• Welcome to ForumKorner!
    Join today and become a part of the community.

How to set up for RSBot scripting [IDE and new API] && basic scripting!

x04a

Onyx user!
Reputation
0
Hello, and welcome to my first tutorial on scripting RSBot. There are a few things you need to know.

First things first, we need RSBot. I use the new API, 1.9. You all most likely have 1.24. To get 1.9, simply make a new rsbot folder, and do an SVN checkout with the link: http://rsbot-client.googlecode.com/svn/trunk



To use RSBot, you don't have to use an IDE, but it is extremely recommended. Download this.
http://www.eclipse.org/downloads/do...R/eclipse-java-helios-win32.zip&mirror_id=483

Set that up. Once it is set up, press file>new>java project.

Set up any name, and unclick default location. Browse to your new RSBot folder and use that.

Now, you will see a little sidepane in Eclipse. Itll say package explorer at the top. It will have whatever you named your RSBot folder at the top of it. For example, mine is named rs1.9.
Click the little arrow to the left of your folder, and right click on your scripts folder.

From there, do new>class
Name the class what you want your script to be named, and press okay.


You are now ready to create your script!​

There are a few things you need to know about java first. When you are using Java, you must import the packages you are going to use. Thankfully, Eclipse helps us do that. I will post a sample code and comment it out to help you. Simply paste this into eclipse, and read.

Code:
import java.util.Map;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.wrappers.RSTile;
//Above are your imports. There are many different imports for Java and RSBot. Eclipse will help you import these. Don't worry about it
//Too much.
@ScriptManifest(authors =  "x04a" , category = "Firemaking", name = "x04aBurner", version = 0.5, description = "My first simple firemaker")

//Above is your "ScriptManifest. This outputs the info into RSBot that you see when you are picking a script.

//Before we get to the code, first things first. Java IS Case-Sensitive. You must also have a ; after most lines to close the line.
// All { need a }
public class x04aBurner extends Script { //This starts the script. When you start up eclipse, and make a new class, it will NOT
	// have the extends Script. You must put that in yourself.
	
	public int[] LogType = {1511, 1517, 1519, 1515, 1521};
	public int[] Tinderbox = {590};
	public int[] BankBooth = {1};
	public int[] RegularLog = {1511};
	RSTile[] ToArea;
	RSTile[] ToBooth;
	
	//Above I have declared my Integers. For example, public means that it can be read by other files in its folder. int means integer.
	// LogType is the name of the integer that I have given to it. The following numbers are the variables that LogType stand for.
	
	public boolean onStart(Map<String, String> args) {   //A boolean is a set of strings that can return true or false.
		// In this example, I have declared new "RSTiles". These are paths you want your character to walk. This is also the 
		//Start boolean, so anything in this boolean will activate when the script is started.
		ToArea = new RSTile[] {new RSTile(3199, 3429) };
		ToBooth = new RSTile[] {new RSTile(3181, 3429), new RSTile(3189, 3435) };
		return true;
	
}
	
	public void ToArea ()  { // A void is simply something that cannot return true or false. If it cannot return true or false, use a void.
		walking.walkPathMM(ToArea); //This command states that you will be walking, and you will be walking on the Minimap(MM)
		//It then states the path to walk, seen in the above boolean "ToArea".
		burn();//This tells that after doing the path, go to public void or boolean "burn()"
		
	}
	
	public void ToBooth () { // This is the void for walking to the bank.
		walking.walkPathMM(ToBooth); //Read description in public void ToArea()
		
	}
	

	public boolean burn() {
		if (getMyPlayer().getAnimation() == -1) { //This is part of an "if" statement. If your players animation is negative, therefore
			//there is NO animation, do the following. It is incomplete, and will tell the bot to click on the tinderbox then the logs.
			
		}
		return true;
		}

	public boolean bank() { //This is the banking command. It's very simple.
		bank.open(); //Opens bank
		sleep(random(700, 800));//Waits for .7 to .8 seconds
		bank.depositAllExcept(Tinderbox); // Deposits all except for integer Tinderbox
		sleep(random(700, 800)); // Waits for .7 to .8 seconds
		bank.close(); //Closes the bank
		
		return true;
	}
	
public int loop() {  //This is the loop. Possibly the most important part of your script. This has to be VERY logical.
	if(inventory.isFull()) { //If your inventory is full, go to public void ToArea()
		ToArea(); //public void ToArea()
	} else if(!inventory.isFull()) { //Else, if your inventory is NOT full, go to public void ToBooth(). you may be wondering,
		//How is this saying it's not full? See the ! point? That makes anything the opposite. So == is equal, != is does not equal. Etc.
		ToBooth(); //public void ToBooth()
	}
	return 0;
	}
}


If you have any questions, ask me!
 
Top