Atom Posted September 25, 2015 Share Posted September 25, 2015 (edited) Hi All, I am wondering if VEX has the equivalent of the C style switch statement, or an IFELSE? Basically I am running into a small problem with just using IF statements only. Consider code... if (s@state_current == "attack") { // Should I switch to defend? float decide = rand(i@id+current_time+ch("rand_seed")); if (decide > f@sf_defend_chance) { printf("Switching from ATTACK to DEFEND for id#%d.\n", i@id); // Switching to defend mode. i@crowdtrigger_attack_defend = 1; s@state_current == "defend"; } } if (s@state_current == "defend") { // Should I switch to attack? float decide = rand(i@id+@Frame+ch("rand_seed")); if (decide > f@sf_attack_chance) { printf("Switching from DEFEND to ATTACK for id#%d.\n", i@id); // Switching to attack mode. i@crowdtrigger_defend_attack = 1; s@state_current == "attack"; } } In this case, if I am attacking and I randomly switch back to defend when I drop out of that 1st IF statement there is still a random chance that I could actually flip-flop back to attack again, which I don't want to ever happen. If only VEX had a switch or select case or something...? Edited September 26, 2015 by Atom Quote Link to comment Share on other sites More sharing options...
JonathanGranskg Posted September 25, 2015 Share Posted September 25, 2015 You can use: if (condition) { do something } else if (condition) { do something else } It works the same way. Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted September 25, 2015 Share Posted September 25, 2015 http://www.sidefx.com/docs/houdini14.0/vex/statement Quote Link to comment Share on other sites More sharing options...
Atom Posted September 26, 2015 Author Share Posted September 26, 2015 Thanks, I missed the ELSE IF when reading over the docs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.