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.

Problem with cooking

Featured Replies

So I'm trying to make a simple cooking script that cooks in Al-kharid and everything is working smoothly except for one thing. The problem occurs when I'm trying to interact with the cook all widget. When the code looks like this the script presses on the fish and then on the range like five times before eventually pressing on cook all. I then tried to add an if statement to see if that would solve it:

 

if(!cookAll.isVisible()) {

 getInventory().interact("Use", mat);
                range.interact("Use");

                sleep(1000);

}

else {
               cookAll.interact("Cook");
              

 sleep(1000);

//I guess I could use a conditional sleep here but thats not the problem

}

But when I do this the client freezes.

 


 

Spoiler

 

package simplecooker;


 


import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "mex", info = "cooks in al kharid", logo = "df", name = "alkahrid cooker", version = 1.0)

public class Everything extends Script {

    final Area COOKINGAREA = new Area(3272, 3182, 3274, 3179);
    final Area BANKINGAREA = new Area(3269, 3170, 3271, 3164);
   

    @Override
    public int onLoop() throws InterruptedException {
        RS2Object range = objects.closest("Range");
        RS2Widget cookAll = getWidgets().get(270, 14);
        String mat;
        mat = "Raw trout";
        
    

        if (getInventory().contains(mat)) {
            if (COOKINGAREA.contains(myPlayer())) {
                if (!myPlayer().isAnimating()) {
                if(!cookAll.isVisible()) {
              

               getInventory().interact("Use", mat);
                range.interact("Use");
                }
                    

                 cookAll.interact("Cook");
                    sleep(2000);
                
                    
                    

                }
                {
                }

            } else {
                getWalking().webWalk(COOKINGAREA);
                

            }

        } else {
            getWalking().webWalk(BANKINGAREA);
        }
        if (BANKINGAREA.contains(myPlayer())) {
            if (getBank().isOpen()) {
                bank.depositAll();
                sleep(2000);
                bank.withdraw(mat, 28);
                sleep(2000);
            } else {
                bank.open();
                sleep(2000);
            }

        }

        return 100;
    }

}
 

 

 

 

 

 

Edited by Jammer

You're not null checking your widget, which is probably why the script freezes. I'd also look into using an alternative method to find your widget as using static IDs isn't the best practice when there's so many other ways to do it. 

  • Author
1 hour ago, HeyImJamie said:

You're not null checking your widget, which is probably why the script freezes. I'd also look into using an alternative method to find your widget as using static IDs isn't the best practice when there's so many other ways to do it. 

Thanks got it to work at last, I was starting to go insane. 

RS2Widget cookAll = getWidgets().getWidgetContainingText("Cook"); Do you mean something like that?

And btw, why doesn't isVisible work but checking if it's null does?

Edited by Jammer

  • 1 year later...
On 10/22/2017 at 5:01 AM, HeyImJamie said:

NullPointerExceptions are exceptions that occur when you try to use a reference that points to no location in memory (null) as though it were referencing an object. Calling a method on a null reference or trying to access a field of a null reference will trigger a NullPointerException. 

For example,

String s = null;
int len = s.length();  // NullPointerException because s is null

So you should check if the variable is null before calling any method on it, for example:

int len;
if (s == null) {
    len = 0;
}
else {
    len = s.length();  // safe, s is never null when you get here
}

 

And just like a NPE, this thread is dead, don't try to access it 💀 🤣

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.