1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question Color of inventory items

Discussion in 'Developer Support' started by machkNL, Aug 22, 2019.

  1. machkNL

    Joined:
    Feb 8, 2019
    Messages:
    2
    Likes Received:
    0
    Currently, I'm trying to learn how to program in java and creating a bot at the same time. I want to create a runecrafting bot and I want it to use essence pouches. When the pouch degrades it turns black. I want to use this colour change to identify when to use NPC contact.

    How do I find the colour of an item? I have searched this forum and everyone sais you can find the colour of an entity by GameObjects, however, when I use the developer toolkit there's no information visible about the colour of the entities and/or inventory items.

    How do i find the color using the developer toolkit?
     
  2. Driftson

    Driftson Shooting up KFC's

    Joined:
    May 27, 2016
    Messages:
    205
    Likes Received:
    61
    nvm.
     
    #2 Driftson, Aug 22, 2019
    Last edited: Aug 22, 2019
  3. Jhinn

    Joined:
    Jun 9, 2015
    Messages:
    3,646
    Likes Received:
    1,337
    @machkNL You'll need to use `getColorSubstitutions()`. If it returns not empty, it means a pouch is degraded. If you query for your pouches in the inventory, you can use filters to figure out if they're broken or not.

    This is old code, but it should still work:

    Code (Text):
    1.     public SpriteItemQueryResults getPouches() {
    2.         return Inventory.newQuery().names("Small pouch", "Medium pouch", "Large pouch", "Giant pouch").results();
    3.     }
    4.  
    5.     public boolean isPouchBroken() {
    6.         return getAvailablePouches().stream().anyMatch(p -> p.getDefinition() != null && !p.getDefinition().getColorSubstitutions().isEmpty());
    7.     }
     
  4. machkNL

    Joined:
    Feb 8, 2019
    Messages:
    2
    Likes Received:
    0
    Thanks for your reply. With your help, I managed to find where in the developer tool I need to look to identify colour changes. Thanks for the code as well, however, I won't be using that any time soon since I'm still in the process of listing all GameObjects I need to make my bot work!
     

Share This Page

Loading...