Модуль:Песочница/Pok: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 51: | Строка 51: | ||
getContentsOutput = function(contents) | getContentsOutput = function(contents) | ||
local result = "" | local result = "" | ||
for _, content in ipairs(contents) do | |||
result = result .. formatContent(content) | |||
end | end | ||
return result | return result | ||
| Строка 72: | Строка 64: | ||
local result = "" | local result = "" | ||
for _, child in ipairs(children) do | |||
if child.id then | |||
if not visited[child.id] then | |||
result = result .. formatContent(child) | |||
end | end | ||
elseif child["!type"] == "NestedSelector" then | |||
result = result .. handleNestedSelector(child, true, visited) | |||
elseif child["!type"] == "GroupSelector" then | |||
result = result .. handleGroupSelector(child, visited) | |||
end | end | ||
end | end | ||
return result | return result | ||
end | end | ||
| Строка 157: | Строка 134: | ||
-- Обработка entity_storage | -- Обработка entity_storage | ||
if containers.entity_storage then | if containers.entity_storage then | ||
if containers.entity_storage.children | if containers.entity_storage.children then | ||
for _, child in ipairs(containers.entity_storage.children) do | |||
if child.id then | |||
result[#result + 1] = formatContent(child) | |||
elseif child["!type"] == "GroupSelector" then | |||
result[#result + 1] = handleGroupSelector(child, visited) | |||
elseif child["!type"] == "AllSelector" then | |||
result[#result + 1] = processNestedSelectors(child.children, visited) | |||
end | end | ||
end | end | ||
| Строка 188: | Строка 153: | ||
-- Обработка storagebase (аналогично entity_storage) | -- Обработка storagebase (аналогично entity_storage) | ||
if containers.storagebase then | if containers.storagebase then | ||
if containers.storagebase.children | if containers.storagebase.children then | ||
for _, child in ipairs(containers.storagebase.children) do | |||
if child.id then | |||
result[#result + 1] = formatContent(child) | |||
elseif child["!type"] == "GroupSelector" then | |||
result[#result + 1] = handleGroupSelector(child, visited) | |||
elseif child["!type"] == "AllSelector" then | |||
result[#result + 1] = processNestedSelectors(child.children, visited) | |||
end | end | ||
end | end | ||
| Строка 243: | Строка 196: | ||
end | end | ||
for _, child in ipairs(groupSelector.children) do | |||
if child["!type"] == "GroupSelector" then | |||
result = result .. handleGroupSelector(child, visited) | |||
elseif child["!type"] == "AllSelector" then | |||
result = result .. string.format('{{LinkСard/Сollapsible|name=Выпадают только вместе:|content=%s}}', handleAllSelector(child)) | |||
elseif child.id then | |||
result = result .. formatContent(child) | |||
else | else | ||
result = result .. "<div>Ошибка: отсутствует id у элемента.</div>" | |||
end | end | ||
end | end | ||
| Строка 340: | Строка 277: | ||
local allReagents = {} | local allReagents = {} | ||
for _, solution in pairs(item.SolutionContainerManager.solutions) do | for _, solution in pairs(item.SolutionContainerManager.solutions) do | ||
if solution and solution.reagents | if solution and solution.reagents then | ||
for _, reagent in ipairs(solution.reagents) do | |||
table.insert(allReagents, reagent) | |||
end | end | ||
end | end | ||
| Строка 354: | Строка 285: | ||
local hasNonFiber = false | local hasNonFiber = false | ||
for _, reagent in ipairs(allReagents) do | |||
if reagent.ReagentId ~= "Fiber" then | |||
hasNonFiber = true | |||
break | |||
end | end | ||
end | end | ||
| Строка 378: | Строка 298: | ||
local function processSolution(solution) | local function processSolution(solution) | ||
local output = "" | local output = "" | ||
if solution and solution.reagents | if solution and solution.reagents then | ||
for _, reagent in ipairs(solution.reagents) do | |||
local chemInfo = chemTranslateData[reagent.ReagentId] | |||
local displayName = chemInfo and chemInfo.name or reagent.ReagentId | |||
output = output .. string.format( | |||
'<li>[[Химия#chem_%s|%s]] (%d ед.)</li>', | |||
reagent.ReagentId, displayName, reagent.Quantity | |||
) | |||
end | end | ||
end | end | ||
| Строка 408: | Строка 317: | ||
result = result .. processSolution(item.SolutionContainerManager.solutions["injector"]) | result = result .. processSolution(item.SolutionContainerManager.solutions["injector"]) | ||
result = result .. processSolution(item.SolutionContainerManager.solutions["pen"]) | result = result .. processSolution(item.SolutionContainerManager.solutions["pen"]) | ||
return result ~= "" and string.format('<ul class="1">%s</ul>', result) or '' | return result ~= "" and string.format('<ul class="1">%s</ul>', result) or '' | ||
end | end | ||
| Строка 460: | Строка 369: | ||
if not itemDataEntry then return "" end | if not itemDataEntry then return "" end | ||
local startingItem = nil | local startingItem = nil | ||
if itemDataEntry.ItemSlots and itemDataEntry.ItemSlots.slots | if itemDataEntry.ItemSlots and itemDataEntry.ItemSlots.slots then | ||
for _, slot in ipairs(itemDataEntry.ItemSlots.slots) do | |||
if slot.startingItem and slot.startingItem ~= "" then | |||
startingItem = slot.startingItem | |||
break | |||
end | end | ||
end | end | ||
| Строка 496: | Строка 396: | ||
if not itemDataEntry then return "" end | if not itemDataEntry then return "" end | ||
local startingItem = nil | local startingItem = nil | ||
if itemDataEntry.ItemSlots and itemDataEntry.ItemSlots.slots | if itemDataEntry.ItemSlots and itemDataEntry.ItemSlots.slots then | ||
for _, slot in ipairs(itemDataEntry.ItemSlots.slots) do | |||
if slot.startingItem and slot.startingItem ~= "" then | |||
startingItem = slot.startingItem | |||
break | |||
end | end | ||
end | end | ||