GeorgeNotFloyd Posted June 7, 2021 Share Posted June 7, 2021 Hello, i'm trying to get my script to bank and to go back basically but it doesn't work it goes to the bank and then chops logs until the tree is done and he stands there doing nothing import java.awt.*; import org.osbot.rs07.api.Bank; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.EquipmentSlot; 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 = "Woodcutting2", author = "Test", version = 1.0, info = "Woodcutting test", logo = "") public class Woodcutting extends Script { Area treearea = new Area(3154, 3421, 3173, 3374); Position treepath = new Position(3171, 3416, 0); Position oakpath = new Position(3171, 3416, 0); @Override public void onStart() { log("Woodcutting Script Begins"); //Code here will execute before the loop is started } @Override public int onLoop() throws InterruptedException { RS2Object tree = getObjects().closest("Tree"); RS2Object oaktree = getObjects().closest("Oak"); if (getInventory().contains("Bronze Axe")) { getEquipment().equip(EquipmentSlot.HANDS, "Bronze Axe"); } if (getSkills().getDynamic(Skill.WOODCUTTING) <= 14) { if (getInventory().isFull()) { sleep(random(700, 1200)); getInventory().dropAll(); } if (treearea.contains(myPlayer())) { if (tree != null && !myPlayer().isAnimating()) { if (tree.isVisible()) { tree.interact("Chop down"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating() || !tree.exists(); } }.sleep(); } else { getCamera().toEntity(tree); } } } else { getWalking().walk(treepath); } } if (getSkills().getDynamic(Skill.WOODCUTTING) >= 15) { if (treearea.contains(myPlayer())) { if (getInventory().isFull()) { log("RIGHT NOW IM FULL"); sleep(random(700, 1200)); // getInventory().dropAll(); if (!Banks.VARROCK_WEST.contains(myPlayer())) { log("WALKING NOW"); getWalking().webWalk(Banks.VARROCK_WEST); log("I'M AT THE BANK"); } else if (!getBank().isOpen()) { log("OPENING THE BANK"); getBank().open(); sleep(random(750, 1250)); getBank().depositAll(); sleep(random(750, 1300)); getBank().close(); } } if (getInventory().isEmpty()) { if (oaktree != null && !myPlayer().isAnimating()) { if (oaktree.isVisible()) { oaktree.interact("Chop down"); log("Choppy Choppy"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating() || !oaktree.exists(); } }.sleep(); } else { getCamera().toEntity(oaktree); } } } } else { getWalking().walk(oakpath); } } return random(350, 500); //The amount of time in milliseconds before the loop starts over } @Override public void onExit() { log("Woodcutting Script Stops"); //Code here will execute after the script ends } @Override public void onPaint(Graphics2D g) { //g.setColor(Color.WHITE); // g.drawString("EXP Gained (HR): " + getExperienceTracker().getGainedXP(Skill.WOODCUTTING) + " (" + getExperienceTracker().getGainedXPPerHour(Skill.WOODCUTTING) + ")", 20, 60); // g.drawString("Levels Gained: " + getExperienceTracker().getGainedLevels(Skill.WOODCUTTING), 20, 80); } } could you please tell me what i did wrong thank you ! (i just started yesterday) Quote Link to comment Share on other sites More sharing options...
ez11 Posted June 7, 2021 Share Posted June 7, 2021 You check if your inventory is empty to decide to cut trees. Just do !getInventory().isfull() if (getInventory().isEmpty()) { Also you should avoid doing stuff like this: if (!getBank().isOpen()) { log("OPENING THE BANK"); getBank().open(); sleep(random(750, 1250)); getBank().depositAll(); sleep(random(750, 1300)); getBank().close(); Just do something like this: if bank isnt open open bank if bank is open - if you dont have all items you want: - withdraw items you want - if you have all items you want: - close bank that way your script shouldnt get stuck incase a loop of the script fails 3 Quote Link to comment Share on other sites More sharing options...
GeorgeNotFloyd Posted June 8, 2021 Author Share Posted June 8, 2021 7 hours ago, ez11 said: You check if your inventory is empty to decide to cut trees. Just do !getInventory().isfull() if (getInventory().isEmpty()) { Also you should avoid doing stuff like this: if (!getBank().isOpen()) { log("OPENING THE BANK"); getBank().open(); sleep(random(750, 1250)); getBank().depositAll(); sleep(random(750, 1300)); getBank().close(); Just do something like this: if bank isnt open open bank if bank is open - if you dont have all items you want: - withdraw items you want - if you have all items you want: - close bank that way your script shouldnt get stuck incase a loop of the script fails Hello Sir first of all, thank you for replying and thank you for your advice, yes I didn't really see the !getInventory().isfull() and now it's good :) for the banking if I understand it's like this? if (!getBank().isOpen()){ getBank().open(); }else{ getBank().depositAll(); getBank().close(); } I haven't tested this yet, but just wanna know if it could work and if its a good way to do it if (!getBank().isOpen()){ getBank().open(); if (getBank().isOpen()){ getBank().depositAll(); if (getBank().contains("Bronze Axe")){ getBank().withdraw("Bronze Axe", 1); }else{ getBank().close(); } } } Thank you Quote Link to comment Share on other sites More sharing options...
ez11 Posted June 8, 2021 Share Posted June 8, 2021 3 hours ago, GeorgeNotFloyd said: Hello Sir first of all, thank you for replying and thank you for your advice, yes I didn't really see the !getInventory().isfull() and now it's good for the banking if I understand it's like this? if (!getBank().isOpen()){ getBank().open(); }else{ getBank().depositAll(); getBank().close(); } I haven't tested this yet, but just wanna know if it could work and if its a good way to do it if (!getBank().isOpen()){ getBank().open(); if (getBank().isOpen()){ getBank().depositAll(); if (getBank().contains("Bronze Axe")){ getBank().withdraw("Bronze Axe", 1); }else{ getBank().close(); } } } Thank you Dont put it all into the same if condition. Also there is no need to depositall if your inventory is empty. If the bank is not open you want to open the bank, else (meaning bank is open) and then inside the else you want to check if your inventory is full and you dont have a bronze axe. If thats the case you depositall. If thats not the case you want to check if back contains a bronze axe etc. check 15. for an example. This also shows conditional sleeps which you should use all the time. . Quote Link to comment Share on other sites More sharing options...