dQw4w9WgXcQ 184 Share Posted February 23, 2017 helped me thx Hashtag 1 Link to comment Share on other sites More sharing options...
death dead 1 Share Posted February 26, 2017 (edited) Paint All about making the brilliant paint. (I wrote this section at 2am, please bear with me) First of all, add this method in your script. All the example code below should be written inside this method. Getting coordinates Setting color Setting font Drawing text Drawing rectangles /spoiler] Drawing an image Drawing an in game tile The final product and full source GUI Nearly all scripts have some kind of a GUI. GUI is the window that appears when you start a script. You input all kinds of info, such as which enemy to attack and should your bot use prayer or not. Now we will take a look at creating a GUI ourselves. We will not be using any kind of a form maker program. Creating a GUI can be sometimes very tedious, especially when you write it completely yourself without the use of a form maker. I personally use WindowBuilder, a plugin for Eclipse. It saves me a lot of time when making a GUI. Starting off The createGUI method Adding different components The final product and full source AbstractScript versus TaskScript Let's take a peek at the differences between AbstractScript and TaskScript. I have written a basic powerchopper script in both frameworks and the sources are visible in the spoilers below. Both of the scripts work the same way. Chops trees until inventory is full and then drops them. AbstractScript source TaskScript source Okay, okay, I've seen enough code. Now what are the differences? As I said the scripts work exactly the same way. However, some scripters, like me, prefer to use the TaskScript framework. Why is that? Well... mostly because your code is spread in to different classes which makes it easier for you to modify your code. You also get the opportunity to set priorities to your nodes and understanding which piece of code is ran is easier. Of course this example script is very basic and short which makes the use of TaskScript an overkill. It is better to use AbstractScript on small scripts using either if-framework or state-framework. Feel free to request new tutorials. If you have any questions, do not hesitate to ask! Can I ask how u made the priority thingy? Paint All about making the brilliant paint. (I wrote this section at 2am, please bear with me) First of all, add this method in your script. All the example code below should be written inside this method. Getting coordinates Setting color Setting font Drawing text Drawing rectangles Drawing an image Drawing an in game tile The final product and full source GUI Nearly all scripts have some kind of a GUI. GUI is the window that appears when you start a script. You input all kinds of info, such as which enemy to attack and should your bot use prayer or not. Now we will take a look at creating a GUI ourselves. We will not be using any kind of a form maker program. Creating a GUI can be sometimes very tedious, especially when you write it completely yourself without the use of a form maker. I personally use WindowBuilder, a plugin for Eclipse. It saves me a lot of time when making a GUI. Starting off The createGUI method Adding different components The final product and full source AbstractScript versus TaskScript Let's take a peek at the differences between AbstractScript and TaskScript. I have written a basic powerchopper script in both frameworks and the sources are visible in the spoilers below. Both of the scripts work the same way. Chops trees until inventory is full and then drops them. AbstractScript source TaskScript source Okay, okay, I've seen enough code. Now what are the differences? As I said the scripts work exactly the same way. However, some scripters, like me, prefer to use the TaskScript framework. Why is that? Well... mostly because your code is spread in to different classes which makes it easier for you to modify your code. You also get the opportunity to set priorities to your nodes and understanding which piece of code is ran is easier. Of course this example script is very basic and short which makes the use of TaskScript an overkill. It is better to use AbstractScript on small scripts using either if-framework or state-framework. Feel free to request new tutorials. If you have any questions, do not hesitate to ask! Edited February 26, 2017 by death dead Link to comment Share on other sites More sharing options...
RawrRawr 1 Share Posted February 28, 2017 So in eclipse do I just do in src - package - then 3 classes or however many for different actions etc.? Link to comment Share on other sites More sharing options...
Kvothe 6 Share Posted February 28, 2017 (edited) holy shit this is beautiful! many thanks! GUI section definitely helped me! i think one of the taskSource pics isnt working. request: for more tasked based tuts! Edited February 28, 2017 by Kvothe Link to comment Share on other sites More sharing options...
Hashtag 8688 Author Share Posted March 4, 2017 So in eclipse do I just do in src - package - then 3 classes or however many for different actions etc.? Yes, you create new class files for your nodes in the src folder/package. holy shit this is beautiful! many thanks! GUI section definitely helped me! i think one of the taskSource pics isnt working. request: for more tasked based tuts! I am glad you made use of my tutorials =). All images seem to be working for me, are they still broken? What about tasks you wish to learn more? Can I ask how u made the priority thingy? Every TaskNode class has the int returning method priority(). By overriding this method and returning a value you want determines the priority of that specific node. The higher the value is, the more important the node is. death dead 1 Link to comment Share on other sites More sharing options...
Nito 0 Share Posted April 5, 2017 (edited) This is a great tutorial thanks. I'm making a priority queue to sort the nodes to most important priority for my script instead of an array. Have you done anything like that? More task based tutorials would be great. Also, Why is OnLoop{} removed from TaskScript? I'm not sure what would be the best way to update my node queue without a loop on my main script. I planned to manage the queue by removing nodes when the task is completed and adding/executing nodes when the accept() method passes. Edited April 5, 2017 by Nito Link to comment Share on other sites More sharing options...
Hashtag 8688 Author Share Posted April 6, 2017 This is a great tutorial thanks. I'm making a priority queue to sort the nodes to most important priority for my script instead of an array. Have you done anything like that? More task based tutorials would be great. Also, Why is OnLoop{} removed from TaskScript? I'm not sure what would be the best way to update my node queue without a loop on my main script. I planned to manage the queue by removing nodes when the task is completed and adding/executing nodes when the accept() method passes. What do you mean by queueing your nodes? You don't have to sort them yourself as the taskscript does it for you. You just have to set the priority by overriding the method. Link to comment Share on other sites More sharing options...
Nito 0 Share Posted April 6, 2017 What do you mean by queueing your nodes? You don't have to sort them yourself as the taskscript does it for you. You just have to set the priority by overriding the method. Ah I didn't know. It's very hard to tell what it does without actually seeing the source of the classes. Taskscript seems very well suited for multitasking states with priority a lot easier than abstractscript such as combat script that would need to drink potions, use prayer, loot, etc. I really would like to see more documentation on task scripting because there is very few snippets or open source script examples available to study from. Link to comment Share on other sites More sharing options...
Lemonade 1 Share Posted April 29, 2017 (edited) Hey Hashtag, nice tutorial first of all! It's really helpful especially with the TaskScript. Just a small question about the code: Wouldn't it be more simpler to just wait till the player is idle after you interact with the tree? if (tree.interact("Chop Down")) { sleepUntil(() -> !getLocalPlayer().isAnimating, 2000); } So this will only click on the tree again if our status is idle. Edited April 29, 2017 by Lemonade Link to comment Share on other sites More sharing options...
Hashtag 8688 Author Share Posted April 29, 2017 Hey Hashtag, nice tutorial first of all! It's really helpful especially with the TaskScript. Just a small question about the code: Wouldn't it be more simpler to just wait till the player is idle after you interact with the tree? if (tree.interact("Chop Down")) { sleepUntil(() -> !getLocalPlayer().isAnimating, 2000); } So this will only click on the tree again if our status is idle. Hey, thanks for the feedback. The code you posted wouldn't be good since when player is standing still/moving, isAnimating() returns false. This means the bot would click the tree and sleep until you are not animating (neither standing still or moving) and notice you are walking to the tree, which means it wouldn't sleep at all. This results in spam clicking the tree. If you happen to stand next to the tree and somehow manage to animate before your script checks for animation, it would work. What my code does is clicks the tree, sleeps until we are moving and then sleeps more until we are animating (chopping). If a lag spike happens to occur, it would sleep for max 7 seconds in total, which is quite a long time. Therefore it rarely spam clicks. I can imagine it clicks the tree twice if the distance to the tree is long and you get a lag spike. To avoid that, increase the timeouts for the sleeps =). I hope I managed to answer your question. 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