I'm trying to convert a zone creation plugin to sourcepython. I'm having an issue with creating triggers.
The following sourcemod code is what I've been using. Its based off this.
Syntax: Select all
int trigger = CreateEntityByName( type );
DispatchKeyValue( trigger, "spawnflags", "1" );
DispatchKeyValue( trigger, "targetname", name );
if ( filterName[0] ) {
DispatchKeyValue( trigger, "filtername", filterName );
}
DispatchKeyValue( trigger, "wait", "0" );
DispatchSpawn( trigger );
ActivateEntity( trigger );
TeleportEntity( trigger, mid, NULL_VECTOR, NULL_VECTOR );
SetEntityModel( trigger, "models/error.mdl" );
SetEntPropVector( trigger, Prop_Send, "m_vecMins", min );
SetEntPropVector( trigger, Prop_Send, "m_vecMaxs", max );
SetEntProp( trigger, Prop_Send, "m_nSolidType", 2 );
int iEffects = GetEntProp( trigger, Prop_Send, "m_fEffects" );
iEffects |= 32;
SetEntProp( trigger, Prop_Send, "m_fEffects", iEffects );
The sourcepython version is
Syntax: Select all
def create_trigger(start: Vec3, end: Vec3):
end.z += 100
center = ((end - start) * 0.5) + start
start -= center
end -= center
start = start.abs()
end = end.abs()
start *= -1.0
entity = Entity.create('trigger_multiple')
entity.spawn_flags = 1
entity.target_name = 'nametest'
entity.spawn()
entity.origin = center.to_vec()
entity.model = error
entity.maxs = end.to_vec()
entity.mins = start.to_vec()
entity.solid_type = SolidType.BBOX
entity.effects |= 0x020
When I loop through the entities, the trigger appears - with the values set correctly. The problem is that OnEntityOutput isn't called when walking through where the trigger should be. I don't really see a difference in the code, except for ActivateEntity, which doesn't seem relevant to the issue. Any ideas of what this could be?
Thanks, and sorry if I'm missing something obvious. I've been watching sourcepython for a while, but this is my first time ever using it.
edit* I reinvented the wheel a bit with the Vec3 class, it converts to the expected Vector format correctly, but I'll change that later.