bobilly89 Posted February 13, 2016 Share Posted February 13, 2016 My script has the player collect wood then he goes to the bank area to place it in the bank. He just stands in the bank area and never accomplishes anything. Help is appreciated . Im having trouble near the //bank section package Woodcutter;import java.awt.Graphics;import org.osbot.rs07.api.Inventory;import org.osbot.rs07.api.model.RS2Object;import org.osbot.rs07.script.Script;import org.osbot.rs07.script.ScriptManifest;import com.google.common.util.concurrent.Service.State;import org.osbot.rs07.api.model.Entity;import org.osbot.rs07.api.model.Player;import org.osbot.rs07.api.Bank;import org.osbot.rs07.api.Inventory;import org.osbot.rs07.api.map.Area;import org.osbot.rs07.script.MethodProvider;@ScriptManifest(author = "Me", info = "Chops willows", name = "woodcutter", version = 0.1, logo = "")public class Woodcutter extends Script{ final Area BANK_AREA = new Area(3168,3492,3161,3487); final Area TREE_AREA = new Area(3150,3464,3172,3450); final int BANK_BOOTH_ID = 5453; final String Tree_Name = "Tree"; public void onStart() { } public void onExit() { } //code in loop public int onLoop() { Inventory inven = getInventory(); Player player = getObjects().myPlayer(); Bank bank = getObjects().getBank(); if(!inven.isFull()) { //chop if(TREE_AREA.contains(player)) { RS2Object willow = getObjects().closest(Tree_Name); if(willow != null) { if (willow.isVisible()) { if (!player.isAnimating()) { if (!player.isMoving()) { willow.interact("Chop down"); } } } else { getCamera().toEntity(willow); } } }else{ getWalking().webWalk(TREE_AREA); } }else{ // bank if (BANK_AREA.contains(player)) { RS2Object bankbooth = getObjects().closest(BANK_BOOTH_ID, 5454, 5455, 5456); if (bank.isOpen()) { bank.depositAll(1511); bank.depositAll(); } else { if (bankbooth != null) { if (bankbooth.isVisible()) { bankbooth.interact("Bank"); }else{ getCamera().toEntity(bankbooth); } } } } else { getWalking().webWalk(BANK_AREA); } } return 50; }//end int onloop //paint public void onPaint(Graphics g) { }} Quote Link to comment Share on other sites More sharing options...
lisabe96 Posted February 13, 2016 Share Posted February 13, 2016 (edited) First of all, don't use ID's as it can change when RS is updated. This also accounts for items as I see you're using ID's everywhere. Second, the API has bank areas already so you don't need to define them yourself. Area bankArea = Banks.YOUR_BANK; Next do something similar to this (might want to use sleep): if (getWalking().webWalk(bankArea)) { if (!getBank().isOpen()) { RS2Object bankbooth = getObjects().closest("Bank booth); if (bankbooth != null && bankbooth.hasAction("Bank")) { bankbooth.interact("Bank"); } } } Btw, use code tags so we can read your code more easily Edited February 13, 2016 by lisabe96 Quote Link to comment Share on other sites More sharing options...
bobilly89 Posted February 13, 2016 Author Share Posted February 13, 2016 (edited) First of all, don't use ID's as it can change when RS is updated. This also accounts for items as I see you're using ID's everywhere. Second, the API has bank areas already so you don't need to define them yourself. Area bankArea = Banks.YOUR_BANK; Next do something similar to this (might want to use sleep): if (getWalking().webWalk(bankArea)) { if (!getBank().isOpen()) { RS2Object bankbooth = getObjects().closest("Bank booth); if (bankbooth != null && bankbooth.hasAction("Bank")) { bankbooth.interact("Bank"); } } } Btw, use code tags so we can read your code more easily Thank you. How do i use the sleep method? I was having trouble with it and ended up giving up on it. :| Edited February 13, 2016 by bobilly89 Quote Link to comment Share on other sites More sharing options...
Saiyan Posted February 13, 2016 Share Posted February 13, 2016 (edited) Thank you. How do i use the sleep method? I was having trouble with it and ended up giving up on it. :| conditional sleep i think so for the return of the conditonal sleep it'd be getBank().isOpen Edited February 13, 2016 by Saiyan Quote Link to comment Share on other sites More sharing options...
Molly Posted February 13, 2016 Share Posted February 13, 2016 (edited) First of all, don't use ID's as it can change when RS is updated. This also accounts for items as I see you're using ID's everywhere. Second, the API has bank areas already so you don't need to define them yourself. Area bankArea = Banks.YOUR_BANK; Next do something similar to this (might want to use sleep): if (getWalking().webWalk(bankArea)) { if (!getBank().isOpen()) { RS2Object bankbooth = getObjects().closest("Bank booth); if (bankbooth != null && bankbooth.hasAction("Bank")) { bankbooth.interact("Bank"); } } } Btw, use code tags so we can read your code more easily Depending where you are banking keep in mind there are some bank booths that are closed, I think there is also one in Draynor bank that is sitting inside the bank. opposite the bankers that can't be used and it's named "Bank booth". I'd recommend grabbing objects around you and filtering them based on name such as "Bank booth" and checking to ensure the object has an action, in this case that action being "Bank". This will prevent your script attempting to interact with a booth that you can't actually use. Thank you. How do i use the sleep method? I was having trouble with it and ended up giving up on it. :| Regular old sleep: sleep(random(150, 200)); Above code will sleep for a random time between 150 and 200 ms. Conditional sleep: new ConditionalSleep(Script.random(725, 925), 20) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); Above code will sleep for a random time between 725 and 925 ms. However, every 20 ms the boolean will be evaluated and if true the sleep will end. Edited February 13, 2016 by Molly Quote Link to comment Share on other sites More sharing options...
lisabe96 Posted February 13, 2016 Share Posted February 13, 2016 Depending where you are banking keep in mind there are some bank booths that are closed, I think there is also one in Draynor bank that is sitting inside the bank. opposite the bankers that can't be used and it's named "Bank booth". I'd recommend grabbing objects around you and filtering them based on name such as "Bank booth" and checking to ensure the object has an action, in this case that action being "Bank". This will prevent your script attempting to interact with a booth that you can't actually use. This, that's why I added action checking in my code. I ran into this problem at draynor where it wanted to bank with the "bank booth" that isn't a bank :p 1 Quote Link to comment Share on other sites More sharing options...
Molly Posted February 13, 2016 Share Posted February 13, 2016 (edited) This, that's why I added action checking in my code. I ran into this problem at draynor where it wanted to bank with the "bank booth" that isn't a bank Yeah, I found that out as well long ago when I wrote my thieving script. Trying to bank at Draynor and was wondering why it wasn't banking lol. I only pointed it out because the snippet you posted doesn't filter, it just checks that the object has the action prior to interacting. Theoretically if you walk into the bank and grab a booth getObjects.closest("Bank booth") you could end up continuously grabbing the same booth and thus would never interact with it if it didn't have the option. Resulting in the script just endlessly looping. Edited February 13, 2016 by Molly Quote Link to comment Share on other sites More sharing options...
lisabe96 Posted February 13, 2016 Share Posted February 13, 2016 (edited) Yeah, I found that out as well long ago when I wrote my thieving script. Trying to bank at Draynor and was wondering why it wasn't banking lol. I only pointed it out because the snippet you posted doesn't filter, it just checks that the object has the action prior to interacting. Theoretically if you walk into the bank and grab a booth getObjects.closest("Bank booth") you could end up continuously grabbing the same booth and thus would never interact with it if it didn't have the option. Resulting in the script just endlessly looping. True when I post what I use I get lambda-lovers on my back RS2Object booth = null; for (RS2Object obj : getObjects().getAll()) { if (bankArea.contains(obj) && obj.getName().equalsIgnoreCase("Bank booth")) { if (obj.hasAction("Bank")) { if (booth == null || getMap().distance(booth) > getMap().distance(obj)) { booth = obj; } } } } if (booth == null) { log("Error, no bank booth found to use."); //Return } booth.interact("Bank"); Edited February 13, 2016 by lisabe96 Quote Link to comment Share on other sites More sharing options...