Advertisement
adrianoswatt

getItemType [Edited by Swatt]

Sep 25th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. -- Função que Retorna Tipo de Item
  2. function getItemType(itemid)
  3.     local slottypes = {"head", "body", "legs", "feet", "ring", "necklace", "axe", "club", "sword", "shield"}
  4.     local consts = {
  5.         ["head"] = CONST_SLOT_HEAD,
  6.         ["armor"] = CONST_SLOT_ARMOR,
  7.         ["legs"] = CONST_SLOT_LEGS,
  8.         ["feet"] = CONST_SLOT_FEET,
  9.         ["ring"] = CONST_SLOT_RING,
  10.         ["necklace"] = CONST_SLOT_NECKLACE,
  11.         ["axe"] = CONST_SLOT_LEFT,
  12.         ["club"] = CONST_SLOT_LEFT,
  13.         ["sword"] = CONST_SLOT_LEFT,
  14.         ["shield"] = CONST_SLOT_RIGHT,
  15.     }
  16.     local arq = io.open("data/items/items.xml", "r"):read("*all")
  17.     local attributes = arq:match('<item id="' .. itemid .. '".+name="' .. getItemNameById(itemid) ..'">(.-)</item>')
  18.     local slot = ""
  19.     for i, x in pairs(slottypes) do
  20.         if attributes:find(x) then
  21.             slot = x
  22.             break
  23.         end
  24.     end
  25.     if slot == "body" then
  26.         slot = "armor"
  27.     end
  28. return consts[slot]
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement