Jump to content

Check if wearing item?


rallostar

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

5 minutes ago, rallostar said:

Lol wtf.. I googled it but in RS3 it's duelling and osrs its dueling:facep:. Thanks mate !

Even the smallest mistakes make your script fail :boge:

 

You might want to use the filter @HeyImJamie provided you so the bot can use ring of dueling no matter how much charges it has

Edited by Abysm
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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