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.

Noob needs some help

Featured Replies

Hi, so I'm getting into Java scripting (but I know a decent amount of PHP) and as always, I learn best by actually doing stuff. So therefore I'd like to learn some really basic stuff by making a very simple script. The script I'd like to make should talk against Wyson the gardener at the Falador garden and buy Woad leaves from him.  This is what I have so far:

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;
 
@ScriptManifest(author = "Luigi", info = "Buys Woad leaves from Wyson the gardener in Falador Park", name = "Woad Leaf Buyer", version = 0.1, logo = "")
public class main extends Script {
 
    @Override
    public void onStart() {
        log("Woad Leaf Buyer has started.");
    }
    
	private enum State {
		TALK, WAIT
	};
	
	private State getState() {
		if (condition 1 is true)
			return State.TALK;
		return State.WAIT;
	}

 
    @Override
    public int onLoop() throws InterruptedException {
    	switch (getState()) {
		case TALK:
			NPC gardener = objects.closest("Wyson the gardener");
			if (stall != null) {
				stall.interact("Talk-to");
			}
			break;
		case WAIT:
			sleep(random(500, 700));
			break;
		}
        return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thanks for running my first script");
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}

I'm making this script based upon this beginners tutorial. Eclipse gives me an error on line 20, 30, 31 and 32. What am I doing wrong? Also how can I check if the user has more than 20 coins in his inventory and exit the script, if that ain't the case?

 

Thanks for helping a starting noob like me smile.png

Edited by Scorncial

  • Author

It's a little difficult to read. If you could alter the resolution the SDN scripters might be able to assist you more efficiently

 

I would like to do that :) But could you tell me how?

Hi, so I'm getting into Java scripting (but I know a decent amount of PHP) and as always, I learn best by actually doing stuff. So therefore I'd like to learn some really basic stuff by making a very simple script. The script I'd like to make should talk against Wyson the gardener at the Falador garden and buy Woad leaves from him.  This is what I have so far:

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;
 
@ScriptManifest(author = "Luigi", info = "Buys Woad leaves from Wyson the gardener in Falador Park", name = "Woad Leaf Buyer", version = 0.1, logo = "")
public class main extends Script {
 
    @Override
    public void onStart() {
        log("Woad Leaf Buyer has started.");
    }
    
	private enum State {
		TALK, WAIT
	};
	
	private State getState() {
		if (condition 1 is true)
			return State.TALK;
		return State.WAIT;
	}

 
    @Override
    public int onLoop() throws InterruptedException {
    	switch (getState()) {
		case TALK:
			NPC gardener = objects.closest("Wyson the gardener");
			if (stall != null) {
				stall.interact("Talk-to");
			}
			break;
		case WAIT:
			sleep(random(500, 700));
			break;
		}
        return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thanks for running my first script");
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}

I'm making this script based upon this beginners tutorial. Eclipse gives me an error on line 20, 30, 31 and 32. What am I doing wrong? Also how can I check if the user has more than 20 coins in his inventory and exit the script, if that ain't the case?

 

Thanks for helping a starting noob like me smile.png

Line 30: You want to get to the NPC but you try to define it as an object.

Line 31: You try to interact with a variable called stall but that's never made.

Line 32: Same as 31.

 

For the coin thing:

		if(!(inventory.getAmount(COINID) < 20)) {
			stop();
		}

Edited by Rudie

  • Author

 

Line 30: You want to get to the NPC but you try to define it as an object.

Line 31: You try to interact with a variable called stall but that's never made.

Line 32: Same as 31.

 

For the coin thing:

		if(!(inventory.getAmount(COINID) < 20)) {
			stop();
		}

 

Thanks, your comments helped a lot :) Would you have an idea on how to solve the error on line 20? Also, if I can't define the NPC as an object as what should I define it? The coin thing should this be put between line 27 and 28?

Thanks, your comments helped a lot smile.png Would you have an idea on how to solve the error on line 20? Also, if I can't define the NPC as an object as what should I define it? The coin thing should this be put between line 27 and 28?

Yes put the coin thing at the beginning of your loop.

To define the npc:

		NPC gardener = npcs.closest("Wyson the gardener");

(Also make sure you import NPC).

Line 20 you forgot the brackets at the if statement it should be:

if(code here) {

 

}

  • Author

Yes put the coin thing at the beginning of your loop.

To define the npc:

		NPC gardener = npcs.closest("Wyson the gardener");

(Also make sure you import NPC).

Line 20 you forgot the brackets at the if statement it should be:

if(code here) {

 

}

 

Thanks a lot, but I'm still getting an error on line 21, Eclipse says the following:

 

Multiple markers at this line:

- condition cannot be resolved to a variable

- syntax error on tokens, delete these tokens

 

