shaba123 Posted May 25, 2018 Share Posted May 25, 2018 Im trying to store my inventory on start up and everytime i go to the bank i want to check if my inventory is the same as onstart, if not, withdraw items from bank to match. This is what i have so far : public void onStart() { Item[]initial = getInventory().getItems(); log(initial); } This must be an incorrect way to grab items as this is what comes up in the log : [INFO][Bot #1][05/25 10:06:18 AM]: [Lorg.osbot.rs07.api.model.Item;@122d063 Do i need to display the results differently? And this is what im doing to check for any changes in the inventory: if (getBank().isOpen()) { for (int i = 0; i < inventory.getItems().length; i++) { Item current = inventory.getItems()[i]; Item in = initial[i]; if (in.getAmount() != current.getAmount()) { log("Invent is different"); // code to withdraw initial from bank return; } } } I believe im just grabbing the initial inventory items wrong onstart which makes the code to check for inventory changes obsolete. Please correct my errors and tell me where im going wrong, thank you. Quote Link to comment Share on other sites More sharing options...
Alek Posted May 25, 2018 Share Posted May 25, 2018 You're trying to print an array... 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted May 25, 2018 Share Posted May 25, 2018 (edited) ... You're printing the array, so what comes up is expected. If you want to print the array's contents you will need to loop over it and print each Item, or use Arrays.toString(): log(Arrays.toString(initial)); Questions like this can be easily answered using Google, all you need to search for is "How to print an array in Java". Edited May 25, 2018 by Explv 2 Quote Link to comment Share on other sites More sharing options...
shaba123 Posted May 25, 2018 Author Share Posted May 25, 2018 Thank you for your help 53 minutes ago, Explv said: ... You're printing the array, so what comes up is expected. If you want to print the array's contents you will need to loop over it and print each Item, or use Arrays.toString(): log(Arrays.toString(initial)); Questions like this can be easily answered using Google, all you need to search for is "How to print an array in Java". Quote Link to comment Share on other sites More sharing options...
shaba123 Posted May 25, 2018 Author Share Posted May 25, 2018 (edited) 1 hour ago, Alek said: You're trying to print an array... How do i use my arrayList, im trying to check that my inventory has not chnaged since i started the script,would it be like so : edit: i know what i have done is not correct i just dont know how to use the array of items if (getBank().isOpen()) { for (int i = 0; i < inventory.getItems().length; i++) { Item current = inventory.getItems()[i]; Item in = Arrays.toString(initial)[i]; if (in.getAmount() != current.getAmount()) { log("Invent is different"); // code to withdraw initial from bank return; } } } 1 hour ago, Explv said: ... You're printing the array, so what comes up is expected. If you want to print the array's contents you will need to loop over it and print each Item, or use Arrays.toString(): log(Arrays.toString(initial)); Questions like this can be easily answered using Google, all you need to search for is "How to print an array in Java". Edited May 25, 2018 by shaba123 Quote Link to comment Share on other sites More sharing options...
shaba123 Posted May 25, 2018 Author Share Posted May 25, 2018 (edited) Do i have to save the array list to a string like this : String[] items = new String[] (initial); then it would be : if (getBank().isOpen()) { for (int i = 0; i < inventory.getItems().length; i++) { Item current = inventory.getItems()[i]; Item in = item[i]; if (in.getAmount() != current.getAmount()) { log("Invent is not the same"); return; } Im watching some video tutorials on java now i have lots of learning to do. EDIT: could a mod merge my last 3 posts please im making a mess of the forums! EDIT: i managed to solve it , thanks for everyones help. Edited May 25, 2018 by shaba123 Quote Link to comment Share on other sites More sharing options...