NC29 1 Posted February 25, 2018 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!!
Nuclear Nezz 2104 Posted February 25, 2018 (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}
NC29 1 Author Posted February 26, 2018 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}
Recommended Posts
Archived
This topic is now archived and is closed to further replies.