Doxial 0 Share Posted May 3 I've made a couple AbstractScripts and I understand how they work and their flow, such as needing onStart(), onLoop(), etc... however there seems to be much less informative content about TaskScript so I'm struggling trying to learn what all is needed in it and it's "flow". I've read Hashtags 'Scripting 101 Guide' however that just details the differences in them, and not the how they work in detail, still a great guide nonetheless. I was wondering if anyone had any links to tutorials over them I may of somehow missed? Or if someone can give the cliff notes of what is needed in a TaskScript? Link to comment Share on other sites More sharing options...
Luxe 78 Share Posted May 3 I personally skipped taskscript and went straight to treescript. Regardless i would suggest you look at open source repos on github. just search "dreambot" with java as language and sort by newest Link to comment Share on other sites More sharing options...
Tweeboy 19 Share Posted May 4 TaskScript uses TaskNodes to perform your script's function. Instead of managing your script's logic within the main onLoop(), you will create several TaskNodes to break up the script into different tasks TaskNodes have three methods associated with them: boolean accept() - this is the condition that must be met in order to trigger the TaskNode. int execute() - think of your AbstractScript's onLoop(). This executes the actions/logic we actually want to perform. int priority() - allows you to prioritize your TaskNodes. By default, TaskScript will iterate through your TaskNodes in the order you add them. The script will iterate through each task (either in priority order high to low, or in order that they've been added). If the accept() condition is found to be valid, the script will loop through that TaskNode's execute(). I will use a basic woodcutting script as an example. In the onStart() of our main class, we will need to add our nodes: @Override public void onStart() { addNodes(new BankTask(), new DropTask(), new ChopTask()); } First the script would iterate through our BankTask. So long as the conditions of accept() are found to be true, we will loop through BankTask.execute(). Once we've deposited our logs, this TaskNode will no longer be true (inventory is NOT full) and the script will move onto the next TaskNode: public class BankTask extends TaskNode { @Override public boolean accept() { return Inventory.isFull() && !isDrop; //isDrop is an internal boolean determined by the user within the GUI } @Override public int execute() { //Logic for Banking & depositing logs return 1000; } } Then the script would iterate through your DropTask, depending on the state of boolean isDrop: public class DropTask extends TaskNode { @Override public boolean accept() { return Inventory.isFull() && isDrop; //isDrop is an internal boolean determined by the user within the GUI } @Override public int execute() { //Logic for Dropping inventory of logs return 1000; } } If neither of our above TaskNodes return a valid accept() condition, the script would move onto the ChopTask(). In this example, I left the accept() as true since I know the script will only get to this node, if DropTask & BankTask are NOT valid. You're welcome to add a condition to be met (for example, verifying treeArea.contains(Players.getLocal()) ) public class ChopTask extends TaskNode { @Override public boolean accept() { return true; } @Override public int execute() { //Logic for Walking to the tree location & chopping desired tree return 1000; } } Once you've flushed out the execute() logic in each, and add your nodes in the Main class onStart(), TaskScript will handle the rest. It will loop through BankTask>DropTask>ChopTask, checking to see which one returns accept() first, and then run the appropriate execute() If you so choose, you could break out the script logic into even more tasks (Bank, Drop, Travel, Chop, Idle). Some people may find this excessive. Do whatever you find easiest. I personally like breaking down my script into smaller tasks and will opt to use either TaskScript or TreeScript. Similar to the previous poster, I learned using TreeScript at first (specifically this implementation), but I do find it overkill for simple scripts and have been using TaskScript far more often now. In TaskScript, your script logic is executed within each TaskNode. The script will check Task accept() > Task execute() if valid In TreeScript, your script logic is executed within each Leaf, which are stored in Branches. The script will check the Branch accept() > check the Leaf accept() if valid > Leaf execute() if valid. Doxial and morten1ela 2 Link to comment Share on other sites More sharing options...
c0d33rr0r 3 Share Posted June 5 https://dreambot.org/guides/scripter-guide/how-to/making-a-basic-woodcutting-script/#how-we-will-handle-certain-conditions-in-our-script Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now