Jump to content

bot state skeleton script


Joseph

Recommended Posts

	import org.osbot.script.Script;
import org.osbot.script.ScriptManifest;
	
	
	@ScriptManifest(name = "", author = "", version = 1D, info="")
	public class test extends Script {
		
		enum State {
			FIRST, SECOND, THIRD;
		}
	
		private State state;
			
		public void onStart(){
		if(client.getInventory().isFull()){
				state = State.FIRST;
		}
		}
		
		public int onLoop() throws InterruptedException{
			switch (state){
			case FIRST:
				return first();
			case SECOND:
				return second();
			case THIRD:
				return third();
			}
		return random(10, 20);
		}
	
		int first() throws InterruptedException {
			return 0;
		}
	
		int second() throws InterruptedException{
			// TODO Auto-generated method stub
			return 0;
		}
	
		int third() throws InterruptedException{
			// TODO Auto-generated method stub
			return 0;
		}
	
	}

----------> "state = State.FIRST;" <-------------------

 

using this will help you switch between your botstates

 

Edited by josedpay
Link to comment
Share on other sites

  • 4 weeks later...

Thanks for us learners when people comment scripts like this // blah blah . Makes a ton easier to read and work out

 i dont even know if your joking around or serious.

 

Code:

import org.osbot.script.Script;
import org.osbot.script.ScriptManifest;
import org.osbot.script.rs2.utility.Area;
		
@ScriptManifest(name = "", author = "", version = 1D, info="")
public class hi extends Script {

//your variable 
//bankArea
//tree area
//tree ints
//anything else you need
 
enum State {
CutTree, WalkToBank, Bank;
}
	
private State state;
public static Area bankArea = new Area(0, 0, 0, 0);//add your area with in here
public static Area treeArea = new Area(0, 0, 0, 0);// add your area here

			
public void onStart(){
 if (client.getInventory().isFull()){
state = State.WalkToBank;
 }
else if (myPlayer().isInArea(treeArea)){
state = State.CutTree;
}
 } 
		
public int onLoop() throws InterruptedException{
                        switch (state){
			case CutTree:
				return first();
			case WalkToBank:
				return second();
			case Bank:
				return third();
			}
		return random(10, 20);
		}
	
int first() throws InterruptedException {

if (myPlayer().isInArea(treeArea)) {
//Cut trees 
//and any other code you want to put here
}		
return 500;
}		

int second() throws InterruptedException{
if (client.getInventory().isFull()){	
if (!myPlayer().isInArea(bankArea)){
walk(bankArea);
}
else if (myPlayer().isInArea(bankArea)){
//interact with bank and so on
}
else if (client.getBank().isOpen()){
state = State.Bank;
}
}
return 200 + random(100,500);	
}			

int third() throws InterruptedException{
if (client.getBank().isOpen() && client.getInventory().isFull()){
//deposit all or what ever
}
else if (client.getBank().isOpen() && !client.getInventory().isFull()){
// close bank and do what ever you want.
}
else if (!client.getBank().isOpen() && client.getInventory().isFull()){
state = State.WalkToBank;
}
return 100;	
}
}
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...