if else condition

Avatar
sylvaing
7 Posts
Posted Sep 12, 2011
Hello guys,

For my first custom map, I'm stuck at a point where I need to have some kind of if/else statement.

What I need to accomplish is :

Whenever a cube hit a prop_floor_cube_button, I want to compare the value of a running timer. If the timer value is less then 16 seconds OR more than 17 seconds, I want to kill the player.

Basically, the player needs to put the cube on the prop_floor_cube_button between 16 and 17 seconds.

What is working right now :
- I got a button that once pressed, get the timer to start.
- I got a logic to kill the player.

Can anyone help me on this?

Best regards

Sylvain

Advertisement
Registered users don’t see ads! Register now!
Avatar
Vordwann
767 Posts
Posted Sep 12, 2011
Replied 8 minutes later
sounds like a reflex map!
Avatar
sylvaing
7 Posts
Posted Sep 12, 2011
Replied 3 minutes later

Vordwann wrote:
sounds like a reflex map!

It's more like "hear a song" and act about it :smile:

Avatar
Mevious
205 Posts
Posted Sep 12, 2011
Replied 20 minutes later

From the sound of it, you want to use two logic_compares.

http://developer.valvesoftware.com/wiki/Logic_compare

Avatar
sylvaing
7 Posts
Posted Sep 12, 2011
Replied 25 minutes later

Mevious wrote:
From the sound of it, you want to use two logic_compares.
http://developer.valvesoftware.com/wiki/Logic_compare

Thanks Mevious, this make sense now.

All I need to find out now is how to "setValue" the current value of my logic_timer to my logic_compare and I will be fine.

Anyone got an idea?

Regards,

Sylvain.

Avatar
Mevious
205 Posts
Posted Sep 12, 2011
Replied 32 minutes later
Oh I thought you had it sorted out how you are sending the value, so I wasn't worrying about that part. To be honest I don't really know a lot about timers and sending values, and I'm not sure how to do this the way you're trying to.

It's a bit different, but here's how I would do it. Make a timer that runs for 16 seconds and add these outputs:
OnTimer : trigger_to_kill_player : Disable : 0.00
OnTimer : trigger_to_kill_player : Enable : 1.00
OnTimer : trigger_to_kill_player_end : Trigger : 2.00

When the player places a cube on the button it should try to trigger the "trigger_to_kill_player", and if the player does it at the right time then he should be in good shape.

In this case "trigger_to_kill_player_end" is used to kill the player if he doesn't ever put the box on the button. Simply send the outputs from the button:
OnPressed : trigger_to_kill_player : Trigger : 0.00
OnPressed : trigger_to_kill_player_end : Disable : 0.00

Does that make sense? It's kind of a different way of thinking out it, but I think it'll work.

Avatar
sylvaing
7 Posts
Posted Sep 12, 2011
Replied 13 minutes later
Good idea. I will try it out and let you know very soon.
Avatar
sylvaing
7 Posts
Posted Sep 12, 2011
Replied 2 hours later

Mevious wrote:
Oh I thought you had it sorted out how you are sending the value, so I wasn't worrying about that part. To be honest I don't really know a lot about timers and sending values, and I'm not sure how to do this the way you're trying to.

It's a bit different, but here's how I would do it. Make a timer that runs for 16 seconds and add these outputs:
OnTimer : trigger_to_kill_player : Disable : 0.00
OnTimer : trigger_to_kill_player : Enable : 1.00
OnTimer : trigger_to_kill_player_end : Trigger : 2.00

When the player places a cube on the button it should try to trigger the "trigger_to_kill_player", and if the player does it at the right time then he should be in good shape.

In this case "trigger_to_kill_player_end" is used to kill the player if he doesn't ever put the box on the button. Simply send the outputs from the button:
OnPressed : trigger_to_kill_player : Trigger : 0.00
OnPressed : trigger_to_kill_player_end : Disable : 0.00

Does that make sense? It's kind of a different way of thinking out it, but I think it'll work.

My "trigger_to_kill_player" does start on "toggle" even if it's disabled. I say "toggle" here because I didn't find any "trigger" call as you were mentioning. Maybe I'm not using the good objects here. As such, the player always get killed, no mater what he does.

This is what I got :

trigger_to_kill_player and trigger_to_kill_player_end are "trigger_hurt" objects.

OnTimer : trigger_to_kill_player : Disable : 0.00
OnTimer : trigger_to_kill_player : Enable : 1.00
OnTimer : trigger_to_kill_player_end : Toggle : 2.00

Button:
OnPressed : trigger_to_kill_player : Toggle : 0.00
OnPressed : trigger_to_kill_player_end : Disable : 0.00

I'm most likely doing something wrong here ; I've been on Hammer for only one week now. Any help will be greatly appreciated.

Regards,

Sylvain.

Avatar
Mevious
205 Posts
Posted Sep 13, 2011
Replied 33 minutes later
I should have been more specific. In my example both of the "trigger_to_kill..." were logic_relays. They can be used to relay a series of events or act as a gate for triggered events like in this situation. A disabled logic_relay will do nothing when triggered, but an enabled one will pass the message to whatever entities you want. In this case, you want your trigger_hurt to start disabled and both of the logic_relays to enable it when triggered.

E.g.,
logic_timer:
OnTimer : kill_relay_01 : Disable : 0.00
OnTimer : kill_relay_01 : Enable : 1.00
OnTimer : kill_relay_02 : Trigger : 2.00

prop_floor_button:
OnPressed : kill_relay_01 : Trigger : 0.00
OnPressed : kill_relay_02 : Disable : 0.00

kill_relay_01 and 02 (both logic_relay):
OnTriggered : hurt_area(the trigger_hurt) : Enable : 0.00

Avatar
sylvaing
7 Posts
Posted Sep 13, 2011
Replied 10 hours later
Thanks Mevious. I'll try this tonight and keep you posted.

Sylvain.

Avatar
sylvaing
7 Posts
Posted Sep 13, 2011
Replied 8 hours later
Your idea works perfectly!!

Thanks a lot!!!!

Sylvain.

Advertisement
Registered users don’t see ads! Register now!
Avatar
iWork925
1,080 Posts
Posted Sep 13, 2011
Replied 54 minutes later
...and the magic 8 ball says:

Don't double post.