XenoTools Posted April 16, 2013 Share Posted April 16, 2013 (edited) Someone asked me, so here //Imports herepublic class ScriptName extends Script { private static enum BotState = { STATE_1, STATE_2, STATE_3, STATE_4, STATE_5 }; private BotState state; public int onLoop() { state = setState(); // Method to figure out which state the bot is in return handleState(state); } /*************************************************************** * Method BotState setState() * returns ENUM - BotState * Use this method to calculate the state * Such as, if the players inventory is full * return BotState.BANKING ****************************************************************/ private BotState setState() { // Stuff here return BotState.STATE_5; } /*************************************************************** * Integer handleState * returns integer * Use this method to function * according to which state the script is in/ * Example: if STATE_1, RETURN 1000; (If the bot is in state_1, wait for a second. If not, look for another * state. ****************************************************************/ private int handleState(BotState state) { switch(state) { case STATE_1: //code return 1000; // Wait time before next onLoop() case STATE_2: //code return 710; // wait time before next onLoop() } }} Edited April 16, 2013 by XenoTools 1 Link to comment Share on other sites More sharing options...
Wizard Posted April 16, 2013 Share Posted April 16, 2013 Good job, could be more details or examples. My AIO scripts use something like this but a bit different this can make the code more efficient and cleaner. Link to comment Share on other sites More sharing options...
XenoTools Posted April 16, 2013 Author Share Posted April 16, 2013 (edited) Good job, could be more details or examples. My AIO scripts use something like this but a bit different this can make the code more efficient and cleaner. Really isn't much to show, if you get it you get it, if you don't you don't. It's very basic scripting and anybody who understands a hello world program using a switch would understand this. /: EDITED with slight comment adjustments Edited April 16, 2013 by XenoTools 1 Link to comment Share on other sites More sharing options...
Wizard Posted April 16, 2013 Share Posted April 16, 2013 Really isn't much to show, if you get it you get it, if you don't you don't. It's very basic scripting and anybody who understands a hello world program using a switch would understand this. /: EDITED with slight comment adjustments Well not everyone knows how to use Enums, just saying anyway good job now it looks better ) Link to comment Share on other sites More sharing options...
XenoTools Posted April 17, 2013 Author Share Posted April 17, 2013 Well not everyone knows how to use Enums, just saying anyway good job now it looks better ) For future clarification the way we are using the Enum is no different than a way you would use a String, int, long, double, var, or def. Link to comment Share on other sites More sharing options...