June 20, 20178 yr I need help with a script I'm trying to make. I'm having trouble collecting things from trees. The script collects for example apples from trees but after it has collected whole tree it just does nothing and doesnt continue collectig from other trees. Can anyone help me? EDIT: HOLY SHIT I'M BLIND AND STUPID! TREE ID CHANGES Edited June 21, 20178 yr by Abysm
June 20, 20178 yr Author Basically just clicking trees until its empty. The action changes from pick -> search if that helps. I've been experimenting with filter but I'm having hart time getting it to work. I'm on phone right now Edited June 20, 20178 yr by Abysm
June 20, 20178 yr Check your conditions, make sure you have if inventory isnt full & in apple area pick apples, else if it is full inv in apple area walk to bank, if its in the bank then bank.
June 20, 20178 yr As Zapako said, or check if the ID of the trees changes if it doesn't have any more to pick from.
June 20, 20178 yr Author I tried using filter but didnt really know how to use it literally making my "first script". and no, tree id stays same Edited June 20, 20178 yr by Abysm
June 20, 20178 yr Author Spoiler import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "BananaPicker", author = "Abysm", info = "Picks bananas in karamja", version = 0.1, logo = "") public final class BananaPicker extends Script { private final Area BananaArea = new Area(2914, 3161, 2926, 3154); private final Area DepositArea = new Area(3045, 3235, 3050, 3237); @Override public final int onLoop() throws InterruptedException { if (canPickBananas()) { Pick(); } else { deposit(); } return random(150, 200); } private void Pick() { RS2Object Bananatree1 = getObjects().closest("Banana tree"); if (!BananaArea.contains(myPosition())) { getWalking().webWalk(BananaArea); } else if (!getInventory().isFull()) { Bananatree1.interact("Pick"); } } private boolean canPickBananas() { return !getInventory().isFull(); } private void deposit() throws InterruptedException { if (!DepositArea.contains(myPosition())) { getWalking().webWalk(DepositArea); } else if (!getDepositBox().isOpen()) { getDepositBox().open(); } else if (!getInventory().isEmptyExcept("Coins")) { getDepositBox().depositAllExcept("Coins"); } else { stop(true); } } } So here is basically the whole code, it goes to the deposit box in port sarim if inventory is full and deposits all the bananas, walks back to banana trees, picks one tree out of bananas then it just freezes. Could somebody help a noob? Edited June 20, 20178 yr by Abysm
June 21, 20178 yr Because even when the banana tree runs out of bananas it's still called "Banana tree" in game, you need to check if the closest banana tree still has bananas to pick
June 21, 20178 yr Author 3 minutes ago, d0zza said: Because even when the banana tree runs out of bananas it's still called "Banana tree" in game, you need to check if the closest banana tree still has bananas to pick Thats the problem, I dont know how I've been trying to use all sorts of filters but I cant get it to work Edited June 21, 20178 yr by Abysm
June 21, 20178 yr 3 hours ago, Abysm said: Thats the problem, I dont know how I've been trying to use all sorts of filters but I cant get it to work Bro, use IDs. The ID changes when it has bananas and when it doesn't. The ID for the tree with bananas is 2073. The ID for the tree without bananas is 2078. So int fullTree = 2073; int emptyTree = 2078; if (fullTree) { if (fullTree.interact("Pick")) { conditionalSleep -> emptyTree, 5000); } } You might want to play around with the conditional sleep to fit you. Edited June 21, 20178 yr by Visty
June 21, 20178 yr So to edit your code, it should be something like this import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "BananaPicker", author = "Abysm", info = "Picks bananas in karamja", version = 0.1, logo = "") public final class BananaPicker extends Script { private final Area BananaArea = new Area(2914, 3161, 2926, 3154); private final Area DepositArea = new Area(3045, 3235, 3050, 3237); @Override public final int onLoop() throws InterruptedException { if (canPickBananas()) { Pick(); } else { deposit(); } return random(150, 200); } private void Pick() { RS2Object fullTree = getObjects().closest(2073); if (!BananaArea.contains(myPosition())) { getWalking().webWalk(BananaArea); } else if (!getInventory().isFull()) { if (fullTree.interact("Pick") { //Conditionalsleep } } private boolean canPickBananas() { return !getInventory().isFull(); } private void deposit() throws InterruptedException { if (!DepositArea.contains(myPosition())) { getWalking().webWalk(DepositArea); } else if (!getDepositBox().isOpen()) { getDepositBox().open(); } else if (!getInventory().isEmptyExcept("Coins")) { getDepositBox().depositAllExcept("Coins"); } else { stop(true); } } }
Create an account or sign in to comment