JAG98 4 Share 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. Link to comment Share on other sites More sharing options...
CodeNinja 32 Share Posted December 21, 2020 (edited) 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); } } Edited December 21, 2020 by CodeNinja JAG98 1 Link to comment Share on other sites More sharing options...
una_maquina 24 Share 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. JAG98 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now