Filtering a mapbased trigger_remove with a Lua created filter_activator_class

I did a lot of scanning through the Valve Dev docs and have done experiment after experiment trying to get a proper result.

I have a map with a trigger_remove entity built into it. It creates an issue when ragdoll entities are spawned in it, causing the server to crash. What I’ve been trying to is create a filter_activator_class to direct it to, obviously with prop_ragdoll filterclass.
I start out by creating the filter using the following code


trigFilterActivator = ents.Create("filter_activator_class")
trigFilterActivator:SetKeyValue("filterclass", "prop_ragdoll")
trigFilterActivator:SetKeyValue("targetname", "trig_filter")
trigFilterActivator:SetKeyValue("negated", 1)
trigFilterActivator:Spawn()

First off, I’m worried that I’m not even using the correct keys. I’ve mixed what I see on Valve Dev along with what little actually gets returned with GetKeyValues and usage I might have seen on other entities.
I’ve tried many more variations of keynames without much luck.

Following this, I run SetKeyValue(“filtername”, “trig_filter”) on the trigger_remove. Again, I’m not comfortable with the keyname, and have tried different variations. I’ve also tried doing SetEntity(“filtername”, trigFilterActivator).
The most I’ve been able to accomplish is changing “spawnflags” of the trigger_remove. The behaviour changes appropriately, but that’s not exactly what I need.

Am I doing things incorrectly, or is this just not possible and I’m trying to turn lead into gold? I can do other methods, but I’d like to use this one if I can. Thanks in advance for any input!

If i understand correctly, you’re unsure if you’re using the correct Keys in the filter_activator_class entity?

If so, place that entity in your map. Open its properties. Turn off SmartEdit, and see what the ‘Filter Classname’ changes to.

This should be the key name as seen from the engine, use that in your SetKeyValue call.

Sorry, I should have clarified that I can’t do it through map editing as I don’t have the VMF.
I’m trying to modify this particular trigger_remove entity with Lua and the addition of the filter_activator_class.

Your ‘filtername’ on your trigger entity seems to be correct, as well as all of your key names for the filter.

What i’d do, to test that your theory is gunna work, is make a simple little map setup the way you’re trying to achieve here, and see if it still crashes.

Then you’ll know if your problem is changing things through lua or physical impossibility with trigger_remove.

The Source SDK wiki DOES say that removing certain entities can cause instability… Perhaps prop_ragdoll is one of them?

Yeah, I reckon it’s something to do with the bones/physobjects of the ragdoll still trying to initialise after it has already been removed. I’m not knowledgeable in the Source workings on that level, so I really shouldn’t even comment on that I guess.

The crash is being caused by the unadultered trigger_remove, without applying any changes via Lua.
That’s what my little project is trying to resolve, just having it ignore the prop_ragdoll class.

I’m certain that I’ve I got a hold of the VMF or decompiled (yuck ) , edited, then recompiled I could just do it by adding a legitimate filter_activator_class and linking it to the trigger_remove things we would be just lovely. I want to stray away from this, though, as the map has been live on the server for a good amount of time, and I don’t want to push a new map just to change one little thing. I’d also like to be able to apply it to other maps that have a built-in trigger remove, so being able to do it on-the-fly is desirable to me.

I guess at this point I’m just hoping someone can say “No, Gmod Lua can’t properly access certain key-values of certain entities”, or a “It’s perfectly doable, keep at it”

Thanks for taking the time to respond, by the way :smiley:

I think you need to call **[Entity.Activate

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.Activate)** on the trigger_remove if you change the filter.



void CBaseTrigger::Activate( void ) 
{ 
	// Get a handle to my filter entity if there is one
	if (m_iFilterName != NULL_STRING)
	{
		m_hFilter = dynamic_cast<CBaseFilter *>(gEntList.FindEntityByName( NULL, m_iFilterName ));
	}

	BaseClass::Activate();
}


Alright, I’ll give that a try right now and see what happens. Thanks!

You wanted it to IGNORE the prop_ragdoll class?

Just set a key called ‘Negated’ to 1, and it will pass all classes except the one supplied.

leiftiger, Activate() was just the trick, works perfectly now. Thank you so much :smiley: