Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Função que Retorna Tipo de Item
- function getItemType(itemid)
- local slottypes = {"head", "body", "legs", "feet", "ring", "necklace", "axe", "club", "sword", "shield"}
- local consts = {
- ["head"] = CONST_SLOT_HEAD,
- ["armor"] = CONST_SLOT_ARMOR,
- ["legs"] = CONST_SLOT_LEGS,
- ["feet"] = CONST_SLOT_FEET,
- ["ring"] = CONST_SLOT_RING,
- ["necklace"] = CONST_SLOT_NECKLACE,
- ["axe"] = CONST_SLOT_LEFT,
- ["club"] = CONST_SLOT_LEFT,
- ["sword"] = CONST_SLOT_LEFT,
- ["shield"] = CONST_SLOT_RIGHT,
- }
- local arq = io.open("data/items/items.xml", "r"):read("*all")
- local attributes = arq:match('<item id="' .. itemid .. '".+name="' .. getItemNameById(itemid) ..'">(.-)</item>')
- local slot = ""
- for i, x in pairs(slottypes) do
- if attributes:find(x) then
- slot = x
- break
- end
- end
- if slot == "body" then
- slot = "armor"
- end
- return consts[slot]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement