Any entity pros out there?

bob+M|M+

L6: Sharp Member
Mar 31, 2008
346
394
I have a trigger, a red light, and a green light.

The red light is on by default, but when the trigger is activated, the green light will turn on for 5 seconds, and then switch back to red.

What I want to do is.. if the trigger is continuously activated, then the green light will remain on and never switch to red, but upon the last trigger, it will go back to red after 5 seconds.

I'm stumped. If anyone can shed some light on me.. =D
 

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,669
Depends on what kind of trigger it is. If it's an actual brush trigger you can do it just like door triggers, using the OnStartTouch and OnEndTouchAll outputs. If it's some arbitrary 'trigger' that is making stuff happen, I think the easiest way would be to use a team_round_timer, have it turn the light green when it reaches 0, and whenever your 'trigger' occurs force the timer to five seconds.
 

bob+M|M+

L6: Sharp Member
Mar 31, 2008
346
394
I'm using a func_breakable that is activated by OnBreak. I have to use this entity cause it's the only one that physic objects can trigger (I believe?) without needing to cause damage.

So I can't use OnStartTouch or OnEndTouchAll.

team_round_timer won't work because I'll have several of these setups all over my map doing their own thing.

Guess I should have mentioned those things huh?
 
Last edited:

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,669
Trigger_multiple (or _once, since breakables are one time things) have flags to determine what can trigger them, including physobjs. Though I'm not sure how you are using those in TF2 and/or if it's only those or some other method of triggering too.

As far as I know there isn't a limit to team_round_timers, however logic_relay is an alternative for that method. Have the triggering event issue a CancelPending to the relay, and 0.1 seconds later activate the relay, which will turn the light red in 4.9 seconds. This should allow the trigger event to happen in succession while not letting the light turn red until everything is finished.
(unless you meant you can't use t_r_t because you want to keep entity counts down due to lots of these setups?)
 

bob+M|M+

L6: Sharp Member
Mar 31, 2008
346
394
oh if multiple team_round_timers are possible then that would work I suppose. I had the impression that this entity was only for the time limit of the map.

If that doesn't work I'll try your other suggestion. Thanks!

btw, triggeR_multiple and trigger_once cannot be activated by physics objects despite having a "physics object" flag.
 

Apom

L6: Sharp Member
Sep 14, 2008
366
65
Use logic_timer for this, it's much more appropriate and it's very easy to do what you want with it (set 5 second as duration, make it enable + reset when your trigger event happens, and make it disable itself on its own OnTimer event).

PS: you originally wanted the event to be triggered multiple times, but then you say it's triggered by OnBreak. I'm curious, how is that possible? I mean, once it's broken it's broken :D
 

bob+M|M+

L6: Sharp Member
Mar 31, 2008
346
394
The problem with logic_timer is it has no SetMaxTime sort of function like team_round_timer has, so I would have to disable and enable it, which means there would be a short fraction of a second where it would turn red.

As for multiple func_breakables, I simply make the brush respawn itself after its broken by using OnBreak to target an env_entity_maker which spawns a point_template that respawns the func_breakable.

(I could use a shorter way, by avoiding the env_entity_maker and only using the point_template but it was buggy and crashing my game)
 

Apom

L6: Sharp Member
Sep 14, 2008
366
65
The problem with logic_timer is it has no SetMaxTime sort of function like team_round_timer has, so I would have to disable and enable it, which means there would be a short fraction of a second where it would turn red.
Even if this was the case, there wouldn't be red time, because what turns the light red is the OnTimer event, which is not fired when you disable the entity. Not to mention that this fraction of second would anyways be considerably shorter than a screen frame so players wouldn't notice it.

Anyways, you don't need to disable anything, you only need to reset the timer (with ResetTimer, an adequately named input).