investmentideas Posted March 23, 2019 Share Posted March 23, 2019 I was wondering if anyone had a barebones methods template? Kind of similar to the one I have created below? I am looking at implementing methods now instead of placing everything in a single loop. import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "", logo = "", version = 1.0, author ="", info ="") public class test extends Script { @Override public void onStart() throws InterruptedException { super.onStart(); } @Override public int onLoop() throws InterruptedException { return 0; } @Override public void onExit() throws InterruptedException { super.onExit(); } } Quote Link to comment Share on other sites More sharing options...
dazeldo Posted March 23, 2019 Share Posted March 23, 2019 Take a look at this: 1 Quote Link to comment Share on other sites More sharing options...
Imthabawse Posted March 23, 2019 Share Posted March 23, 2019 How I go about it is like this: import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "Example", logo = "", version = 1, author = "Your name here", info = "Example script") public class Example extends Script { private void exampleMethod() { // Put your method in here and call in the onLoop with conditions } @Override public int onLoop() throws InterruptedException { // if(Im where I need to be) { <--- Condition to run method // exampleMethod(); <--- Method is executed if condition met return 0; } } Not saying this is the "proper" OR best way to go about it but works for me. Have only used this for the simplest of tasks though. For more complex scripts I'm sure there's far better ways to structure it. Hope this helps. Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted March 23, 2019 Share Posted March 23, 2019 I personally use a mix between a Task and a State 'framework' For example, I'll have a Bank Task which contains code for banking. And in that class will be a switch statement that chances based on certain conditions, for example: switch (getTaskState()) { case WALK_TO_BANK: // walk to bank etc break; case OPEN_BANK: // open bank break; // etc } private enum TaskState { WALK_TO_BANK, OPEN_BANK, BANK_ETC } private TaskState getTaskState() { if (!Bank.contains(Player)) { return TaskState.WALK_TO_BANK; // etc } Quote Link to comment Share on other sites More sharing options...