Модуль:Песочница/Pok: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 44: | Строка 44: | ||
--------------------------------------------------------------------- | --------------------------------------------------------------------- | ||
local function | local function searchTableIdInStructure(struct, tableIds) | ||
if type(struct) ~= "table" then | |||
return false | |||
end | |||
if struct.tableId then | |||
for _, tid in ipairs(tableIds) do | |||
if struct.tableId == tid then | |||
return true | |||
end | |||
end | end | ||
end | |||
for _, v in pairs(struct) do | |||
if type(v) == "table" then | |||
if searchTableIdInStructure(v, tableIds) then | |||
return true | |||
end | end | ||
end | end | ||
end | end | ||
return false | |||
return | |||
end | end | ||
| Строка 94: | Строка 88: | ||
local matchingStorages = {} | local matchingStorages = {} | ||
for storageId, storage in pairs(itemData) do | for storageId, storage in pairs(itemData) do | ||
if type(storage) == "table" | if type(storage) == "table" then | ||
local found = false | |||
if storage.EntityTableContainerFill and storage.EntityTableContainerFill.containers then | |||
if searchTableIdInStructure(storage.EntityTableContainerFill.containers, allRelatedTables) then | |||
found = true | |||
end | end | ||
end | end | ||
if | if storage.id and storage.id == targetId then | ||
found = true | |||
end | |||
if found then | |||
table.insert(matchingStorages, storageId) | |||
end | end | ||
end | end | ||
end | end | ||