And how can I find the Id for coins?

 

This is my script now:

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;
 
@ScriptManifest(author = "Luigi", info = "Buys Woad leaves from Wyson the gardener in Falador Park", name = "Woad Leaf Buyer", version = 0.1, logo = "")
public class main extends Script {
 
    @Override
    public void onStart() {
        log("Woad Leaf Buyer has started.");
    }
    
	private enum State {
		TALK, WAIT
	};
	
	private State getState() {
		if (condition 1 is true) {
			return State.TALK;
		} else {
		return State.WAIT;
		}
	}

 
    @Override
    public int onLoop() throws InterruptedException {
    	
    	if(!(inventory.getAmount(COINID) < 20)) {
			stop();
		}
    	
    	switch (getState()) {
		case TALK:
			NPC gardener = npcs.closest("Wyson the gardener");
			if (gardener != null) {
				gardener.interact("Talk-to");
			}
			break;
		case WAIT:
			sleep(random(500, 700));
			break;
		}
        return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thanks for running my first script");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}

Edited by Scorncial

 

Thanks a lot, but I'm still getting an error on line 21, Eclipse says the following:

 

 

And how can I find the Id for coins?

 

This is my script now:

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;
 
@ScriptManifest(author = "Luigi", info = "Buys Woad leaves from Wyson the gardener in Falador Park", name = "Woad Leaf Buyer", version = 0.1, logo = "")
public class main extends Script {
 
    @Override
    public void onStart() {
        log("Woad Leaf Buyer has started.");
    }
    
	private enum State {
		TALK, WAIT
	};
	
	private State getState() {
		if (condition 1 is true) {
			return State.TALK;
		} else {
		return State.WAIT;
		}
	}

 
    @Override
    public int onLoop() throws InterruptedException {
    	
    	if(!(inventory.getAmount(COINID) < 20)) {
			stop();
		}
    	
    	switch (getState()) {
		case TALK:
			NPC gardener = npcs.closest("Wyson the gardener");
			if (gardener != null) {
				gardener.interact("Talk-to");
			}
			break;
		case WAIT:
			sleep(random(500, 700));
			break;
		}
        return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thanks for running my first script");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}

Well you try to see if a boolean is true but you dont check a variable, when programming you can't just put plain text like you have in line 20 in the if statement.

 

And for the coin id it should be 995 if I remember correctly :)

  • Author

Well you try to see if a boolean is true but you dont check a variable, when programming you can't just put plain text like you have in line 20 in the if statement.

 

And for the coin id it should be 995 if I remember correctly smile.png

 

Thanks :) I see, that was very stupid of me :D Do you have any idea how I can check if the player is currently talking to the gardener?

Thanks smile.png I see, that was very stupid of me biggrin.png Do you have any idea how I can check if the player is currently talking to the gardener?

Let me try something, hold on.

  • Author

Let me try something, hold on.

 

No problem, take your time :) I just saw you're The Netherlands, I'm from Belgium, so we both speak Dutch :)

No problem, take your time smile.png I just saw you're The Netherlands, I'm from Belgium, so we both speak Dutch smile.png

		if(myPlayer().isInteracting(gardener)) {
			
		}

Kan je dat proberen, geen idee of het werkt heb het snel even gemaakt tongue.png

Edited by Rudie

  • Author
		if(myPlayer().isInteracting(gardener)) {
			
		}

Kan je dat proberen, geen idee of het werkt heb het snel even gemaakt tongue.png

 

 

Super bedankt :) But I'll keep writing in english so other people can still understand ;) So I did look a bit into the api and when talking to the gardener I'll need to use the "dialogues" class and use "clickContinue()" to talk to him, but how can I make the bot chose a specific option when he gets offered one? for example the gardener will ask how much he wants to pay for the Woad leaf, and you have 4 options: 5, 10, 15 and 20 gp, how do I make the bot to chose for the 20 gp option?

Super bedankt :) But I'll keep writing in english so other people can still understand ;) So I did look a bit into the api and when talking to the gardener I'll need to use the "dialogues" class and use "clickContinue()" to talk to him, but how can I make the bot chose a specific option when he gets offered one? for example the gardener will ask how much he wants to pay for the Woad leaf, and you have 4 options: 5, 10, 15 and 20 gp, how do I make the bot to chose for the 20 gp option?

Isn't there a method in the API to select a specific option? I can't make an example method right now cause I shut down my PC cause I'm going to bed in a few minutes.

Edited by Rudie

  • Author

Isn't there a method in the API to select a specific option? I can't make an example method right now cause I shut down my PC cause I'm going to bed in a few minutes.

I'm stille getting used to the API, so it's kinda hard to find ...

Also, you gold me the coin id, bit how could I find such things myself?

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.