A working Traffic Lights (with 3 env_sprites)
Post Reply
Quote
Re: A working Traffic Lights (with 3 env_sprites)
Posted by JohnSmith on Sun Jan 9th at 7:35pm 2005


Hi!

I'm trying to make a working "traffic lights", but i'm having some troubles..

I have 3 env_sprites named: Green, Orange, and Red. They show/hide Sprites via the Outputs/Inputs thingy..

My question is about the: My ouptut named ..what should i do with this? (the default choices are OnUser1 (2/3/or 4) but i dunno what does it means and what does it do)...I've checked the SDK doc, but it didn't helped.

And also, how i make start working the traffic lights? Must it be triggered by something (like a trigger_once) or can it starts from its own?

Thanks by advance if you can help me.





Quote
Re: A working Traffic Lights (with 3 env_sprites)
Posted by Myrk- on Sun Jan 9th at 7:40pm 2005


Think you'll find thats amber, not orange [addsig]



Quote
Re: A working Traffic Lights (with 3 env_sprites)
Posted by Leperous on Sun Jan 9th at 7:51pm 2005


A logic_auto will trigger things automatically with the OnMapSpawn output. And sprites don't have any outputs really, you will want a logic_relay or other entity to trigger them instead.



Quote
Re: A working Traffic Lights (with 3 env_sprites)
Posted by JohnSmith on Sun Jan 9th at 9:00pm 2005


Yea...but isn't the logic_relay a kind of Multi_Manager?

Cause i've read somewhere that the Multi_manager is now obsolete because of the Outputs/inputs thingy..And so it now limits the entities in a map..(good for server performance)

So isn't it an "oldshool" method?

And is there absolutely no way to make it working with only 3 env_sprites and 1 Logic_auto ?

I dont know, because i still absolutely dont understand the field: My ouptut named..

If someone can explain me what does it do, or if it exists a good tutorial about this, let me know

PS for Myrk: In France, it's orange





Quote
Re: A working Traffic Lights (with 3 env_sprites)
Posted by Rof on Sun Jan 9th at 9:43pm 2005


Logic_relays aren't obsolete. They aren't any type of multi_manager, it's just that with the new entity I/O system, you can use logic_relays to replace multi_managers.

No, I don't think there's a way to make it work properly with just 3 env_sprites and the logic_auto. You need some way to time the state changes of the sprites. I'd use a logic_timer, though I'm sure there are other ways to do it.

Now for what "my output named" means. Almost all entities now have a variety of inputs and outputs. The inputs are like little commands other entities can send to that entity. For example if you look at env_sprite, it has inputs:

Kill - destroys the entity
Alpha - sets the sprite's alpha value
Color - sets the sprite's color (RGB)
HideSprite - hides the sprite
ShowSprite - shows the sprite
ToggleSprite - toggles between hiding and showing the sprite
(there are some other inputs, too, that I'm skipping.)

Now for outputs. Outputs are events that happen to the entity. When the event happens, they fire. As it happens, env_sprite doesn't have any outputs (except the OnUserX ones, which are rarely needed and not useful for what you want to do). So lets look at the outputs of the func_button entity:

OnDamage: fires when the button is damaged
OnPressed fires when the button is pressed
OnIn: fires when the button reaches the fully-in position
OnOut: fires when the button reaches the fully-out position

So for instance, if you want to have a button that turns on a sprite, on the func_button's output tab you'd set:

My Output Named: OnPressed
Target Entities Named: <the name of the env_sprite>
Via This Input: ShowSprite
Delay: 0

So now, when you press the func_button, the output (OnPressed) sends a command to the env_sprite to show itself (ShowSprite), and does it immediately (Delay 0)

Now you could add another output to the func_button:
Output Named: OnPressed
Target: <the env_sprite>
Input: HideSprite
Delay: 5

This will wait 5 seconds (Delay 5) and then send a HideSprite command to the env_sprite, when the button is pressed. So together with the first output, pressing the button will turn on the sprite, and after 5 seconds turn it off again.

You can add many outputs one entity, so if you had several sprites (with different names) you could easily make pressing the button turn off some of them, and turn on others.




Quote
Re: A working Traffic Lights (with 3 env_sprites)
Posted by Nanodeath on Sun Jan 9th at 11:04pm 2005


? quote:
No, I don't think there's a way to make it work properly with just 3 env_sprites and the logic_auto.


Actually, I believe you can. This would be the perfect case for using the User1 inputs/outputs. Okay, so all the sprites start out off, right? You have the logic_auto fire the OnUser1 of, say, the red sprite. Now, this sprite has outputs something like the following:

Show red sprite 0.0

Hide red sprite 10.0
Show green sprite 10.0

Hide green sprite 20.0
Show orange sprite 20.0

Hide orange sprite 25.0
Fire OnUser1 of red sprite 25.0

And...that would do it, I think.

EDIT: alternatively, if you want it a little more "decentralized" than that, you could do it as follows:

Logic_auto fires OnUser1 of the red sprite

OnUser1, the red sprite turns itself on for 10 seconds, then turns itself off and executes the OnUser1 of the green sprite.

On the OnUser1 of the green sprite, it turns itself on for 10 seconds, then turns itself off and executes the OnUser1 of the orange sprite.

On the OnUser1 of the orange sprite, it turns itself on for 5 seconds, then turns itself off and executes the OnUser1 of the red sprite, and the cycle continues.

Either way would work...




Quote
Re: A working Traffic Lights (with 3 env_sprites)
Posted by JohnSmith on Tue Jan 11th at 3:21pm 2005


Thanks for the explanation guys

Gonna try later.





Quote
Re: A working Traffic Lights (with 3 env_sprites)
Posted by brett5010 on Tue Jan 11th at 6:26pm 2005


If you manage to get a working traffic light, can you show me exactly how it works? Our competition site is working on a map and we've been trying to get traffic lights working for weeks...





Post Reply