jython Posted September 16, 2016 Share Posted September 16, 2016 This was a really nice tutorial! Thanks! You did a really great job on your wording and flow through the different components. I already had a basic idea of how to get this going and this tutorial did a fantastic job cementing the ideas around splitting your states into their own classes. Thanks so much for the time you spent on this. As a side note, this really should be Pinned.. 1 Quote Link to comment Share on other sites More sharing options...
Abyssal Service Posted September 16, 2016 Share Posted September 16, 2016 thanks! Quote Link to comment Share on other sites More sharing options...
slazter Posted June 25, 2017 Share Posted June 25, 2017 Hmm trying to read up on this... How far in Java learning should i be to start using, task based scripts? Intermediate? This is kinda the same thing as a Node system right? Quote Link to comment Share on other sites More sharing options...
byoun Posted October 10, 2017 Share Posted October 10, 2017 So if I require the character to withdraw multiple items from the bank, is a task list a good route to get it done? Quote Link to comment Share on other sites More sharing options...
KyleDBusey Posted June 2, 2019 Share Posted June 2, 2019 This was a great tutorial. As a new script writer, I really appreciate a well put-together tutorial like this. Thanks again. Quote Link to comment Share on other sites More sharing options...
beaver_fever Posted March 6, 2020 Share Posted March 6, 2020 (edited) Nice one. Looks so much cleaner than having a cluttered onLoop Edited March 6, 2020 by beaver_fever Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted March 21, 2020 Share Posted March 21, 2020 Is there a way to have the script stop processing the task list once it matches on of the canProcess() criteria? Currently it keeps trying to process other tasks or at least matching them, but if there are two that qualify it runs them. For example I have a "Debug" task that I want to use if the script falls through and doesn't match any other canProcess() criteria. But the logs show "I am lost" on every single loop, even it it processes one of the other classes. Is there something that can be added to to "do" part of the class that will make it break out of the current loop and start from the top of the task list? The java keyword "continue" seems to be what I am looking for but no matter where I put it, Eclipse doesn't like it. Here is my debug class: import org.osbot.rs07.script.MethodProvider; public class Debug extends Task { public Debug(MethodProvider api) { super(api); } @Override public boolean canProcess() { return !api.myPlayer().isMoving(); } @Override public void process() { api.log("I am lost"); } } Quote Link to comment Share on other sites More sharing options...
Camaro Posted March 21, 2020 Share Posted March 21, 2020 1 hour ago, sudoinit6 said: Is there a way to have the script stop processing the task list once it matches on of the canProcess() criteria? Currently it keeps trying to process other tasks or at least matching them, but if there are two that qualify it runs them. For example I have a "Debug" task that I want to use if the script falls through and doesn't match any other canProcess() criteria. But the logs show "I am lost" on every single loop, even it it processes one of the other classes. Is there something that can be added to to "do" part of the class that will make it break out of the current loop and start from the top of the task list? The java keyword "continue" seems to be what I am looking for but no matter where I put it, Eclipse doesn't like it. Here is my debug class: import org.osbot.rs07.script.MethodProvider; public class Debug extends Task { public Debug(MethodProvider api) { super(api); } @Override public boolean canProcess() { return !api.myPlayer().isMoving(); } @Override public void process() { api.log("I am lost"); } } use a standard 'for' loop instead of a 'List.forEach' method in main. And you probably want break, not continue. Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted March 21, 2020 Share Posted March 21, 2020 16 minutes ago, camaro 09 said: use a standard 'for' loop instead of a 'List.forEach' method in main. And you probably want break, not continue. Thank you for your response. My Main class is the same as the one in the first post and I don't see a List.forEach method to change to a for loop. import java.util.ArrayList; import org.osbot.rs07.script.Script; public class Main extends Script{ //this is our array list which will contain our tasks ArrayList<Task> tasks = new ArrayList<Task>(); @Override public int onLoop() throws InterruptedException { return 700; } } Quote Link to comment Share on other sites More sharing options...
Camaro Posted March 21, 2020 Share Posted March 21, 2020 1 hour ago, sudoinit6 said: Thank you for your response. My Main class is the same as the one in the first post and I don't see a List.forEach method to change to a for loop. import java.util.ArrayList; import org.osbot.rs07.script.Script; public class Main extends Script{ //this is our array list which will contain our tasks ArrayList<Task> tasks = new ArrayList<Task>(); @Override public int onLoop() throws InterruptedException { return 700; } } Read until the end of the first post 1 Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted March 21, 2020 Share Posted March 21, 2020 21 minutes ago, camaro 09 said: Read until the end of the first post DHO! Thank you again for your time. I will fiddle with that and see if I can make it work. Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted March 21, 2020 Share Posted March 21, 2020 15 hours ago, camaro 09 said: Read until the end of the first post OK, I am a little closer, I changed the loop to this: for (i = 0; i < tasks.size(); i++){ x = tasks.get(i); x.run(); } Which works great, now I am having trouble with the "break;". No matter where I put it in the tasks classes I get syntax error or break cannot be used outside of a loop or a switch. Any hints? Quote Link to comment Share on other sites More sharing options...
Camaro Posted March 21, 2020 Share Posted March 21, 2020 1 hour ago, sudoinit6 said: OK, I am a little closer, I changed the loop to this: for (i = 0; i < tasks.size(); i++){ x = tasks.get(i); x.run(); } Which works great, now I am having trouble with the "break;". No matter where I put it in the tasks classes I get syntax error or break cannot be used outside of a loop or a switch. Any hints? public boolean run() { if (canProcess()) { process(); return true; } return false } for (i = 0; i < tasks.size(); i++){ x = tasks.get(i); if (x.run()) { break; } } This will allow you to break the loop and reset whenever a task runs Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted March 21, 2020 Share Posted March 21, 2020 24 minutes ago, camaro 09 said: public boolean run() { if (canProcess()) { process(); return true; } return false } for (i = 0; i < tasks.size(); i++){ x = tasks.get(i); if (x.run()) { break; } } This will allow you to break the loop and reset whenever a task runs I came up with something that works but yours is cleaner and I will convert to it. Here is what I did: I declared a static variable "br" in my Task class and added br = 1; to the end of each class. Then I changed my loop to this: int i; Task x; for (i = 0; i < tasks.size(); i++){ Task.br = 0; x = tasks.get(i); x.run(); if (Task.br == 1) { break; } } Like I said, yours is better, I just wanted to express that I am trying to learn and not just be spoonfed and I really appreciate your time and help. 1 Quote Link to comment Share on other sites More sharing options...
Promo Posted April 12, 2020 Share Posted April 12, 2020 Sorry I am a total noob coder. We have this code to add the task in this example: @Override public void onStart() { tasks.add(new Attack(this)); How do I add another task , for example Banking? Can I put all name of task in an array list and pass that array list as argument to tasks.add( List here)(this)) ? Quote Link to comment Share on other sites More sharing options...