Vinny143 0 Posted June 8, 2023 (edited) Hey, New to this so sorry if im posting in wrong spot. Been working on a script and for some reason Bank.contains(int id) doesn't work for me. I've tried it with multiple different items, which are 100% in my bank but it returns false for them. I also tried Bank.count(int id) for those items and got 0. I have no idea what I'm doing wrong. I've attached screenshots of an example with air runes, which have the id 556. OK well I tried to attach screenshots but they fail to upload which is an issue of itself lmao, so you're just gonna have to take my word that it doesn't work. Edited June 9, 2023 by Vinny143
Vinny143 0 Author Posted June 9, 2023 (edited) Yeah sure, but it's nothing complitcated, I'm literally just running tests with Logger.log. I tried testing with the string name as well, but that also doesn't work. public class FoodCooker extends AbstractScript { static final Item cookingItem= Inventory.getItemInSlot(0); static final Node[] nodes = {new BankerNode(cookingItem),new CookerNode(cookingItem)}; @Override public void onStart() { log("Start up tests:"); log(Bank.contains(cookingItem.getName())); log(Bank.contains(cookingItem.getID())); log(Bank.contains("Raw lobster")); log(Bank.contains("Lobster")); log(Bank.contains("Bread")); log("Start up tests end -----------------"); log("Welcome to VDog's Simple Food Cooker!"); } .... } Formatting got messed up from pasting, cbs fixing it. I have all those items in my Bank, but I get false for every single one of them. Edited June 9, 2023 by Vinny143
Diggington 20 Posted June 9, 2023 I think Bank.contains() requires you to have opened the Bank prior to calling the method. I have my own custom implementation of the method so don't really use it but maybe try opening your bank first and then checking?
Vinny143 0 Author Posted June 9, 2023 Didn't work. The steps I did were: - Login - Manually open bank - Close bank - Run script Still gave me false for every test.
Tweeboy 20 Posted June 9, 2023 (edited) 5 hours ago, Vinny143 said: Didn't work. The steps I did were: - Login - Manually open bank - Close bank - Run script Still gave me false for every test. To my knowledge, the script itself will need to access the bank to know what's inside. You manually opening and closing bank before running the script = the script does not know what's in the bank and will just return false. To verify this you can move that snippet from your onStart() to the onLoop(). Once you've started the script enable user input and open & close your bank. Your test should now return true. What are you trying to achieve with this code? It may be easier to check if the Bank contains those items within your bank node instead of the onStart method. So your bank node could have something like: if (Bank.open()){ if (Bank.contains(cookingItem)){ Bank.withdrawAll(cookingItem.getName()); } else { log("No more raw fish, ending script"); return -1; } } Edited June 9, 2023 by roflme
mcleod63 2 Posted June 9, 2023 Don't close bank, before running script. It must be open. If you close the bank, you have to use Bank.getBankHistoryCache()
Diggington 20 Posted June 10, 2023 19 hours ago, roflme said: To my knowledge, the script itself will need to access the bank to know what's inside. You manually opening and closing bank before running the script = the script does not know what's in the bank and will just return false. This is how I think the implementation works. You need the script to access the bank so it loads your bank contents into memory. Manually accessing the bank won't achieve this. Try the code posted by roflme. Put it in onLoop instead of onStart
Vinny143 0 Author Posted June 15, 2023 Ohhh ok, I understand how it works now, thanks for all the help guys.
wicker558 5 Posted June 16, 2023 It works, but you have to use these calls to contains() when you run your code to withdraw/deposit. That's what I do at least, and it works everytime. if (Bank.open()) { if (Bank.contains("Coins") { Bank.withdrawAll("Coins"); } else { // some code to withdraw and sell stuff on GE } }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now