darkvenus 1 Share Posted October 29, 2020 I'm kinda stuck because when I learn something new i'm more like a copy-paste learner (I know only some java basic so that's why). help xd Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted October 29, 2020 The principle is pretty much identical to that of writing scripts for DB2, the only real 'difference' is the conversion to a static API, so classes are accessed differently. For example: Put simply, Instead of using getPlayers()...method, you would use Players...method. Link to comment Share on other sites More sharing options...
una_maquina 35 Share Posted November 13, 2020 First thing you should learn is how to use the dreambot's javadocs and understand it. 1) Download a chrome extension called Javadoc Search Frame. This will help you navigate through the javadocs and find stuff easier. 2) Understand what are constructors and methods. 3) For example you wanna get your character's combat level. You'd use the constructor "Player". And use a method called getLevel(). The code would look like this: log(Player.getLevel()); 4) Also what's really helpful is learning how to code in a node system kind of way, instead of writing linear, abstract scripts (they get pretty confusing real fast). It's better to have many classes and keep them as short as possible. You can find some help on node systems here: Hope this helps you a bit. When I started, the biggest aha moment was learning what are constructors and methods. That started my scripting career. Link to comment Share on other sites More sharing options...
darkvenus 1 Author Share Posted November 13, 2020 50 minutes ago, una_maquina said: First thing you should learn is how to use the dreambot's javadocs and understand it. 1) Download a chrome extension called Javadoc Search Frame. This will help you navigate through the javadocs and find stuff easier. 2) Understand what are constructors and methods. 3) For example you wanna get your character's combat level. You'd use the constructor "Player". And use a method called getLevel(). The code would look like this: log(Player.getLevel()); 4) Also what's really helpful is learning how to code in a node system kind of way, instead of writing linear, abstract scripts (they get pretty confusing real fast). It's better to have many classes and keep them as short as possible. You can find some help on node systems here: Hope this helps you a bit. When I started, the biggest aha moment was learning what are constructors and methods. That started my scripting career. Thanks bro that extension is really helpful, This is currently my goal, to learn how to script. I've read a lot throughout the forum and i've seen that node tutorial. I'll check him out asap, I managed to build some Woodcutting script. i'm trying to understand now how to do some actions to what I want to script. (thought of anti-pattern system, prioritize system and such) i like to start in the middle of the puzzle 😜 more interesting and fun. Link to comment Share on other sites More sharing options...
una_maquina 35 Share Posted November 13, 2020 6 minutes ago, darkvenus said: Thanks bro that extension is really helpful, This is currently my goal, to learn how to script. I've read a lot throughout the forum and i've seen that node tutorial. I'll check him out asap, I managed to build some Woodcutting script. i'm trying to understand now how to do some actions to what I want to script. (thought of anti-pattern system, prioritize system and such) i like to start in the middle of the puzzle 😜 more interesting and fun. For antiban compatibility, you'll most likely need to learn how the node system works. I just implemented it into my own code; you'll most likely not understand this, but I'll leave an explanation how I did it. In the main class where I go through the nodes, I've made an if statement, which checks if "run_anti_ban" static variable isn't true. If it's true, the main class won't run the nodes, and that will basically stop the main code. I have the antiban class as a thread, so whenever it finishes sleeping for a random amount, it'll change "run_anti_ban" variable into true and will run its own code in the meantime. After it finishes running antiban code, it'll change back the "run_anti_ban" variable into false again and go to sleep; and essentially let the main code run again. I also have all my variables stored into a different class called variables to keep it neat. Anyhow, good luck! Link to comment Share on other sites More sharing options...
darkvenus 1 Author Share Posted November 13, 2020 6 minutes ago, una_maquina said: For antiban compatibility, you'll most likely need to learn how the node system works. I just implemented it into my own code; you'll most likely not understand this, but I'll leave an explanation how I did it. In the main class where I go through the nodes, I've made an if statement, which checks if "run_anti_ban" static variable isn't true. If it's true, the main class won't run the nodes, and that will basically stop the main code. I have the antiban class as a thread, so whenever it finishes sleeping for a random amount, it'll change "run_anti_ban" variable into true and will run its own code in the meantime. After it finishes running antiban code, it'll change back the "run_anti_ban" variable into false again and go to sleep; and essentially let the main code run again. I also have all my variables stored into a different class called variables to keep it neat. Anyhow, good luck! Thanks much, I understand half of it theoretically. but i'll return to this comment in a couple of days when i'll have more knowledge about how nodes work and more😜 Link to comment Share on other sites More sharing options...
Hashtag 8670 Share Posted November 13, 2020 3 hours ago, una_maquina said: 3) For example you wanna get your character's combat level. You'd use the constructor "Player". And use a method called getLevel(). The code would look like this: log(Player.getLevel()); No, you don't use the constructor of Player. If you used constructor, you'd be writing new Player(someReference).getLevel(), which you don't want to or can't do. When you write Player.getLevel() you call a static method getLevel inside the Player class (HOWEVER, getLevel is not a static method, so that doesn't work! To get your character's level, you'd use Players.getLocalPlayer().getLevel()). Nothing constructor related there. Here's an example of constructor usage. Say I want to walk to a certain location. I browse the javadocs to find that there's a walk method in Walking class The method walk takes a Tile as a parameter. Then I click the link to Tile's javadocs page and notice it has three constructors I can then use the walk method to walk to a certain tile by using one of the following Walking.walk(new Tile()), I didn't pass any coordinates to Tile's constructor, so it defaults them to 0 (not something you'd use) Walking.walk(new Tile(3284, 4310)), I used the second constructor that takes the tile's x and y coordinates Walking.walk(new Tile(3284, 4310, 1)), I used the third constructor that also has the z coordinate as a parameter Link to comment Share on other sites More sharing options...
una_maquina 35 Share Posted November 13, 2020 1 minute ago, Hashtag said: No, you don't use the constructor of Player. If you used constructor, you'd be writing new Player(someReference).getLevel(), which you don't want to or can't do. When you write Player.getLevel() you call a static method getLevel inside the Player class. Nothing constructor related there. Here's an example of constructor usage. Say I want to walk to a certain location. I browse the javadocs to find that there's a walk method in Walking class The method walk takes a Tile as a parameter. Then I click the link to Tile's javadocs page and notice it has three constructors I can then use the walk method to walk to a certain tile by using one of the following Walking.walk(new Tile()), I didn't pass any coordinates to Tile's constructor, so it defaults them to 0 (not something you'd use) Walking.walk(new Tile(3284, 4310)), I used the second constructor that takes the tile's x and y coordinates Walking.walk(new Tile(3284, 4310, 1)), I used the third constructor that also has the z coordinate as a paremeter I see, I've used constructor and class interchangeably, because I thought they're one and the same. Then I guess we're taking methods from classes and using constructors in the methods themselves. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.