Haydomon 1 Share Posted April 8, 2021 Lets say I have [1349, 1351, 1353, 1355, 1357, 1359, 1361, 6739] in my inventory. What's the best way to say that 6739 is the item it should equip? Link to comment Share on other sites More sharing options...
Haydomon 1 Author Share Posted April 9, 2021 Yeah but I don't think more info is necessary. It's just a programming question of how to prioritize a value in a list if its true. Link to comment Share on other sites More sharing options...
Pandemic 2703 Share Posted April 9, 2021 I'm also confused, how are you determining which item you want? Regardless, you'll need to sort your list by whatever metric you'd like to use, then grab the first item for the "best" Link to comment Share on other sites More sharing options...
Haydomon 1 Author Share Posted April 9, 2021 For future reference if someone has a similar question. The solution I have found is using the For-Each loop. For my case I had an integer list containing axe ID's that I organized from best to worst. I then used the For-Each loop to go through each item in the list and check if the bank contained it, then used break to leave the loop. If anyone would like to share a better solution it would be much appreciated, thanks! Integer[] axes = new Integer[] {6739, 1359, 1357, 1355, 1361, 1353, 1349, 1351}; if(Bank.openClosest()) { for(Integer i : axes){ MethodProvider.log(i); if(Bank.contains(i)){ Bank.withdraw(i); Bank.close(); break; } } } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.