Jump to content

Check if wearing item?


Recommended Posts

Posted (edited)

Hi guys, its me again. Making some progress on my first script but i ran into an issue.

I am trying to make the script check if i'm wearing a ring (to check if there are still duelling ring charges). 

This is my code but it doesn't seem to work :(

if (!equipment.isWearingItem(EquipmentSlot.RING)) {

log("no ring");

status = "Withdrawing ring of duelling";

getBank().withdraw("Ring of duelling(8)", 1);

new ConditionalSleep(10000) {

@Override

public boolean condition() throws InterruptedException {

return inventory.contains("Ring of duelling(8)");

}

}.sleep();

bank.close();

sleep(random(500,700));

inventory.getItem("Ring of duelling(8)").interact("Wear");

new ConditionalSleep(10000) {

@Override

public boolean condition() throws InterruptedException {

return getEquipment().isWearingItem(EquipmentSlot.RING);

}

}.sleep(); 



}

 

I believe the issue is in the first if statement of isWearingItem 

Edited by rallostar
Posted (edited)
15 minutes ago, HeyImJamie said:

Not on an IDE but probs something like 


if (!equipment.isWearingItem(EquipmentSlot.RING, duelring -> duelring.getName().contains("Ring of duelling"))){
	// no ring

Edit: Thinking about it, isn't there isWearingItemThatContains?

Yes that's true but can't I just check if ring is empty? Would be a smaller code too. 

I'll try it with isWearingItemThatContains tho to see if that works.

 

EDIT: It  worked and logged the No Ring string, but then it logged this error:

[ERROR][Bot #1][07/17 01:34:37 AM]: Error in script executor!
java.lang.NullPointerException
    at Main.onLoop(Main.java:190)
    at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(vj:152)
    at java.lang.Thread.run(Thread.java:745)

this error comes after sleeping for 10000 ms 

dunno where its coming from

Edited by rallostar

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...