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.

furnace interface keeps opening repeatedly instead of staying open until I finish crafting.

Featured Replies

Issue: In my script for crafting Gold Necklaces, the furnace interface keeps opening repeatedly instead of staying open until I finish crafting.

 

Context: I’m using a loop that checks if the furnace interface is open. If not, it interacts with a nearby furnace to open it. Once opened, I store the interface in a widget holder and then proceed with crafting. However, if the widget isn’t visible (or becomes non-visible), I set a flag (interfaceOpened) to false, which then triggers another furnace interaction. This leads to the furnace interface being opened over and over again. while 

 

while (getInventory().contains(GOLD_BAR)) {
    RS2Object furnace = getObjects().closest("Furnace");

    if (!interfaceOpened) {
        if (furnace != null && furnace.interact("Smelt")) {
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() {
                    smeltInterfaceHolder[0] = getWidgets().get(446, 23);
                    return smeltInterfaceHolder[0] != null;
                }
            }.sleep();
            interfaceOpened = true;
        }
        continue;
    }

    RS2Widget smeltInterface = smeltInterfaceHolder[0];
    if (smeltInterface == null || !smeltInterface.isVisible()) {
        interfaceOpened = false;
        continue;
    }

    // Crafting code follows...
}

 

 

13 hours ago, CrystalChris said:

Issue: In my script for crafting Gold Necklaces, the furnace interface keeps opening repeatedly instead of staying open until I finish crafting.

 

Context: I’m using a loop that checks if the furnace interface is open. If not, it interacts with a nearby furnace to open it. Once opened, I store the interface in a widget holder and then proceed with crafting. However, if the widget isn’t visible (or becomes non-visible), I set a flag (interfaceOpened) to false, which then triggers another furnace interaction. This leads to the furnace interface being opened over and over again. while 

 

while (getInventory().contains(GOLD_BAR)) {
    RS2Object furnace = getObjects().closest("Furnace");

    if (!interfaceOpened) {
        if (furnace != null && furnace.interact("Smelt")) {
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() {
                    smeltInterfaceHolder[0] = getWidgets().get(446, 23);
                    return smeltInterfaceHolder[0] != null;
                }
            }.sleep();
            interfaceOpened = true;
        }
        continue;
    }

    RS2Widget smeltInterface = smeltInterfaceHolder[0];
    if (smeltInterface == null || !smeltInterface.isVisible()) {
        interfaceOpened = false;
        continue;
    }

    // Crafting code follows...
}

 

 

replied to you on discord in the OSBot help channel:)

Looks to me like ths issue is the while loop...

A simple if would be better

The script onLoop function runs continuously over and over again, so whiles should be used with caution.

Also, while loops should have multiple breaking options or they can get stuck. Even stopping the script won't work sometimes if you don't check if the script is stopping in the while loop.

If you must use while loops, best to make a special while function with all of the necessary checks that will break out of it if needed. That way you can easily implement while loops.

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.