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
  • Calculating Quantity Of Items


    thiccbooty123
     Share

    Recommended Posts

    Hi there, pretty simple thing i need help on.

    Id like to calculate the items on the floor and inventory combined, and if there is less than a total of 28 then i should drop all eye of newts from my inventory.

     

    This is what my boolean looks like:

    *line* is meant to be the area in which the eye of newts are (the rectangular co-ords of where abouts i would be standing around)

     

    private boolean DropEyes() {
        if (getInventory().contains("Eye of newt") && (getGroundItems(Line).names("Eye of newt").results().size() <= 28)) {
            status = "Dropping newts";
            getInventory().drop("Eye of newt");
        }
        return true;
    }

     

    Thanks so much :)

    Link to comment
    Share on other sites

    I'm assuming groundItem.getAmount() doesn't work as they aren't stackable? If so you could iterate of all groundItems in an X tile radius and store the data to a variable?

     

    Something like:

    	private int getGroundItemCount(String itemName) {
            int items = 0;
            for (GroundItem groundItem : getGroundItems().all(i -> i != null && i.getName().equals(itemName) /*Could additionally check for tile*/)) {
                if (groundItem != null && groundItem.exists()) {
                    items++;
                }
            }
            return items;
        }
    	    private int getTotalLoadedItemCount(String itemName) {
            return getInventory().count(itemName) + getGroundItemCount(itemName);
        }

    Edited by Pseudo
    Link to comment
    Share on other sites

    3 hours ago, Pseudo said:

    I'm assuming groundItem.getAmount() doesn't work as they aren't stackable? If so you could iterate of all groundItems in an X tile radius and store the data to a variable?

     

    Something like:

     

    	private int getGroundItemCount(String itemName) {
            int items = 0;
            for (GroundItem groundItem : getGroundItems().all(i -> i != null && i.getName().equals(itemName) /*Could additionally check for tile*/)) {
                if (groundItem != null && groundItem.exists()) {
                    items++;
                }
            }
            return items;
        }
    	    private int getTotalLoadedItemCount(String itemName) {
            return getInventory().count(itemName) + getGroundItemCount(itemName);
        }

     

    Ah fair enough, sorry im quite new to creating scripts :P

    Thanks so much, ill let you know how it goes

    Link to comment
    Share on other sites

    3 hours ago, Pseudo said:

    I'm assuming groundItem.getAmount() doesn't work as they aren't stackable? If so you could iterate of all groundItems in an X tile radius and store the data to a variable?

     

    Something like:

     

    	private int getGroundItemCount(String itemName) {
            int items = 0;
            for (GroundItem groundItem : getGroundItems().all(i -> i != null && i.getName().equals(itemName) /*Could additionally check for tile*/)) {
                if (groundItem != null && groundItem.exists()) {
                    items++;
                }
            }
            return items;
        }
    	    private int getTotalLoadedItemCount(String itemName) {
            return getInventory().count(itemName) + getGroundItemCount(itemName);
        }

     

    image.png.a746edd3980e5874aad58b3ec5996981.png

    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.