refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-23 12:45:23 +02:00
parent 99ba3e7fdc
commit deb85ad030
18 changed files with 169 additions and 152 deletions
+23
View File
@@ -404,4 +404,27 @@ function public.item_quality_index(item_quality)
return i, quality
end
end
end
function public.accessor.inventory()
local bag, slot = 0, 0
return function()
if not GetBagName(bag) or slot >= GetContainerNumSlots(bag) then
repeat bag = bag + 1 until GetBagName(bag) or bag > 4
slot = 1
else
slot = slot + 1
end
if bag <= 4 then return {bag, slot}, bag_type(bag) end
end
end
function public.bag_type(bag)
if bag == 0 then return 1 end
for link in present(GetInventoryItemLink('player', ContainerIDToInventoryID(bag))) do
local item_id = parse_link(link)
local item_info = item(item_id)
log(link, item_id, item_info, item_info.subclass)
return item_subclass_index(3, item_info.subclass)
end
end