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
  • Question related to State Framework.


    Cardozz

    Recommended Posts

    Hi there,

     

    So to make a long story short: my state framework is checking what state it's in after it's clicked a tile on the minimap using the getWalking().walk(Tile tile) method. Is this usual or am I doing something wrong?

     

    Thanks in advance :)

    Link to comment
    Share on other sites

    Hi there,

     

    So to make a long story short: my state framework is checking what state it's in after it's clicked a tile on the minimap using the getWalking().walk(Tile tile) method. Is this usual or am I doing something wrong?

     

    Thanks in advance :)

    If you have some method like this:

    public void doThing() {
      if (getInventory().contains("stuff") {
        state = 1;
      }
    
      if (getInventory().contains("other stuff") {
        log("other stuff");
      }
    
    }
    

    The method will still execute after the assignment to state. So it keeps going past the first if statement. To fix this, add a return; after your state assignment if your method has other things going on after it.

     

    PS: Posting a snippet on pastebin/in code tags will help the most for us to help you.

    Link to comment
    Share on other sites

    • 1 month later...

    You could also add a break after each state:

     

    state = getState()

    switch(state) {

    case1:

    //actions

    break;

    case2:

    //actions

    break;

     

    etc.

    }

    return Calculations.random(700,900); //on loop return after states block

    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.