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


    thiccbooty123

    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);
        }

    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

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.