introduce talkaction to query house tile items by id

This commit is contained in:
ErikasKontenis
2020-03-31 12:30:50 +03:00
parent 693a9120ee
commit a53e79d628
3 changed files with 57 additions and 0 deletions

View File

@@ -25,3 +25,25 @@ end
function Container.isTile(self)
return false
end
function Container.getItemsById(self, itemId)
local list = {}
for index = 0, (self:getSize() - 1) do
local item = self:getItem(index)
if item then
if item:isContainer() then
local rlist = item:getItemsById(itemId)
if type(rlist) == 'table' then
for _, v in pairs(rlist) do
table.insert(list, v)
end
end
else
if item:getId() == itemId then
table.insert(list, item)
end
end
end
end
return list
end