Hello.
1. itemcount to count visible items (items on currently open containers)
If you wanna know the EXACTLY COUNT using itemcount then you must have all backpacks open. It's the most accurate method.
However, if you just wanna check when UHs are going out then you just need to leave the last bp open. For example: You have 3 BPs of UH then leave the last bp open, so the function will check for this bp. Once you start to use the last bp of uhs, you will be able to know because the uhs on that bp will be gone.
itemcount(string/number item, optional string location name, optional boolean countEquipments) [number]: Represent the amount of defined items found on opened containers.
|Only Registered members can see download links. | Click here to buy subscription or here to register.
2. screenmessage() and itemcountmsg() to count from the last green message that shows up when you use a hotkey.
This method works based on messages green messages that shows in the middle of your screen when using an item by hotkeys.
screenmessage() [string]: Returns the last green message that appeared to you. The optional parameter bool visible, true by default, if true will only return if the message is currently visible.
itemcountmsg(string item, string message) [number]: Returns the amount of items from a using on message. E.g.: itemcountmsg('vial', 'Using one of 2 vials...') will return value 2. itemcountmsg('vial', 'Using the last vial...') will return value 1.
Notice if you use itemcountmsg() with an item but the message is talking about another item OR message is invalid (not related to items) then it will return -1.
The script below checks if it's higher or equal than zero due to reason above. So it would not leave in case of last message related to another item for example.
local item = 'vial' -- mana fluid shows up as a vial on the green message.
local count = itemcountmsg('vial', screenmessage())
if count >= 0 and count <= 10 then
gotolabel('leave')
end
|Only Registered members can see download links. | Click here to buy subscription or here to register.
3. actionbarcount() to count from the action bar, but i'm not sure how accurate that is and this works only for stackable items.
local item = 'fish'
if actionbarcount(item) <= 10 then
gotolabel('leave')
end
4. Select server log and use getmessages() to read the "Using ..." message as well.
That's only useful for checking for runes on specific places. For example: Create an Action to select server log, check for supplies and select Default back.
It will count enchanted spears from your LEFT HAND (<<<).
local ENCHANTED_SPEAR_ID = 1234 -- Enchanted spear id.
local leftHandItem = lhand()
if leftHandItem.id == 0 or leftHandItem.id ~= ENCHANTED_SPEAR_ID or (leftHandItem.id == ENCHANTED_SPEAR_ID and leftHandItem.count < 5) then
playsound('default')
flashclient()
end
As you wanna alert whenever you get 50 mfs or 40 uhs then the only way is by using itemcountmsg().
Notice that any rune will show up as "spell rune", so if you are using runes to hunt then it's NOT gonna work.
local mf_item = 'vial' -- mana fluid shows up as a vial on the green message.
local uh_item = 'spell rune' -- ultimate healing rune shows up as a vial on the green message.
local mf_count = itemcountmsg(mf_item, screenmessage())
if mf_count >= 0 and mf_count <= 10 then
playsound('default')
flashclient()
else
local uh_count = itemcountmsg(uh_item, screenmessage())
if uh_count >= 0 and uh_count <= 10 then
playsound('default')
flashclient()
end
end