+ Reply to Thread
Results 1 to 11 of 11

Thread: Inspect.Item.Detail(itemtype) on login

  1. #1
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default Inspect.Item.Detail(itemtype) on login

    I have a function that triggers off of Event.Unit.Availability.Full

    Code:
    local FOOD = 1
    local STONE = 2
    
    local _playerFound = false
    
    local _allbuffs = {}
    local _buffDtls = {
    	{ name = "Ember Steak", cat = FOOD, id = "I31959B69773917AF,B3F3EA37BBDC9E82,,,,,," },
    	{ name = "Dwarven Ghoulash", cat = FOOD, id = "I40314581DB079239,C7B0D9D087069253,,,,,," },
    	{ name = "Feast of Aptitude", cat = FOOD, id = "I379F77F950B6CE2B,F492E1913A033C25,,,,,," },
    	{ name = "Feast of Cooperation", cat = FOOD, id = "I3E08CB4B7DC92A6C,4EF5ACD293E6B909,,,,,," },
    	{ name = "Feast of Efficacy", cat = FOOD, id = "I05711E6E8F14E021,08506C7295BEDEF7,,,,,," },
    	
    	{ name = "Ancient Burning Manastone", cat = STONE, id = "I76F77140A17CAB4C,F8178CA7822EB198,,,,,," },
    	{ name = "Ancient Burning Powerstone", cat = STONE, id = "I4B3B6D62A2371CD7,14AAA9A73F5A2AC9,,,,,," },
    	{ name = "Ancient Burning Witchstone", cat = STONE, id = "I532C843CBD033DF2,EAD48E79ABD33E0A,,,,,," },
    	{ name = "Ancient Exquisite Oilstone", cat = STONE, id = "I0B78B071307D7AF7,053CF0E5CE5FE32C,,,,,," },
    	{ name = "Ancient Exquisite Whetstone", cat = STONE, id = "I060113989C963D19,1C4364ACAE024CCB,,,,,," },
    	{ name = "Ancient Massive Weaponstone", cat = STONE, id = "I4A0968E7D72592C0,0DA541B0CD125376,,,,,," },
    	{ name = "Burning Powerstone", cat = STONE, id = "I79BD18397AF3C969,3C43A37D35321E55,,,,,," },
    	{ name = "Exquisite Oilstone", cat = STONE, id = "I165D9D50534B19B4,F12E517C49EC7856,,,,,," },
    	{ name = "Exquisite Whetstone", cat = STONE, id = "I52653315A6280E17,CB5D872D2C915D7C,,,,,," }
    }
    
    function RS.PlayerAvailable(t)
    	if _playerFound == false then
    		for k,v in pairs(t) do
    			if v == "player" then
    				_playerFound = true
    				for k1,v1 in pairs(_buffDtls) do
    					print("Current Item: "..v1.name)
    					local d = Inspect.Item.Detail(v1.id)
    					if d ~= nil then
    						_allbuffs[d.name] = { c = v1.cat, i = d.icon }
    						print(string.format("%s = %s (%s)", v1.name, d.name, d.icon))
    					end
    				end
    			end
    		end
    	end
    end
    This is throwing an incorrect function usage error on a fresh login :

    Error: Incorrect function usage.
    Parameters: "I0B78B071307D7AF7,053CF0E5CE5FE32C,,,,,,"
    Parameter types: string
    Function documentation:
    Provides detailed information about items.
    item = Inspect.Item.Detail(item) -- table <- item
    item = Inspect.Item.Detail(itemtype) -- table <- itemtype
    item = Inspect.Item.Detail(slot) -- table <- slot
    items = Inspect.Item.Detail(slot) -- table <- slot
    items = Inspect.Item.Detail(elements) -- table <- table
    Parameters:
    elements: A table of slot specifiers, item IDs, or item types.
    item: A single item ID.
    itemtype: A single item type.
    slot: A single slot specifier.

    However, it isnt failing right at the start :

    12:11:00: [RaidStatus] Current Item: Ember Steak
    12:11:00: [RaidStatus] Ember Steak = Ember Steak (Data/\UI\item_icons\meat_20.dds)
    12:11:00: [RaidStatus] Current Item: Dwarven Ghoulash
    12:11:00: [RaidStatus] Dwarven Ghoulash = Dwarven Goulash (Data/\UI\item_icons\bowl_of_vegetable_stew.dds)
    12:11:00: [RaidStatus] Current Item: Feast of Aptitude
    12:11:00: [RaidStatus] Feast of Aptitude = Feast of Aptitude (Data/\UI\item_icons\purple_grape.dds)
    12:11:00: [RaidStatus] Current Item: Feast of Cooperation
    12:11:00: [RaidStatus] Feast of Cooperation = Feast of Cooperation (Data/\UI\item_icons\food_16.dds)
    12:11:00: [RaidStatus] Current Item: Feast of Efficacy
    12:11:00: [RaidStatus] Feast of Efficacy = Feast of Efficacy (Data/\UI\item_icons\white_grape.dds)
    12:11:00: [RaidStatus] Current Item: Ancient Burning Manastone
    12:11:00: [RaidStatus] Ancient Burning Manastone = Ancient Burning Manastone (Data/\UI\item_icons\manastone_04.dds)
    12:11:00: [RaidStatus] Current Item: Ancient Burning Powerstone
    12:11:00: [RaidStatus] Ancient Burning Powerstone = Ancient Burning Powerstone (Data/\UI\item_icons\spellstone_04_b.dds)
    12:11:00: [RaidStatus] Current Item: Ancient Burning Witchstone
    12:11:00: [RaidStatus] Ancient Burning Witchstone = Ancient Burning Witchstone (Data/\UI\item_icons\witchstone_04_a.dds)
    12:11:00: [RaidStatus] Current Item: Ancient Exquisite Oilstone
    12:11:00: [RaidStatus] Ancient Exquisite Oilstone = Ancient Exquisite Oilstone (Data/\UI\item_icons\weaponstone_06.dds)
    12:11:00: [RaidStatus] Current Item: Ancient Exquisite Whetstone
    12:11:00: [RaidStatus] Error in RaidStatus. (details)

    So, failing on Ancient Exquisite Whetstone...

    And if I do this on the console, then it works...

    /script dump(Inspect.Item.Detail("I060113989C963D19,1C4364 ACAE024CCB,,,,,,"))

    12:13:41: [/script] {bind = "account", category = "consumable enchantment", icon = "Data/\\UI\\item_icons\\weaponstone_07.dds", id = "I060113989C963D19,1C4364ACAE024CCB,,,,,,", name = "Ancient Exquisite Whetstone", rarity = "uncommon", requiredLevel = 50, sell = 1000, stackMax = 20, type = "I060113989C963D19,1C4364ACAE024CCB,,,,,,"}

    Somewhat at a loss as to what I am doing wrong - if there was a problem with the code, then I would expect it to all fail.

    I have tried triggering the function from Event.Addon.Startup.End, and I get the same errors.

    From repeated logout/login tests, it doesnt always fail on the same item - sometimes it does 3 before failing, sometimes 10+

    Just when can I expect that an API call will work during an addons startup?

    Any clues as to what I am doing wrong greatfully received!
    Last edited by Adelea; 08-05-2012 at 04:20 AM.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  2. #2
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    This is getting weirder and weirder...

    If I delay my function call for 5 minutes so that my character is well and truly in the world, it still fails.

    However, since I now had a handler for Event.System.Update.Begin I thought I would try and brute force it... wrap it in pcall() and keep retrying till it worked...

    Code:
    local _first = 0
    local _tries = 0
    
    local RS_on = true
    local _frNum = 0
    
    function RS.OnUpdate()
    	_frNum = _frNum+1
    	if RS_on then
    		print("RS.OnUpdate()")
    		RS_on = false
    	end
    
    	for x=_first+1, #_buffDtls do
    		local _itmDtl
    		if _tries == 0 then
    			print("Current Item: ".._buffDtls[x].name)
    		end
    		_tries = _tries+1
    		if pcall(function() _itmDtl = Inspect.Item.Detail(_buffDtls[x].id) end) then
    			print(string.format("#%d (%d) : %s : %s", _tries, _frNum, _itmDtl.name, _itmDtl.icon))
    			_allbuffs[_itmDtl.name] = { c = _buffDtls[x].cat, i = _itmDtl.icon }
    			_tries = 0
    			_first = x
    			break
    		else
    			if _tries%10 == 0 then
    				print("Try #".._tries)
    			end
    			break
    		end
    	end
    end
    And the weird thing here... It works.

    Doing 1 per update frame, they all work on the first try.

    I get through 24 of the 30 in my list before the event handler for Event.Unit.Availability.Full fires for the first time....

    EDIT: In fact, removing the break on success, it does all 30 first time on the first Update.Begin event...

    So why does it work in Event.System.Update.Begin, but consistently fails in Event.Unit.Availability.Full, but Update.Begin runs before Availability.Full ....
    Last edited by Adelea; 08-05-2012 at 04:58 AM.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  3. #3
    Sword of Telara Semele's Avatar
    Join Date
    Mar 2011
    Posts
    872

    Default

    Almost sounds like it has a throttle queue. Though it doesn't seem to mention it in the docs.
    Rank 76 Guardian Mage

  4. #4
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Quote Originally Posted by Semele View Post
    Almost sounds like it has a throttle queue. Though it doesn't seem to mention it in the docs.
    Thats what I was thinking, which is why I went with the repeat until it works...

    But if it was throttled, then I am surprised it ran to completion on the first Event.Update invocation, where it was failing after 3 or 4 earlier.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  5. #5
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    If an item is not in the client's cache you get an incorrect function usage error. However, that will automatically start the caching sequence, so calling the function a few seconds later with the same arguments works as expected. That cache doesn't seem to live very long and it looks like it doesn't survive a logout/character change.
    Author of the Imhothar's Bags addon.

  6. #6
    Plane Touched
    Join Date
    Feb 2012
    Posts
    228

    Default

    Inspect.Item.Detail will throw an error if you call it with an itemType that hasn't been cached yet. That cache seems to be cleared only when logging off the character, that is, reloadui doesn't clear that cache.

    ItemTypes are cached if you see them ingame (inventory, mail, auctions) or through any API call that returns them.

    They can also be cached if you Inspect.Item.Detail them, failing the first time you try, but being available some frames after. Note some itemTypes can't be cached this way, though those are small percentage.

    All items sharing the "base item type", that is, the substring before the first comma, will be cached once any of them is cached.

    A cache miss not only will throw an error, but it was, as of 1.7, a lot more expensive in CPU time than a cache hit.
    Last edited by Baanano; 08-05-2012 at 06:36 AM.

  7. #7
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Well...

    Seems I may have been too hasty in thinking it was all working...

    With my Update.Begin retry method, this login session it retrieved 6 items first time...

    As of right now, I am at try #7300 for the next one...

    So, thinking maybe its down to hammering the server, i've modified my search routine, to try once every 2 seconds :

    Code:
    local _first = 0
    local _tries = 0
    local _frNum = 0
    local _lastsuccess = 0
    
    function RS.OnUpdate()
    	_frNum = _frNum+1
    	if _lastsuccess+2 < os.time() then
    		_lastsuccess = os.time()
    		for x=_first+1, #_buffDtls do
    			print("Searching for item: ".._buffDtls[x].name)
    			local _itmDtl
    			_tries = _tries+1
    			if pcall(function() _itmDtl = Inspect.Item.Detail(_buffDtls[x].id) end) then
    				print(string.format("#%d (%d) : %s : %s", _tries, _frNum, _itmDtl.name, _itmDtl.icon))
    				_allbuffs[_itmDtl.name] = { c = _buffDtls[x].cat, i = _itmDtl.icon }
    				_tries = 0
    				_first = x
    			else
    				print("Try #".._tries)
    				break
    			end
    		end
    	end
    end
    And currently on try #60 to retrieve data for Ancient Burning Manastone...

    So if its a cache thing, I would have hoped that nearly 2 mins would be enough time for the client to update!

    There has to be a better way of doing this...
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  8. #8
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Just to rule out the obvious, are you 100% sure the itemid is correct? That might sound silly but you know, it happens. I have the same procedure you describe in ImhoBags, retrying after 1 second and so far no item required more than 1 retry. But I don't do that directly on login, but during the initial Event.Item.Slot which fires some time after login, and I don't actually do antyhing after /reloadui as that event doesn't fire.


    Just a note (not related to the problem itself): creating a lambda capture on every iteration inside the for loop is a bit overkill, CPU and memory wise. I hope you did that just for demonstration purposes. If not then you might refactor your call to
    Code:
    local ok, _itmDtl = pcall(Inspect.Item.Detail, ...)
    if(ok and _itmDtl) then -- It may return nil
    This puts less strain on both the CPU and garbage collector.
    Author of the Imhothar's Bags addon.

  9. #9
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Sometimes it gets further than others, and sometimes it gets all the way to end - so im pretty sure the itemtype values are correct.

    Currently on try #1472 !

    There could be a better way to do what I'm trying to do, but I cant think of one...

    I'm trying to find the actual name of some items, which the player may or may not own - so I can match them up with buffs on players - since there doesnt seem to be a way of getting from a Buff ID to an originating item.

    I suppose I could just give up on people not using the English client !
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  10. #10
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    After realising I can pass in a table of itemIDs, we have:

    Code:
    local _lastsuccess = 0
    local _itmDtl
    local _status
    
    function RS.OnUpdate()
    
    	_frNum = _frNum+1
    	if _lastsuccess+2 < os.time() then
    		_lastsuccess = os.time()
    
    		local itemtypes = {}
    		local cnt = 0
    
    		for k,v in pairs(_buffDtls) do
    			if _allbuffs[v.name] == nil then
    				cnt = cnt+1
    				itemtypes[v.id] = true
    			end
    		end
    		
    		if cnt < 5 then
    			dump(itemtypes)
    		end
    
    		print("Searching for #"..cnt.." items")
    		
    		_status, _itmDtl = pcall(Inspect.Item.Detail, itemtypes)
    		
    		if _status and _itmDtl then
    			for k,v in pairs(_itmDtl) do
    				_allbuffs[v.name] = { i = _itmDtl.icon }
    			end
    		else
    			print("Fail: ")
    			dump(_err)
    		end
    	end
    end
    Which runs, and after a few iterations gets all but 2 items...

    20:06:04: [RaidStatus] Searching for #2 items
    20:06:07: [RaidStatus] {["I40314581DB079239,C7B0D9D087069253,,,,,,"] = true, ["I76F77140A17CAB4C,F8178CA7822EB198,,,,,,"] = true}

    The first of those is Dwarven Ghoulash, which I do have in my bags.

    /script dump(Inspect.Item.Detail("si03.020"))

    20:06:08: [/script] {category = "consumable food", icon = "Data/\\UI\\item_icons\\bowl_of_vegetable_stew.dds", id = "i04E78000219AA6C5", name = "Dwarven Goulash", requiredLevel = 50, sell = 623, stack = 15, stackMax = 99, type = "I40314581DB079239,C7B0D9D087069253,,,,,,"}

    So...

    I40314581DB079239,C7B0D9D087069253,,,,,, The itemtype I am looking for
    I40314581DB079239,C7B0D9D087069253,,,,,, The item type from an inventory query

    They look identical to me.

    Even after doing this, the Inspect.Item.Detail() is failing for this itemtype.
    Last edited by Adelea; 08-05-2012 at 12:19 PM.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  11. #11
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    So, my client crashed...

    I relog, and need to find 11 of the 32 items, quick trip to the guild bank finds 3 of them.

    So - can you only run Inspect.Item.Detail() on items you have seen?

    I had hoped to be able to avoid having localisation for items, instead querying the client for them - since presumably, a non-English client would give the non-English name of items.

    I'm now storing seen items in an account-wide saved variable file, so hopefully over time this will fill out for people!
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts