JAG98 4 Posted December 21, 2020 In the snippet below Spoiler int x = Calculations.random(1,3); if(x==1){ //some code } else{ //some other code } How to continue the flow of execution? Every time onLoop will iterate, a new value gets assigned to x and the codes that get executed may change. How to ensure only one segment gets executed after the first iteration. if x ==1, only some code should get executed and shouldn't flip between some other code till a new condition doesn't trigger the change.
CodeNinja 32 Posted December 21, 2020 not exactly sure if i understand you, but it sounds like you want to set x to a random number in onstart, and then dont set it again until your code is completed in the if/else statement psuedo code: onstart { x = Calculations.random(1,3); } loop() { if(x = 1) { if(//your code to execute) { x=Calculations.random(1,3); } } else { if(//your other code to execute) { x=Calculations.random(1,3); } }
una_maquina 36 Posted December 22, 2020 Err, not sure exactly what you need, but maybe you're looking for a "return;" ? This will go back to the beginning without running anything else.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.