Jump to content

Check Examine Text against String


Recommended Posts

Posted

Hey all,

I'm combining items within the inventory, the first few combinations change the name of the item so I just sleep until that item name is within the inventory. BUT other item combinations I'm automating keep the same Item name but the examine text changes. How would I go about checking the examine text against a string.

I don't think I'm allowed to post GitHub links so I won't. I'll insert an example of what I'm trying to do.

 

if (getInventory().interact("Examine", item) == String)
                    {
                        //Actions to do
                    }

This obviously doesn't work as the interact method returns a boolean, but how would I go about getting the text from the examine action?

(I've already stored the text that I want to check against in a String)

If you would like to see the current script, I'm more than happy to link it, just pm me. The current script is completely functional but slow. I'm rewriting it currently with better checks and more features but I'm completely stumped on this atm.

 

PS: Should have mentioned that the script makes Guthix Rests. It is nowhere near as complex as I'd like it but it works, although slowly.

Posted
Quote

sleep until that item name is within the inventory

In my opinion this is a big mistake; the key with a solid script is that the onLoop is minimally interrupted; i.e no long sleeps. Perhaps not as important for a fletching script or something similar to what you're doing, however for scripts such as those which involve combat, checking values such as hp levels, prayer levels etc regularly is paramount.

There must be a way for you to check the status based on the current contents of your inventory, your animation or some kind of inventory change listener implementation!

Posted
1 hour ago, Apaec said:

In my opinion this is a big mistake; the key with a solid script is that the onLoop is minimally interrupted; i.e no long sleeps. Perhaps not as important for a fletching script or something similar to what you're doing, however for scripts such as those which involve combat, checking values such as hp levels, prayer levels etc regularly is paramount.

There must be a way for you to check the status based on the current contents of your inventory, your animation or some kind of inventory change listener implementation!

I'll think about it further then.

The problem I have is that the item being combined has the same name for three actions. The only thing that changes is the examine text. I could listen the inventory but that would only work if I make the item one by one. If I attempt to make the tea by completing the combination step at the same time,  Ie combining the next herb four times in a row, will use the the same herb tea mix instead of using one herb individually on each mix. If you look up how guthix rests are made or herb tea mix you'll see that the item only changes examine text not the item name. Ill continue to think about it, but I want to avoid having the item being used on a specific item slot as that may cause other issues if it withdraws a different amount of items than required for that method to work. 

1 hour ago, Dex said:

Well first of all, don't use "==".

Use instanceOf String.

 

To get the text from the examine text I suggest you use toString.

Sorry! My example was rushed but fear not, I do know how to compare strings. I'll check to see if the tostring method on the interact method will return what I need. Thanks for the idea! 

  • Like 1
Posted

I think the easiest way to do it would be what @d0zza mentioned and see if they have different ids. If you want to get the examine text you will need to use the onMessage() method which gets called everytime new text is displayed in the chat. I'm not sure if there is any other way to get that text without examining the item and checking what text is output in the chat box.

Posted
15 minutes ago, d0zza said:

Have you tried checking if the ID of the 2 items is different? Names can be the same but ID can be different.

Checking right now, I do believe you are 100% correct

 

3 hours ago, Apaec said:

In my opinion this is a big mistake; the key with a solid script is that the onLoop is minimally interrupted; i.e no long sleeps. Perhaps not as important for a fletching script or something similar to what you're doing, however for scripts such as those which involve combat, checking values such as hp levels, prayer levels etc regularly is paramount.

Sorry to quote you again. If I'm combining two items and waiting on the item to be made and register in the inventory, why wouldn't I sleep? Maybe I wasn't clear about them being conditional sleeps but I think you're trying to teach me something that I'm failing to understand :(

Posted
11 hours ago, Colorless said:

Sorry to quote you again. If I'm combining two items and waiting on the item to be made and register in the inventory, why wouldn't I sleep? Maybe I wasn't clear about them being conditional sleeps but I think you're trying to teach me something that I'm failing to understand :(

Apologies; I thought when you said you were combining items, you meant for example putting toppings on pizza; and I concluded you were attempting to sleep until, for example, there are no tomatoes left in your inventory, with a time out of 1 minute say.

Guthix teas is a bit different; not entirely sure how they work but i'm sure you will find a neat solution - good luck!

Posted
11 hours ago, Apaec said:

Apologies; I thought when you said you were combining items, you meant for example putting toppings on pizza; and I concluded you were attempting to sleep until, for example, there are no tomatoes left in your inventory, with a time out of 1 minute say.

Guthix teas is a bit different; not entirely sure how they work but i'm sure you will find a neat solution - good luck!

Okay, I'm just relieved I'm not missing a lesson that could improve my work!

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