HeyImJamie Posted July 29, 2017 Share Posted July 29, 2017 (edited) Written this up quickly. Banks at Varrock West and chops Trees to 15, Oaks to 60 and Yews 60+. Doesn't check for axes etc, I'll leave that for you to add. import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(name = "Free Woodcutter", version = 1.0, author = "HeyImJamie", info = "", logo = "") public class Main extends Script { @Override public int onLoop() throws InterruptedException { if (shouldBank()) { bank(); } else { cutTree(getTreeName()); } return 100; } private boolean shouldBank() { return getInventory().isFull(); } private void bank() throws InterruptedException { if (!Banks.VARROCK_WEST.contains(myPlayer())) { getWalking().webWalk(Banks.VARROCK_WEST); } else { if (!getBank().isOpen()) { getBank().open(); } else { getBank().depositAllExcept(axes -> axes.getName().contains(" axe")); } } } private void cutTree(String treeName) { if (!getTreeArea().contains(myPlayer())) { getWalking().webWalk(getTreeArea()); } else { RS2Object tree = getObjects().closest(treeName); if (!myPlayer().isAnimating() && tree != null) { if (tree.interact("Chop down")) { new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } } } } private Area getTreeArea() { if (getSkills().getDynamic(Skill.WOODCUTTING) >= 60) { return new Area(3203, 3506, 3225, 3497); } else { return new Area(3171, 3425, 3159, 3399); } } private String getTreeName() { if (getSkills().getDynamic(Skill.WOODCUTTING) >= 60){ return "Yew"; } else if (getSkills().getDynamic(Skill.WOODCUTTING) >= 15){ return "Oak"; } else { return "Tree"; } } } Edited August 3, 2017 by HeyImJamie 7 Quote Link to comment Share on other sites More sharing options...
Seriously Posted July 29, 2017 Share Posted July 29, 2017 Is this the JSlayer Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted July 29, 2017 Author Share Posted July 29, 2017 2 minutes ago, Seriously said: Is this the JSlayer This is better than JSlayer Quote Link to comment Share on other sites More sharing options...
ProjectPact Posted July 29, 2017 Share Posted July 29, 2017 Remember, people can't learn from something that isn't tested. If something is broken, it will probably just confuse them even more. Quote Link to comment Share on other sites More sharing options...
Tom Posted July 29, 2017 Share Posted July 29, 2017 Looks to me Explv has his hands around your neck 1 Quote Link to comment Share on other sites More sharing options...
Antonio Kala Posted July 29, 2017 Share Posted July 29, 2017 (edited) Now this is what I'm talking about. Added to the collection. Would like if you tested it first tho Edited July 29, 2017 by Antonio Kala Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted July 29, 2017 Author Share Posted July 29, 2017 2 minutes ago, Tom said: Looks to me Explv has his hands around your neck I wanted to grow his lil e-peen, I still fanboy Tasks 5 minutes ago, ProjectPact said: Remember, people can't learn from something that isn't tested. If something is broken, it will probably just confuse them even more. Was just strings I didn't check. I'll load OSbot now and confirm 1 Quote Link to comment Share on other sites More sharing options...
ProjectPact Posted July 29, 2017 Share Posted July 29, 2017 Great contribution though! Was just giving you some advice, not bashing Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted July 29, 2017 Author Share Posted July 29, 2017 1 minute ago, ProjectPact said: Great contribution though! Was just giving you some advice, not bashing You made a good point! As it happened I'd put in an incorrect string, so someone would've been confused! :P 7 minutes ago, Antonio Kala said: Now this is what I'm talking about. Added to the collection. Would like if you tested it first tho Tested, Works. 1 Quote Link to comment Share on other sites More sharing options...
The Undefeated Posted July 29, 2017 Share Posted July 29, 2017 Have been using this for months to goldfarm. Driving a gold renault clio right now. Thanks dude. 11/10 2 Quote Link to comment Share on other sites More sharing options...
godspower33 Posted July 29, 2017 Share Posted July 29, 2017 9 minutes ago, HeyImJamie said: You made a good point! As it happened I'd put in an incorrect string, so someone would've been confused! :P Tested, Works. Awesome work Jamie!! Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted July 29, 2017 Author Share Posted July 29, 2017 2 minutes ago, godspower33 said: Awesome work Jamie!! Quote Link to comment Share on other sites More sharing options...
Explv Posted July 29, 2017 Share Posted July 29, 2017 (edited) @HeyImJamie Looks nice, good job Just FYI you should be checking if wc levels are >=, rather than >. Right now your script will keep chopping normal trees until level 16, and oaks until level 61. Also you might want to consider using an enum for storing your Tree names & areas. Something like this: enum Tree { NORMAL("Tree", 1, new Area(1, 2, 3, 4)), OAK("Oak", 15, new Area(1, 2, 3, 4)), YEW("Yew", 60, new Area(1, 2, 3, 4)); String name; int levelRequired; Area area; Tree(final String name, final int levelRequired, final Area area) { this.name = name; this.levelRequired = levelRequired; this.area = area; } } You can also avoid having lots of nested if statements, by just inverting them: if (getTreeArea().contains(myPlayer())) { if .. if .. } else { getWalking().webWalk(...); } Becomes: if (!getTreeArea().contains(myPlayer())) { getWalking().webWalk(...); } else if { ... } ... Edited July 29, 2017 by Explv 4 Quote Link to comment Share on other sites More sharing options...
Eliot Posted July 29, 2017 Share Posted July 29, 2017 Looks good, pretty similar to progressiveWC. You have a lot of nested if statements that could be shortened (e.g. if (tree != null && tree.interact("Chop down")). Tree names and areas should be final constants declared once instead of returning a new area/string each time. Logic of the script has some quirks such as not switching to the next tree when the current tree is chopped down (by someone else) and waiting until the animation ends. Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted July 29, 2017 Author Share Posted July 29, 2017 7 minutes ago, Explv said: @HeyImJamie Looks nice, good job Just FYI you should be checking if wc levels are >=, rather than >. Right now your script will keep chopping normal trees until level 16, and oaks until level 61. Also you might want to consider using an enum for storing your Tree names & areas. Something like this: enum Tree { NORMAL("Tree", 1, new Area(1, 2, 3, 4)), OAK("Oak", 15, new Area(1, 2, 3, 4)), YEW("Yew", 60, new Area(1, 2, 3, 4)); String name; int levelRequired; Area area; Tree(final String name, final int levelRequired, final Area area) { this.name = name; this.levelRequired = levelRequired; this.area = area; } } You can also avoid having lots of nested if statements, by just inverting them: if (getTreeArea().contains(myPlayer())) { if .. if .. } else { getWalking().webWalk(...); } Becomes: if (!getTreeArea().contains(myPlayer())) { getWalking().webWalk(...); } else if { ... } ... Never thought about Enums before. Will definitely use in the future I'll update in regards to the >= and nested if's though Quote Link to comment Share on other sites More sharing options...