Page 1 of 1

How to count items by part of their name?

Posted: Sat Dec 03, 2011 9:51 pm
by Rickster
I want to count all the fusion stones in my bags and when there are enough, send them with UMM.

There are only Fusion Stones in my bags, but there exist many different kinds, from NPC, mini games, shop e.g.
Have a look over here for them.

They all have different IDs, but I want to count them all and get one result.

They all have in common "Fusion" as part of their names. This refers to the us and de clients, do not no about others.

Sending them can be done by

Code: Select all

UMM_SendByNameOrId(_recipient, _itemTable[, _amount])
coz you can find a placeholder for all Fusion Stones in the file \micromacro\scripts\rom\cache\itemtypestable.lua. So

Code: Select all

UMM_SendByNameOrId(_recipient, "Fusion Stones", _amount])
should do the job and send all or an amount of items belonging to the _itemTable entry "Fusion Stones". (I do not know how to make this independent from localization)

But how to count them before sending?

Ric

Re: How to count items by part of their name?

Posted: Sat Dec 03, 2011 10:34 pm
by rock5
First of all "UMM_SendByNameOrId" does not send by 'type' as you suggest, it sends by the name or id, as the name of the function implies.

To send by type you could use ...... hm looks like I don't have a 'send by type' function but you could use the advanced function.

Code: Select all

UMM_SendAdvanced(_recipient, _nil, nil, nil, nil, _objtype, nil, nil, _amount)
Although if all the stones have the words "Fusion Stone" it's probably easier to just send by name. "UMM_SendByNameOrId" sends by partial name so any item with the words "Fusion Stone" will be sent.

As to counting the stones, the easiest way would be to just count them separately. Even though there are a lot of ids, there are only a few names.

Code: Select all

count = inventory:itemTotalCount("Fusion Stone") + inventory:itemTotalCount("Random Fusion Stone") + inventory:itemTotalCount("Honor Fusion Stone")
'itemTotalCount' does not count partial names, only the full names, so they need to be counted separately.

Re: How to count items by part of their name?

Posted: Sun Dec 04, 2011 11:13 am
by Rickster
Ok, so counting should not be a big prob.
And by counting each stone type I can use IDs to be independant from localisation.

Re: How to count items by part of their name?

Posted: Sun Dec 04, 2011 11:49 am
by rock5
Not so easy. There are a lot of "Fusion Stone" ids. I believe there is only 1 "Random Fusion Stone" id and 1 "Honor Fusion Stone" id so it would be easy to use ids for them. It might be easier to get the localized name and use that.
eg.

Code: Select all

FusionStoneName = RoMScript("TEXT('Sys202880_name')"); 
count = inventory:itemTotalCount(FusionStoneName) + inventory:itemTotalCount(202999) + inventory:itemTotalCount(206694)
That should work.