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
  • If equipment slot is empty or specific item is not equiped


    NC29

    Recommended Posts

    Hey. I am new to Runescape scripting and still getting to know the API..

     

    I am trying to check if an item slot is empty, or already contains the required item. I am unable to test at the moment so looking for some advice on the below on whether I am taking the right approach and ways to improve

     

    if ((getEquipment().isSlotEmpty(EquipmentSlot.HAT.getSlot())) || (EquipmentSlot.HAT.name() != "Iron Full Helm"))

     

    After this I will either:

    a. Equip item if in inventory

    b. Go to bank, withdraw and equip item

    c. Go to shop, buy item and equip

     

    Thanks!!

    Link to comment
    Share on other sites

    (EquipmentSlot.HAT.name() != "Iron Full Helm"))

     

    Is not how you check that. That'll just give you the name of the enum.

    Also don't use == or != on objects, they're different things. Use .equals

    Item item = getEquipment().getInSlot(EquipmentSlot.HAT); or whatever the method is

    if(item == null || !item.getName().equals("Shit")){stuff}

    Link to comment
    Share on other sites

    Thanks Nezz

     

    (EquipmentSlot.HAT.name() != "Iron Full Helm"))

     

    Is not how you check that. That'll just give you the name of the enum.

    Also don't use == or != on objects, they're different things. Use .equals

    Item item = getEquipment().getInSlot(EquipmentSlot.HAT); or whatever the method is

    if(item == null || !item.getName().equals("Shit")){stuff}

    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.