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.

interact() returning true even though entity is not interacted with

Featured Replies

Hi there. I'm making a simple Mining Guild bot. I'm having an issue where the bot will sometimes misclick the ladders or coal veins and get stuck. I am currently using the following snippet to perform the interaction (example below is for climbing down the ladder):

RS2Object ladder = objects.closest("Ladder");
while (!ladder.interact("Climb-down")) sleep(100);

I believe interact() may be returning true even though the ladder/vein was not properly interacted with.

 

I was wondering if anyone else was having this issue. Thanks in advance for the help.

Hi there. I'm making a simple Mining Guild bot. I'm having an issue where the bot will sometimes misclick the ladders or coal veins and get stuck. I am currently using the following snippet to perform the interaction (example below is for climbing down the ladder):

RS2Object ladder = objects.closest("Ladder");
while (!ladder.interact("Climb-down")) sleep(100);

I believe interact() may be returning true even though the ladder/vein was not properly interacted with.

 

I was wondering if anyone else was having this issue. Thanks in advance for the help.

 

I have been in scripting for a long time now, I am just going to tell you that 

1) Using a while loop in this manner is a bad idea.

2) Do not ever depend on one of the methods to return a correct boolean. 

3) You dont have a single null check on the ladder

 

What if the interaction was successful, but the interaction still returned false? Then that while loop would likely get stuck trying to interact with an object that doesnt exist, and your script would do nothing.

 

Dont use the return values in this manner, and dont use a while loop in this manner.

 

This type of logic is shakey and be easily broken. Make your script stable by having a strong baseline of logic that can handle any situation.

 

I believe interact() may be returning true even though the ladder/vein was not properly interacted with.

 

 

The boolean just reflects whether a mouse click was transmitted to the entity's  (option's) click region.

 

You might want to check whether you are in the area below or above the ladder (actual proof of whether the interaction was succesfull) instead of relying on that metho's boolean too much.

  • Author

Thanks for the input. I'm new to RS Scripting. Seems confusing for interact to return true when interaction has not actually occurred.

 

What would you guys recommend then? Something like:

RS2Object ladder = getScript().objects.closest("Ladder");

if (ladder != null) {
  while (UPPER_LADDER_AREA.contains(myPlayer())) {
    ladder.interact("Climb-down");
    sleep(100);
  }
}

Thanks again for the input.

Edited by abotter

I'd use something like:

if floor = 1 then
  attempt to click ladder
  wait for a small amount of time
  if moving/animating then wait a little longer (LocalWalker#waitUntilIdle() or smth similar)

As Mysteryy points out you shouldn't use a while loop. You want to do 1 action each time the onLoop method executes.

Edited by Flamezzz

  • Author

As Mysteryy points out you shouldn't use a while loop. You want to do 1 action each time the onLoop method executes.

 

I see the issue now. I am performing more than one action in the walk states. Currently I am using the State paradigm with four states: BANK, MINE, WALK_TO_BANK, and WALK_TO_MINE.

 

I guess Ill have to expand the WALK_TO_MINE state to WALK_TO_UPPER_LADDERS, GO_DOWN_UPPER_LADDERS, and WALK_TO_MINE, and a similar expansion for the WALK_TO_BANK state.

 

Thanks you all for the help. I'll try implementing this and see if it works.

Edited by abotter

I see the issue now. I am performing more than one action in the walk states. Currently I am using the State paradigm with four states: BANK, MINE, WALK_TO_BANK, and WALK_TO_MINE.

 

I guess Ill have to expand the WALK_TO_MINE state to WALK_TO_UPPER_LADDERS, GO_DOWN_UPPER_LADDERS, and WALK_TO_MINE, and a similar expansion for the WALK_TO_BANK state.

 

Thanks you all for the help. I'll try implementing this and see if it works.

 

Generally speaking you should not ever use potentially infinite loops. You should do your action, and determine the result from the state / positions of the player or its surroundings. If your state does not change as a result of the action; try the action again in the next loop.

 

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.