Abysm Posted June 20, 2017 Share Posted June 20, 2017 (edited) 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, 2017 by Abysm Quote Link to comment Share on other sites More sharing options...
Eliot Posted June 20, 2017 Share Posted June 20, 2017 Hard to help without a code snippet. Quote Link to comment Share on other sites More sharing options...
Abysm Posted June 20, 2017 Author Share Posted June 20, 2017 (edited) 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, 2017 by Abysm Quote Link to comment Share on other sites More sharing options...
LIVING Posted June 20, 2017 Share Posted June 20, 2017 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. 1 Quote Link to comment Share on other sites More sharing options...
Abysm Posted June 20, 2017 Author Share Posted June 20, 2017 so I should search tree in area instead of getobject.closest? Quote Link to comment Share on other sites More sharing options...
Juggles Posted June 20, 2017 Share Posted June 20, 2017 Post your code so we can see it and help Quote Link to comment Share on other sites More sharing options...
Abysm Posted June 20, 2017 Author Share Posted June 20, 2017 Sure I'll post it bit later Quote Link to comment Share on other sites More sharing options...
Zapako Posted June 20, 2017 Share Posted June 20, 2017 Use a filter which checks hasAction("Pick") with closest() Quote Link to comment Share on other sites More sharing options...
Viston Posted June 20, 2017 Share Posted June 20, 2017 As Zapako said, or check if the ID of the trees changes if it doesn't have any more to pick from. Quote Link to comment Share on other sites More sharing options...
Abysm Posted June 20, 2017 Author Share Posted June 20, 2017 (edited) 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, 2017 by Abysm Quote Link to comment Share on other sites More sharing options...
Abysm Posted June 20, 2017 Author Share Posted June 20, 2017 (edited) 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, 2017 by Abysm Quote Link to comment Share on other sites More sharing options...
d0zza Posted June 21, 2017 Share Posted June 21, 2017 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 Quote Link to comment Share on other sites More sharing options...
Abysm Posted June 21, 2017 Author Share Posted June 21, 2017 (edited) 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, 2017 by Abysm Quote Link to comment Share on other sites More sharing options...
Viston Posted June 21, 2017 Share Posted June 21, 2017 (edited) 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, 2017 by Visty Quote Link to comment Share on other sites More sharing options...
Viston Posted June 21, 2017 Share Posted June 21, 2017 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); } } } Quote Link to comment Share on other sites More sharing options...