LoTROInterface

LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Tutorials & Other Helpful Information (L) (https://www.lotrointerface.com/forums/forumdisplay.php?f=21)
-   -   Item information (https://www.lotrointerface.com/forums/showthread.php?t=3656)

gillothrin 04-26-2017 05:11 PM

Item information
 
Hello, is there any way of getting the item's name from a

Item Removed: <Examine:IIDDID:0x0000000000000000:0x7002B018>[Medallions]<\Examine>.

chat entry? The problem in this case is the plural form of the names and I would want the singular form of it.

Garan 04-26-2017 06:34 PM

Yes. You already have an item ID, "0x0000000000000000:0x7002B018"
The "0x0000000000000000" is a unique item identifier (in this case not specified) and the "0x7002B018" is the generic item id part.

If the generic part is 0, then the unique part MUST be specified, otherwise you can use the generic part. In this case, the easiest thing to do is just use the entire "0x0000000000000000:0x7002B018".
To use the itemID to create a shortcut, you have to replace the ":" with a "," like "0x0000000000000000,0x7002B018"

You can use that item ID to create a shortcut and then use the getItem method of the shortcut to get an Item. I would not suggest using the GetName method of the Item object, rather use GetItemInfo() to get an ItemInfo structure and use the GetName() from that (the GetName on the Item is a deprecated function and may not be supported at some point).

I will forgo the parsing and just assign the id to a variable, but you should be able to parse it easily enough.

Code:

  local itemId="0x0,0x7002B018"
  local name="undefined"
  local sc=Turbine.UI.Lotro.Shortcut(Turbine.UI.Lotro.ShortcutType.Item,itemId)
  if sc~=nil then
    local item=sc:GetItem()
    if item~=nil then
      local ii=item:GetItemInfo()
      if ii~=nil then
        name=ii:GetName()
      end
    end
  end

In this case, name="Medallion". Of course, you would want some error messages if sc, item or ii were ever nil, etc. but you should get the gist.


All times are GMT -5. The time now is 02:26 PM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI