Before 97 Posted May 20, 2016 That title though. I'm planning on making a little bit bigger of a script, that will use some of my other scripts inside. I could merge it all into once source code, but isn't there a way to have a script use multiple classes? Like there is a way, I know that but.. oh well you get what I'm saying. Also, I've had some help with people and they recommend when I'm using the "interact" method I put an if-statement around it, because it will return false if it missclicks; how does that help me make the bot more reliable with the interact method? (Right now sometimes for whatever reason, it clicks the entity on the minimap instead of clicking it on the screen)
Chapter 55 Posted May 20, 2016 I'm no java expert, but I'm pretty sure you use setters and getters or w/e. From what I can remember when I was scripting years back for a different bot, I was told you use setters and getters and you can use it across multiple classes. http://www.dreamincode.net/forums/topic/86439-getters-and-setters-and-using-multiple-classes/ That title though. I'm planning on making a little bit bigger of a script, that will use some of my other scripts inside. I could merge it all into once source code, but isn't there a way to have a script use multiple classes? Like there is a way, I know that but.. oh well you get what I'm saying. Also, I've had some help with people and they recommend when I'm using the "interact" method I put an if-statement around it, because it will return false if it missclicks; how does that help me make the bot more reliable with the interact method? (Right now sometimes for whatever reason, it clicks the entity on the minimap instead of clicking it on the screen) #pleasedon'tkillmeifIgotthiswrong.
Diddy 265 Posted May 20, 2016 put this in your Main class private ClasName classname; public void onStart() { classname = new ClasName(this); } Then to make a new class public class ClasName { AbstractScript s; public ClasName (AbstractScript ctx) { this.s = ctx; } }
Dreamlicker 750 Posted May 20, 2016 public class chop { private AbstractScript ctx; private GameObject tree; public chop(AbstractScript ctx) { this.ctx = ctx; } public boolean choppingIsFun() { tree = ctx.getGameObjects().closest(f -> f != null && f.getName().contains("tree")); if (tree != null && tree.interact("Chop down")) { ctx.sleep(randNum(300, 400)); ctx.sleepUntil(() -> !tree.exists(), randNum(12000, 8000)); return true; } else { return false; } } } public class Scripto extends AbstractScript { private chop chopper; @Override public void onStart() { chopper = new chop(this); } @Override public int onLoop() { if (chopper.choppingIsFun()) { log("ok we did some choppin"); } } } Hope that helps ;o edit: Edited to display what Hope is referring to
Hopewelljnj 46 Posted May 20, 2016 The reason you use an if around interact is you don't want to test if you are doing something in a conditional sleep at f you never actually did it.
Cardozz 46 Posted May 20, 2016 public class chop { private AbstractScript ctx; private GameObject tree; public chop(AbstractScript ctx) { this.ctx = ctx; } public boolean choppingIsFun() { tree = ctx.getGameObjects().closest(f -> f != null && f.getName().contains("tree")); if (tree != null && tree.interact("Chop down")) { ctx.sleep(randNum(300, 400)); ctx.sleepUntil(() -> !tree.exists(), randNum(12000, 8000)); return true; } else { return false; } } } public class Scripto extends AbstractScript { private chop chopper; @Override public void onStart() { chopper = new chop(this); } @Override public int onLoop() { if (chopper.choppingIsFun()) { log("ok we did some choppin"); } } } Hope that helps ;o edit: Edited to display what Hope is referring to I used classA = new ClassA(); Where classA is in my main package, outside the main class. This will work too right?
Mad 86 Posted May 20, 2016 Are you trying to have multiple scripts in the same project? Or just split your script up into nodes?
Constuck 13 Posted May 20, 2016 Putting an if around an x.interact("y") doesn't prevent misclicks, rather it tells you whether your first click was successful or not. The interact method returns a boolean depending on whether your client successfully completed the interaction. If you put x.interact("y") inside an if statement, you would be able to act differently depending on whether the interaction succeeded or failed. As hope mentioned earlier, it's convenient inside a sleepUntil condition.
Before 97 Author Posted May 20, 2016 The reason you use an if around interact is you don't want to test if you are doing something in a conditional sleep at f you never actually did it. Oh.. Hmm. Yeah as I said one of my scripts had been acting weird (for some accounts only too, checked all the settings and shit). Dunno. (code) Hope that helps ;o edit: Edited to display what Hope is referring to So do I just have two Classes inside the same source file (like a superfunction) or are these separate in my package? put this in your Main class private ClasName classname; public void onStart() { classname = new ClasName(this); } Then to make a new class public class ClasName { AbstractScript s; public ClasName (AbstractScript ctx) { this.s = ctx; } } Okayy, I think I get this. I'll use it as reference Are you trying to have multiple scripts in the same project? Or just split your script up into nodes? Multiple scripts in the same project; like I already have a fishing script and a cooking one, so if I combine them into one script, can I just copy the class files or do I have to copy and paste the source as a function Putting an if around an x.interact("y") doesn't prevent misclicks, rather it tells you whether your first click was successful or not. The interact method returns a boolean depending on whether your client successfully completed the interaction. If you put x.interact("y") inside an if statement, you would be able to act differently depending on whether the interaction succeeded or failed. As hope mentioned earlier, it's convenient inside a sleepUntil condition. Ohh, that will help for a few things. Awesoem!
Mad 86 Posted May 20, 2016 A script is just a class file w/ the manifest at the top, that is ALL the bot looks for. So you can have as many classes as you want w/ those manifest at the top, and those would be separate scripts inside the bot client. Now of course with these classes, you can create instances of other classes inside of them, like shown above, the client doesn't look for those, it only needs the main class with the manifest to run the script.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.