trusted
167
edits
(Break up recipe row functions, add comments, use recipe ID to determine component/building) |
(Include ocean data, use GridIndex for component/building) |
||
Line 44: | Line 44: | ||
end | end | ||
if isItemOcean(item.ID) then | if isItemOcean(item.ID) then | ||
table.insert(rtable, oceanRow(item | table.insert(rtable, oceanRow(item, frame)) | ||
end | end | ||
table.insert(rtable, '|}') | table.insert(rtable, '|}') | ||
Line 101: | Line 101: | ||
for _, giant in pairs(deduplicateGiants(gasGiantsMakingByID(item.ID))) do | for _, giant in pairs(deduplicateGiants(gasGiantsMakingByID(item.ID))) do | ||
table.insert(output, gasGiantRecipe(giant, frame)) | table.insert(output, gasGiantRecipe(giant, frame)) | ||
end | |||
if isItemOcean(item.ID) then | |||
table.insert(rtable, oceanRecipe(item, frame)) | |||
end | end | ||
return table.concat(output, '\n') | return table.concat(output, '\n') | ||
Line 246: | Line 249: | ||
end | end | ||
function oceanRow(item | function oceanRow(item, frame) | ||
local pump = itemByName(machines.Ocean) | local pump = itemByName(machines.Ocean) | ||
local pumpTech = technologyForRecipeID(recipesMakingByID(pump.ID)[1].ID) | local pumpTech = technologyForRecipeID(recipesMakingByID(pump.ID)[1].ID) | ||
Line 307: | Line 310: | ||
for _, itemid in pairs(recipe.Items) do | for _, itemid in pairs(recipe.Items) do | ||
if itemid == id then | if itemid == id then | ||
if | if recipe.GridIndex >= 2000 then | ||
table.insert(buildings, recipe) | table.insert(buildings, recipe) | ||
else | else | ||
Line 361: | Line 364: | ||
end | end | ||
-- deduplication | -- sorting/deduplication | ||
function recipeSort(recipes) | |||
table.sort(recipes, function(a, b) | |||
return a.GridIndex < b.GridIndex | |||
end) | |||
return recipes | |||
end | |||
function deduplicateGiants(giants) | function deduplicateGiants(giants) |