Joseph Posted July 4, 2013 Share Posted July 4, 2013 (edited) 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 July 4, 2013 by josedpay Link to comment Share on other sites More sharing options...
Traveling Posted July 9, 2013 Share Posted July 9, 2013 Thanks, always useful! Link to comment Share on other sites More sharing options...
MoneyMan Posted July 9, 2013 Share Posted July 9, 2013 Thanks alot! Link to comment Share on other sites More sharing options...
03storic Posted July 9, 2013 Share Posted July 9, 2013 This is helpful to understand how states work. Link to comment Share on other sites More sharing options...
abibot Posted July 10, 2013 Share Posted July 10, 2013 EXACTLY what I was looking for, thanks mate. Link to comment Share on other sites More sharing options...
Jordan Posted July 10, 2013 Share Posted July 10, 2013 Used this for my rarefinder. Link to comment Share on other sites More sharing options...
A lazy Cat Posted August 1, 2013 Share Posted August 1, 2013 what gos here enum State { FIRST, SECOND, THIRD; } Link to comment Share on other sites More sharing options...
Joseph Posted August 1, 2013 Author Share Posted August 1, 2013 What you put in the enum are the cases, which are states. Link to comment Share on other sites More sharing options...
A lazy Cat Posted August 1, 2013 Share Posted August 1, 2013 could u give a example? Link to comment Share on other sites More sharing options...
Joseph Posted August 1, 2013 Author Share Posted August 1, 2013 (edited) could u give a example? Sure. edit: remove the oce i had here. Tooo many errors. edit 2: add new code with out error. at the post below Edited August 1, 2013 by josedpay Link to comment Share on other sites More sharing options...
ibotujelly123 Posted August 1, 2013 Share Posted August 1, 2013 ty Link to comment Share on other sites More sharing options...
Joseph Posted August 1, 2013 Author Share Posted August 1, 2013 Fixed Link to comment Share on other sites More sharing options...
A lazy Cat Posted August 1, 2013 Share Posted August 1, 2013 Thanks for us learners when people comment scripts like this // blah blah . Makes a ton easier to read and work out Link to comment Share on other sites More sharing options...
Joseph Posted August 1, 2013 Author Share Posted August 1, 2013 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 More sharing options...
A lazy Cat Posted August 1, 2013 Share Posted August 1, 2013 No I'm serious helps break up blocks of texts ! 1 Link to comment Share on other sites More sharing options...