Naked Posted March 25, 2019 Share Posted March 25, 2019 1 hour ago, t0r3 said: Ok, so u mean one method for oaks, one for tree's and so on? chopOaks(); chopTrees(); Yeah that would be better down the line, adding willows and yews thanks! Chop(String tree) or Chop(){ getTree(); goCut(); } Quote Link to comment Share on other sites More sharing options...
zwaffel Posted March 25, 2019 Share Posted March 25, 2019 2 hours ago, t0r3 said: Ok, so u mean one method for oaks, one for tree's and so on? chopOaks(); chopTrees(); Yeah that would be better down the line, adding willows and yews thanks! You could make a method Chop that takes 2 parameters a Location and a String for the tree name. Than you could reuse the function by just passing in the name of the tree and the location where it needs to be chopped. You could do this for your bank method as well, make a method getRightAxe() which returns a string (the name of your axe) than pass it in by parameter (bank method) or in the withdrawItem method itself. This logic can be reused for allot of things it will make your code cleaner and save you some time typing. Also every time you loop you set your int wcLvl again you could just get it once at onStart than every time you get a level (You see the widget or you read it from chat) you could update it to save some cpu time. Quote Link to comment Share on other sites More sharing options...
Elixar Posted March 25, 2019 Share Posted March 25, 2019 9 hours ago, t0r3 said: Hey How do I use the itemcontainer class to make a list of the axes? Might be not having enough knowledge of java haha, though I am learning from codeacademy.. Click the link and read some of those, also would help your journy if you look into osbot filters(Search Forum) and Java Lambdas (Search Yotube) getItem(Filter<Item>... filter) Gets the first item found after filtering the container with the specified filter 1 Quote Link to comment Share on other sites More sharing options...
t0r3 Posted March 26, 2019 Author Share Posted March 26, 2019 (edited) @Chris Is something like this example better logic-wise? Also cut out the "Walking" void from before and trying out conditional sleep public class Sleep extends Script { private Area treeArea = new Area(3190, 3250, 3171, 3263); private void chopTree() { RS2Object tree = getObjects().closest("tree"); if (!treeArea.contains(myPosition())) { getWalking().webWalk(treeArea); } else if (tree != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){ tree.interact("Chop down"); new ConditionalSleep(70000) { @Override public boolean condition() { return !myPlayer().isAnimating() && !myPlayer().isMoving(); } }.sleep(); } } private void needToBank() { if (!Banks.LUMBRIDGE_UPPER.contains(myPosition())){ getWalking().webWalk(Banks.LUMBRIDGE_UPPER); } else { RS2Object bankBooth = getObjects().closest("Bank booth"); bankBooth.interact("Bank"); new ConditionalSleep(70000) { @Override public boolean condition() { return getBank().isOpen(); } }.sleep(); getBank().depositAllExcept("Bronze axe"); } } @Override public int onLoop () throws InterruptedException { if (getInventory().isFull()) { needToBank(); } else { chopTree(); } return 1000; } } Edited March 26, 2019 by t0r3 1 Quote Link to comment Share on other sites More sharing options...
Chris Posted March 26, 2019 Share Posted March 26, 2019 3 hours ago, t0r3 said: @Chris Is something like this example better logic-wise? Also cut out the "Walking" void from before and trying out conditional sleep public class Sleep extends Script { private Area treeArea = new Area(3190, 3250, 3171, 3263); private void chopTree() { RS2Object tree = getObjects().closest("tree"); if (!treeArea.contains(myPosition())) { getWalking().webWalk(treeArea); } else if (tree != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){ tree.interact("Chop down"); new ConditionalSleep(70000) { @Override public boolean condition() { return !myPlayer().isAnimating() && !myPlayer().isMoving(); } }.sleep(); } } private void needToBank() { if (!Banks.LUMBRIDGE_UPPER.contains(myPosition())){ getWalking().webWalk(Banks.LUMBRIDGE_UPPER); } else { RS2Object bankBooth = getObjects().closest("Bank booth"); bankBooth.interact("Bank"); new ConditionalSleep(70000) { @Override public boolean condition() { return getBank().isOpen(); } }.sleep(); getBank().depositAllExcept("Bronze axe"); } } @Override public int onLoop () throws InterruptedException { if (getInventory().isFull()) { needToBank(); } else { chopTree(); } return 1000; } } a lot better 1 Quote Link to comment Share on other sites More sharing options...
Imthabawse Posted March 26, 2019 Share Posted March 26, 2019 @t0r3 Maybe add }else if (treeArea.doesContainMyPosition to your else if. Probably not necessary to get chopping but can't hurt. Looks clean though. Quote Link to comment Share on other sites More sharing options...
t0r3 Posted March 27, 2019 Author Share Posted March 27, 2019 (edited) 13 hours ago, Imthabawse said: @t0r3 Maybe add }else if (treeArea.doesContainMyPosition to your else if. Probably not necessary to get chopping but can't hurt. Looks clean though. Thanks! Yeah I could do that, but probs not necessary though. Could also do getBank().open() instead of these two; as Chris said (did it) Less demanding of the cpu or something, I guess. RS2Object bankBooth = getObjects().closest("Bank booth"); bankBooth.interact("Bank"); Edited March 27, 2019 by t0r3 1 Quote Link to comment Share on other sites More sharing options...
Imthabawse Posted March 27, 2019 Share Posted March 27, 2019 @t0r3 Yeah no need to create object for bank the API has built in Bank.functions Quote Link to comment Share on other sites More sharing options...
t0r3 Posted March 28, 2019 Author Share Posted March 28, 2019 (edited) Ok, progressing a bit Making it easier with boolean variables, lambda expressions, and a String for the axes Also used the alternative sleep from explvl's 101 tutorial, although I don't understand how he made it, but how to use it What do you think? Is this ok? What to do next? (Including important parts) EDIIIIT; Need to test my scripts more haha, getAxes(); would'nt work ofc.. removed it Edited March 31, 2019 by t0r3 Quote Link to comment Share on other sites More sharing options...
Imthabawse Posted March 31, 2019 Share Posted March 31, 2019 @t0r3 Haven't tryed using booleans like you've implemented but seen it used in @Explv's tutorial on scripting and I like how much cleaner it looks will have to try it out in one of my scripts. As for the script, to me it looks really clean and well organized so good job there. Curious as to how it's functioning. Keep on scripting brotha you're progressing pretty fast. Quote Link to comment Share on other sites More sharing options...
t0r3 Posted March 31, 2019 Author Share Posted March 31, 2019 (edited) 12 hours ago, Imthabawse said: @t0r3 Haven't tryed using booleans like you've implemented but seen it used in @Explv's tutorial on scripting and I like how much cleaner it looks will have to try it out in one of my scripts. As for the script, to me it looks really clean and well organized so good job there. Curious as to how it's functioning. Keep on scripting brotha you're progressing pretty fast. Thanks! Should've tested the script beforehand haha, getAxes(); didn't work ofcourse... Need to test my scripts more before posting haha.. and yeah those booleans makes it cleaner Edited March 31, 2019 by t0r3 Quote Link to comment Share on other sites More sharing options...