Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to determine when an action is completed.

Featured Replies

What is the most reliable way to ensure that an action is completed before starting another one.

 

I know their is sleep methods but is this truly the best way to ensure you give enough time for an event to happen before another one starts ?

 

An example is perfectly fine as a answer to this question and if my question seems unclear just let me know.

 

Thanks in advance.

 

 

Totally depends on what action mate.

Like for a death npc you could check the hitpoints, for woodcutting you could check if the tree still exists and if the bot is animating...

Or for banking you'd check if it's open.

 

Example situation:

onLoop() {
switch (state) {
  case OPEN_BANK:
    banker.interact("Bank");
    state = State.BANK;
    break;

  case BANK:
    if (!getBank().isOpen()) { //if bank is not open
      break; //wait
    } //else
    //Dostuff
    break;
}
return 600;
}
  • Author

 

Totally depends on what action mate.

Like for a death npc you could check the hitpoints, for woodcutting you could check if the tree still exists and if the bot is animating...

Or for banking you'd check if it's open.

 

Example situation:

onLoop() {
switch (state) {
  case OPEN_BANK:
    banker.interact("Bank");
    state = State.BANK;
    break;

  case BANK:
    if (!getBank().isOpen()) { //if bank is not open
      break; //wait
    } //else
    //Dostuff
    break;
}
return 600;
}

 

 

You check for consequences of that action (experience increase, item mutation, player flags, etc...).

 

Thanks, That's all that i needed, I figured that was the way to do it. Was just making sure their wasn't an easier way.

 

Totally depends on what action mate.

Like for a death npc you could check the hitpoints, for woodcutting you could check if the tree still exists and if the bot is animating...

Or for banking you'd check if it's open.

 

Example situation:

onLoop() {
switch (state) {
  case OPEN_BANK:
    banker.interact("Bank");
    state = State.BANK;
    break;

  case BANK:
    if (!getBank().isOpen()) { //if bank is not open
      break; //wait
    } //else
    //Dostuff
    break;
}
return 600;
}

 

That looks extremely unsafe. Bank opening failure = permanent stuck

 

 

Totally depends on what action mate.

Like for a death npc you could check the hitpoints, for woodcutting you could check if the tree still exists and if the bot is animating...

Or for banking you'd check if it's open.

 

Example situation:

onLoop() {
switch (state) {
  case OPEN_BANK:
    banker.interact("Bank");
    state = State.BANK;
    break;
  case BANK:
    if (!getBank().isOpen()) { //if bank is not open
      break; //wait
    } //else
    //Dostuff
    break;
}
return 600;
}

 

Let me fix that for you

onLoop() {
switch (state) {
  case OPEN_BANK:
   if(!getBank().isOpen()){
     if(banker.interact("Bank")){
        state = State.BANK;
     }
   }
     break;
 case BANK:
    if(getBank().isOpen()){
       bank stuff
    }
    break;
}
return 600;
}

Edited by Tom

 

Totally depends on what action mate.

Like for a death npc you could check the hitpoints, for woodcutting you could check if the tree still exists and if the bot is animating...

Or for banking you'd check if it's open.

 

Example situation:

onLoop() {
switch (state) {
  case OPEN_BANK:
    banker.interact("Bank");
    state = State.BANK;
    break;

  case BANK:
    if (!getBank().isOpen()) { //if bank is not open
      break; //wait
    } //else
    //Dostuff
    break;
}
return 600;
}

 

Your states should be based on some boolean condition, not set when you think they should be. Otherwise when an action fails your script will be rekt.

Also you should use the getBank().open() method.

enum State{ OPEN_BANK, BANK }

private State getState(){

    return getBank() != null && getBank().isOpen() ? State.BANK : State.OPEN_BANK;
}

@Override
public int onLoop() throws InterruptedException{
    switch (getState()) {
        case OPEN_BANK:
            getBank().open();
            break;

        case BANK:
            //Dostuff
            break;
    }
    return random(200, 250);
}

 It was just a simple example for OP, don't shoot me

Edited by lisabe96

 It was just a simple example for OP, don't shoot me

 

Shoot him!

 

But seriously you do it in your scripts too

Edited by Explv

Shoot him!

 

But seriously you do it in your scripts too

In my older script i probably did, but not anymore.

Decompile my woodcutting script and you'll see I handle any possible unexpected situations.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.