Please or Register to create posts and topics.

if statements using outputs and inputs?

Hey there,
I was wondering: Is there a way to make an if-statement ( like in programming ) using outputs and inputs? Because I need to create an if-statement for a button: If button pressed and If the animation of a specific prop_dynamic is equals to, lets say, 90down, then execute SetAnimation for prop_dynamic to 90up, else return nothing.

So, is it possible to something like this perhaps?

I was wondering the same thing before but then someone pointed me to math_counter and logic_relay....and the combination of multiple of those, I have been able to successfully mimic if statements.

In your case you might have to use 2 logic_relays (one to animate the panel up and the other to animate the panel down) and a math_counter.

-
2 logic_branch's - 1 logic_branch_listener

Add to button

Code: Select all
onpressed > [name_of_first_branch] > setvalue > true
onupressed > [name_of_first_branch] > setvalue > false

Add to panel out relay

Code: Select all
ontrigger > [name_of_panel_arm] > setanimation > 90deg_out_cornerback
ontrigger > [name_of_second_branch] > setvalue > true

Make a logic_branch_listener - set its branches to above

Code: Select all
OnAllTrue > [name_of_panel_arm] > setanimation > 90deg_in_cornerback
Image
PortalStories.com
"Oh, in case you got covered in that repulsion gel, here's some advice the lab boys gave me: DO NOT get covered in the repulsion gel."

How should that work?
The branch-listener doesnt get's even gets triggers by the button, so how should the branch listener set the animation then? Also, even if this would work, the animation would stay for ever, but i want to close it after a while. I also use the telescope_arm_128, so the animation you gave me wouldnt work ( but I guess you just used it as an example, hehe )

A branch listener checks what states the specified logic_branches have. If all are true (Value 1) it will fire the output "OnAllTrue".
The following will happen: OnPressed - first branche is true. If the logic_relay triggers the second branch will be true and the animation 90down will play. Now both branches are true and the animation you wanted plays. Now the listener plays the other animation, because both branches are true (both conditions are fullfilled).
To close it after a while just work with a delay for the closing animation.

Emm, and why doesnt it works for me when I'm ingame? I mean, I did like he said, but it doesnt works when I press the button.

Skelpolu wrote:
Emm, and why doesnt it works for me when I'm ingame? I mean, I did like he said, but it doesnt works when I press the button.

Not sure if this might help, but i'm pretty sure you just need the knowledge from this tutorial
and adapt / extend it a bit.

rtT8haN8_Fw

I see what you did there ..
Well, I'm gonna take a look at this later on when I got some more freetime. Thanks :)

If your problem is just that the prop_dynamic is replaying the 90up animation while it is already in that position, try replacing your "SetAnimation" outputs with "SetAnimationNoReset" outputs.

Sendificate series: Sendificate | A Beam Too Far | Airtime | 302
Other Portal 2 maps: Medusa Glare
Portal 1 maps: Try Anything Twice | Manic Mechanic

Ha, that is not the problem at all, since it does NOTHING.
I press the button: nothing happens.
I used the way iWork925 wrote above.