Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Continuity with calculations.random()


    JAG98

    Recommended Posts

    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

    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);
    	}
    }

     

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.