Jump to content

Checking to see if an item in your inventory has a certain action?


Recommended Posts

Posted

I saw that itemcontainer had a method for .hasAction() which was what I was looking for, but no matter what I tried, it kept giving me an error.

 

What action are you looking for?

 

I know that item.interact returns a boolean so you can basically check if it happened, and if it doesnt do nothing or something.

Posted (edited)

What action are you looking for?

 

I know that item.interact returns a boolean so you can basically check if it happened, and if it doesnt do nothing or something.

 

Does it really? I think that pretty much solves this then. I just need to check if an item has a certain action, and if it doesn't then don't bother doing anything with this item.

 

Lol it does, I really didn't know that. Pretty sure that should fix this then. Thanks a lot :)

Edited by twin 763
Posted

Does it really? I think that pretty much solves this then. I just need to check if an item has a certain action, and if it doesn't then don't bother doing anything with this item.

 

Lol it does, I really didn't know that. Pretty sure that should fix this then. Thanks a lot smile.png

 

http://osbot.org/api/org/osbot/rs07/api/model/Item.html#hasAction%28java.lang.String...%29

 

Check this out also, Item has a hasAction method

Posted (edited)

Twin do not use != false

If you do

If (boolean) <-- its already checking to see if its true.

If (!boolean) <-- false check

That's what I did sorry :p. I just got up when I wrote that wasn't thinking lol.

At least I think I did. I might have to check my code when I get home. :o

Edited by twin 763
Posted

Next time you say you get an "error" you should include the exception stack trace as well so we can help you pinpoint the exact location and cause of the problem very quickly.

I was just getting cannot make a static call to a non static reference but that's because I was using the wrong code. Like I said, I just didn't know inventory.interact returned as Boolean.

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...