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.

A Beginners Guide to Writing OSBot Scripts (where to get started!) by Apaec

Featured Replies

 

Replace your getState() method with this

private State getState() {
		Entity FS = npcs.closest("Fishing spot");
		if (!inventory.isEmptyExcept("Small fishing net"))
			return State.DROP;
		if (FS != null && !myPlayer.isAnimating() && !myPlayer.isMoving())
			return State.FISH;
		return State.WAIT;
	}

 

fixed

private State getState() {	
if (!inventory.isEmptyExcept("Small fishing net")) return State.DROP;
else {
Entity FS = npcs.closest("Fishing spot");
if (FS != null && !myPlayer.isAnimating() && !myPlayer.isMoving()) {
return State.FISH;
}                 
return State.WAIT;
}

 

Replace your getState() method with this

private State getState() {
		Entity FS = npcs.closest("Fishing spot");
		if (!inventory.isEmptyExcept("Small fishing net"))
			return State.DROP;
		if (FS != null && !myPlayer.isAnimating() && !myPlayer.isMoving())
			return State.FISH;
		return State.WAIT;
	}

 

 

 

fixed

private State getState() {	
if (!inventory.isEmptyExcept("Small fishing net")) return State.DROP;
else {
Entity FS = npcs.closest("Fishing spot");
if (FS != null && !myPlayer.isAnimating() && !myPlayer.isMoving()) {
return State.FISH;
}                 
return State.WAIT;
}

Thanks both, got it working!

This looks really good, I'm hopefully going to learn some scripting stuff once I finish my exams and this will definitely be where I start!

Followed your guide and i really enjoyed it, i tried to make a simple lesser demon killer but i received a couple errors in eclipse as well as in OSbot (obviously)

 

Errors in eclipse were: state cannot be resolved to a type 

Errors in OSbot were: unknown source, wait and attack cannot be resolved to a variable

 

My script

import org.osbot.rs07.api.model.Entity;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
import java.awt.*;
 
@ScriptManifest(author = "You", info = "My first script", name = "aLesserDemonKiller", version = 0, logo = "")
public class main extends Script {
 
    @Override
    public void onStart() {
        log("Let's kill some demons!");
    }
    
    private enum state {
    ATTACK, WAIT
    };
    
private State getState() {
NPC demon = npcs.closest("Lesser demon");
if (demon != null)
return State.ATTACK;
return State.WAIT;
}
 
    @Override
    public int onLoop() throws InterruptedException {
    switch (getstate()) {
    case ATTACK:
    NPC demon = npcs.closest("Lesser demon");
    if (demon !=null) {
    demon.interact("Attack");
    }
    break;
    case wait: 
    sleep(random(500, 700));
    break;
    }
        return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thank you for running my script!");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}

 
 

Edited by Aart1

Followed your guide and i really enjoyed it, i tried to make a simple lesser demon killer but i received a couple errors in eclipse as well as in OSbot (obviously)

Errors in eclipse were: state cannot be resolved to a type

Errors in OSbot were: unknown source, wait and attack cannot be resolved to a variable

My script

import org.osbot.rs07.api.model.Entity;

import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;

@ScriptManifest(author = "You", info = "My first script", name = "aLesserDemonKiller", version = 0, logo = "")

public class main extends Script {

@Override

public void onStart() {

log("Let's kill some demons!");

}

private enum state {

ATTACK, WAIT

};

private State getState() {

NPC demon = npcs.closest("Lesser demon");

if (demon != null)

return State.ATTACK;

return State.WAIT;

}

@Override

public int onLoop() throws InterruptedException {

switch (getstate()) {

case ATTACK:

NPC demon = npcs.closest("Lesser demon");

if (demon !=null) {

demon.interact("Attack");

}

break;

case wait:

sleep(random(500, 700));

break;

}

return random(200, 300);

}

@Override

public void onExit() {

log("Thank you for running my script!");

}

@Override

public void onPaint(Graphics2D g) {

}

}

Make it public enum State and not state.

I followed the instructions in the OP and went to test the tea stealer but it is not showing up in my list of scripts in OSbot. Did I do something wrong?

Apaec, would you be able to help me? For whatever reason I can't run eclipse, it says it downloads but then I can't find the file etc...

I followed the instructions in the OP and went to test the tea stealer but it is not showing up in my list of scripts in OSbot. Did I do something wrong?

 

Where did you put the compiled script?

osbot/scripts

 

The script could be broken. Try refreshing your local scripts in the OSBot client if it's just not showing up. Otherwise, check your script for errors and recompile.

Greatly appreciated man was going to post about the basics have minimum script coding knowledge from school. Very informing post!

 

Followed your guide and i really enjoyed it, i tried to make a simple lesser demon killer but i received a couple errors in eclipse as well as in OSbot (obviously)

 

Errors in eclipse were: state cannot be resolved to a type 

Errors in OSbot were: unknown source, wait and attack cannot be resolved to a variable

 

 

...

    case wait: 
    sleep(random(500, 700));
    break;

 

Another thing I noticed is that in your switch block, "wait" should be "WAIT". Your private enum has entries ATTACK and WAIT, and Java is case-sensitive. Case "wait" will never trigger as is. 

When i try to open Eclipse.exe i get an error: Java was started but returned to exit code=13, Installed the newest version of Java and still get the same error. Any help?

 

-Fixed!

Edited by hybride4life

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.