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
  • A few noob problems


    regurak
     Share

    Recommended Posts

    I recently began my attempt at an edge looting bot. It's been smooth sailing except for three hookups.

     

    1. How can I check how many of a stack able item I have?
    2. How can I choose to loot from a list of multiple acceptable items? (any method that works)
    3. How can I turn on run/ eat from inventory?

    I've gotten the damn thing to do everything but these. Thanks a wholeee lot in advance. I've hardly done much code so the api is a new format for me.

     Edit: How can I use a filter to do #2 and the last part of #3? Currently it won't pick up anything with this filter. ->

     

    Here's the code:

    case WILD:
            GroundItem loots = (getGroundItems().closest(new Filter<GroundItem>(){
                public boolean match(GroundItem gi){
                    if(gi == null || gi.getName() == null)
                        return false;
                    if(!gi.getName().equals("Swordfish"))
                        return false;
                    if(!gi.getName().equals("Adamant arrow"))
                        return false;
                    if(WILD_AREA.contains(gi))
                        return true;
                    return false;
                    
                }
            }));
            if(loots != null) {
                if(loots.interact("Take")){
                    sleepUntil(new Condition(){
                        public boolean verify(){
                            return !loots.exists();
                        }
                    },Calculations.random(900,1200));
                }
                    
            }
    
    Edited by regurak
    Link to comment
    Share on other sites

    To get the number of a stackable item in your inventory you could do something like this.

    getInventory().count("Item name");
    

    You could use a filter to check for multiple items by doing something like this

    getGroundItems.closest((item) -> item != null && (item.getName().contains("NameOne") || item.getName().contains("NameTwo")));
    

    Assuming you know the name of the food that you want to eat, you could do something like this to find and eat the item.

    getInventory().interact((item) -> item != null && !item.isNoted() && item.getName().contains("Food Name"), "Eat");
    
    Link to comment
    Share on other sites

    to see how many of a stackable item you have you can do getInventory().count(String name OR int itemID); this returns the number of items with that name/itemid you have in you're inventory at that time

    Edited by TheMcPker
    Link to comment
    Share on other sites

     

    I recently began my attempt at an edge looting bot. It's been smooth sailing except for three hookups.

     

    1. How can I check how many of a stack able item I have?
    2. How can I choose to loot from a list of multiple acceptable items? (any method that works)
    3. How can I turn on run/ eat from inventory?

    I've gotten the damn thing to do everything but these. Thanks a wholeee lot in advance. I've hardly done much code so the api is a new format for me.

     Edit: How can I use a filter to do #2 and the last part of #3? Currently it won't pick up anything with this filter. ->

     

    Here's the code:

    case WILD:
            GroundItem loots = (getGroundItems().closest(new Filter<GroundItem>(){
                public boolean match(GroundItem gi){
                    if(gi == null || gi.getName() == null)
                        return false;
                    if(!gi.getName().equals("Swordfish"))
                        return false;
                    if(!gi.getName().equals("Adamant arrow"))
                        return false;
                    if(WILD_AREA.contains(gi))
                        return true;
                    return false;
                    
                }
            }));
            if(loots != null) {
                if(loots.interact("Take")){
                    sleepUntil(new Condition(){
                        public boolean verify(){
                            return !loots.exists();
                        }
                    },Calculations.random(900,1200));
                }
                    
            }
    

    How does it work properly ? If you find an addy arrow it will check if its a swordfish it will see that it is not and it will return false and not bother checking everything else .

    It should be something like this

    if(WILD_AREA.contains(gi) && (gi.getName().equals("Swordfish") ||(gi.getName().equals("Adamant arrow")) )
    Edited by ozeki6
    Link to comment
    Share on other sites

     

    How does it work properly ? If you find an addy arrow it will check if its a swordfish it will see that it is not and it will return false and not bother checking everything else .

    It should be something like this

    if(WILD_AREA.contains(gi) && (gi.getName().equals("Swordfish") ||(gi.getName().equals("Adamant arrow")) )

    Quite right I'm an idiot, however I attempted to fix up the code a bit and this is what I came up with. It only gets arrows now however. Uhg. The last ID, 890 is the arrows..

     

     

    if(!getInventory().isFull() && !getLocalPlayer().isHealthBarVisible()){
            (getGroundItems().closest((item) -> item != null && item.getID() == 1478 || item.getID() == 374
            || item.getID() == 120 || item.getID() == 118 || item.getID() == 116
            || item.getID() == 114 || item.getID() == 1726 || item.getID() == 890)).interact("Take");
            }
    
    Edited by regurak
    Link to comment
    Share on other sites

     

     

    How does it work properly ? If you find an addy arrow it will check if its a swordfish it will see that it is not and it will return false and not bother checking everything else .

    It should be something like this

    if(WILD_AREA.contains(gi) && (gi.getName().equals("Swordfish") ||(gi.getName().equals("Adamant arrow")) )

    Quite right I'm an idiot, however I attempted to fix up the code a bit and this is what I came up with. It only gets arrows now however. Uhg. The last ID, 890 is the arrows..

     

     

    if(!getInventory().isFull() && !getLocalPlayer().isHealthBarVisible()){
            (getGroundItems().closest((item) -> item != null && item.getID() == 1478 || item.getID() == 374
            || item.getID() == 120 || item.getID() == 118 || item.getID() == 116
            || item.getID() == 114 || item.getID() == 1726 || item.getID() == 890)).interact("Take");
            }
    

     

    lol , here :

    if(!getInventory().isFull() && !getLocalPlayer().isHealthBarVisible()){

    (getGroundItems().closest((item) -> item != null && ( item.getID() == 1478 || item.getID() == 374

    || item.getID() == 120 || item.getID() == 118 || item.getID() == 116

    || item.getID() == 114 || item.getID() == 1726 || item.getID() == 890))).interact("Take");

    }

    if what I gave you doesn't work then your ID's aren't good .

    Edited by ozeki6
    Link to comment
    Share on other sites

    lol , here :

    if(!getInventory().isFull() && !getLocalPlayer().isHealthBarVisible()){

    (getGroundItems().closest((item) -> item != null && ( item.getID() == 1478 || item.getID() == 374

    || item.getID() == 120 || item.getID() == 118 || item.getID() == 116

    || item.getID() == 114 || item.getID() == 1726 || item.getID() == 890))).interact("Take");

    }

    if what I gave you doesn't work then your ID's aren't good .

    Thanks a bunch for the help. Fairly certain however that instead of a programmers case of bad pemdas this is more of an api bottleneck. Both give the same results and I've triple checked the ids, and even switched them for names. Might just be that the arrows are so much more common than anything else. I thought having all the other ids first would prioritize them in that order, but it's just not working out. And thanks everyone else as well!

    Link to comment
    Share on other sites

    Thanks a bunch for the help. Fairly certain however that instead of a programmers case of bad pemdas this is more of an api bottleneck. Both give the same results and I've triple checked the ids, and even switched them for names. Might just be that the arrows are so much more common than anything else. I thought having all the other ids first would prioritize them in that order, but it's just not working out. And thanks everyone else as well!

    it should prioritize in that order 

    Link to comment
    Share on other sites

    Thanks a bunch for the help. Fairly certain however that instead of a programmers case of bad pemdas this is more of an api bottleneck. Both give the same results and I've triple checked the ids, and even switched them for names. Might just be that the arrows are so much more common than anything else. I thought having all the other ids first would prioritize them in that order, but it's just not working out. And thanks everyone else as well!

    Note that you are getting the closest item to your player with that code. When you tested this and it only got addy arrows, were the arrows closer to you than any of the other items? Try doing it with one of the other items closer to you than addy arrows. Then you could also do one with one of the other items on the same tile as addy arrows to test if its prioritizing them in the order you are checking the ids.

    Edited by distraction
    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.