Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • How do I get best item in a list?


    Haydomon
     Share

    Recommended Posts

    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

    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

    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

    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

    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 account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.