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.

My First Script HELP

Featured Replies

Well, I really didn't want to ask for help and try to figure this out myself but...I just don't understand why my script is not running. I click start and it just stands there by the jug...:/

If anyone can help and explain too me how to fix this to make it take the Jug in lumbridge kitchen and then drop and wait....please I would love you.

Here is my Code

Spoiler

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.api.model.RS2Object; 
 
import java.awt.*;


 
@ScriptManifest(author = "Toxic", info = "My first script", name = "Lumbridge Jug Stealer", version = 0, logo = "")
public class Main extends Script {
 
    @Override
    public void onStart() {
        log("Welcome to Toxic's Jug Stealer.");
        log("This is my first sript ever, hope you enjoy!");
    }
    
    private enum State {
        TAKE, DROP, WAIT
    };
    
    private State getState() {
        RS2Object Table = getObjects().closest("Jug");
        if (!inventory.isEmpty())
            return State.DROP;
    if (Table != null)
            return State.TAKE;
        return State.WAIT;
    }
 
    @Override
    public int onLoop() throws InterruptedException {
        switch (getState()) {
        case TAKE:
            RS2Object Table = getObjects().closest("Jug");
            
            if (Table != null) {
                    Table.interact("Take");
            }
            break;
        case DROP:
                inventory.dropAll();
                break;
        case WAIT:
                sleep(random(500, 700));
                break;
        }
        return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thanks for running my Jug Stealer!");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
        g.drawString("Hello Jugs!", 50, 50);
    }
 
}

 

 

It's possible the RS2Object call within your getState method is stopping it from running. Try with the script logged in. If that fixes it you could add a while loop to your onStart method that waits for the script to be logged in before your getState method is called :) 

  • Author
4 minutes ago, HeyImJamie said:

It's possible the RS2Object call within your getState method is stopping it from running. Try with the script logged in. If that fixes it you could add a while loop to your onStart method that waits for the script to be logged in before your getState method is called :) 

I am already logged in while starting the script and it does nothing still.

jug is a GroundItem

 

 

edit: btw you search for a jug twice (getState / TAKE case), maybe you could cache it

Edited by Stimpack

  • Author

@HeyImJamie Helped me with it all on teamviewer

Also showed me a bunch of other stuff...love this guy haha.

Will be doing pseudo code from now on

  • Author
16 minutes ago, Juggles said:

Super bowl is on. No coding. 

Your right, I apologize :(

You're trying to grab the nearest Object, when jugs are grounditems. use getGroundItems().closest() as I use in the example.

 

GroundItem jug = getGroundItems().closest("Jug");

if(jug != null && jug.exists() && jug.interact("Take")) {

// Interaction successful - sleep here

}

  • Author
9 hours ago, Prozen said:

You're trying to grab the nearest Object, when jugs are grounditems. use getGroundItems().closest() as I use in the example.

 

GroundItem jug = getGroundItems().closest("Jug");

if(jug != null && jug.exists() && jug.interact("Take")) {

// Interaction successful - sleep here

}

Got it, Thank you :D

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.