How to level of item from item id?

Level 15
Joined
Aug 7, 2013
Messages
1,337
Hi,

Is there a way to get the level of an item based on its integer id?

Otherwise, do we have to create a dummy item--how does this sound (and leakless too I hope..)?

JASS:
function GetItemLevelById takes integer itemID returns integer
  local item i = CreateItem(itemId, X, Y)
  local integer level = GetItemLevel(i)
  call RemoveItem(i)
  set i = null
  return level
endfunction
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
But if you need to do these level checks very frequently you should cache them in a hashtable.

Already doing that basically. I should only have to calculate the level of each item type once, then I'll store it away.

Thanks for the responses--wasn't sure if there was a native or a better way (besides hardcoding it in).
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Well one more thing: if you are generating the itemtypes you could try to pass the respective values from the objectgenerator to the map script. Im not sure how convenient this is with vJass and ObjectMerger/LUA, but with WurstScript its very simple.
 
Top