Module:Item recipes
Jump to navigation
Jump to search
Examples
{{#invoke:Item_recipes|main|Factory}}
How to make it
Assembly Plant | ||||
---|---|---|---|---|
Ingredients | Products | Duration in days | Nb per year | |
3× Mechanical Parts | Factory | 25 | 12 |
What it can make
Factory | ||||
---|---|---|---|---|
Ingredients | Products | Duration in days | Nb per year | |
3× Iron Ore | Steel Bar | 10 | 30 | |
Steel Bar | Mechanical Parts | 10 | 30 | |
3× Sulfur | Concrete | 10 | 30 | |
Concrete + Steel Bar | Reinforced Concrete | 10 | 30 | |
2× Aluminum Ore | Aluminum Bar | 10 | 30 | |
3× Carbon | Polymer Bar | 10 | 30 | |
2× Aluminum Bar + Polymer Bar | 3× High-tech Parts | 10 | 30 | |
2× Carbon + Nitrogen | Compost | 10 | 30 | |
4× Steel Bar + Nitrogen | 3× Tempered Steel | 10 | 30 | |
Tempered Steel + Polymer Bar | Composite | 10 | 30 |
{{#invoke:Item_recipes|main|Steel Bar}}
How to make it
Factory | ||||
---|---|---|---|---|
Ingredients | Products | Duration in days | Nb per year | |
3× Iron Ore | Steel Bar | 10 | 30 |
Recycling Center | ||||
---|---|---|---|---|
Ingredients | Products | Duration in days | Nb per year | |
3× Metal Waste | 2× Steel Bar + Aluminum Bar | 10 | 30 |
What to make from it
Factory | ||||
---|---|---|---|---|
Ingredients | Products | Duration in days | Nb per year | |
Steel Bar | Mechanical Parts | 10 | 30 | |
Concrete + Steel Bar | Reinforced Concrete | 10 | 30 | |
4× Steel Bar + Nitrogen | 3× Tempered Steel | 10 | 30 |
Assembly Plant | ||||
---|---|---|---|---|
Ingredients | Products | Duration in days | Nb per year | |
3× Steel Bar | Extractor | 25 | 12 | |
3× Steel Bar | Depot | 25 | 12 | |
Concrete + Steel Bar | 8× Rail | 25 | 12 | |
2× Steel Bar + 3× Polymer Bar | Greenhouse | 25 | 12 |
{{#invoke:Item_recipes|main|Supply Center}}
How to make it
Assembly Plant | ||||
---|---|---|---|---|
Ingredients | Products | Duration in days | Nb per year | |
4× Concrete | Supply Center | 25 | 12 |
What it can make
Supply Center | ||||
---|---|---|---|---|
Ingredients | Products | Duration in days | Nb per year | Population |
Concrete | - | 5 → 23.2 | 60 → 12.9 | 1 → 9 |
Concrete + Oxygen | - | 6.7 → 33.1 | 45 → 9.1 | 10 → 99 |
Reinforced Concrete + Oxygen | - | 15 → 74.9 | 20 → 4 | 100 → 999 |
Reinforced Concrete + Oxygen + High-tech Parts | - | 37.5 → 187.5 | 8 → 1.6 | 1000 → 9999 |
Reinforced Concrete + Oxygen + High-tech Parts + Food | - | 100 → 500 | 3 → 0.6 | 10000 → 99999 |
Composite + Oxygen + High-tech Parts + Food | - | 200 → - | 1.5 → - | 100000 → ∞ |
local p={}
function HasAUse(name, recipe)
for i=1,7,2 do
if recipe.inputs[i] == name then return true end
end
return false
end
function IsMadeWith(name, recipe)
for i=1,7,2 do
if recipe.outputs[i] == name then return true end
end
end
function Produces(name, recipe)
return recipe.factory == name
end
function CreateTabHeader(factory, frame, is_city)
s = '\n{| class="wikitable sortable"\n'
.. '! colspan=5 | ' .. frame:expandTemplate{title = 'item', args = {factory}} .. '\n'
-- .. '! colspan=2 | ' .. string.format("{item|%s}", factory) .. '\n'
.. '|-\n'
.. '! Ingredients !! Products !! Duration in days !! Nb per year '
if is_city then s = s .. ' !! Population' end
return s .. '\n'
end
function CreateTableLine(recipe, frame)
str = '|-\n| '
if #recipe.inputs == 0 then str = str .. '-' end
for i=1,7,2
do
if recipe.inputs[i] ~= nil then
if i ~= 1 then str = str .. ' + ' end
if recipe.inputs[i + 1] > 1 then str = str .. string.format('%d× ', recipe.inputs[i + 1]) end
str = str .. frame:expandTemplate{title = 'item', args = {recipe.inputs[i]}}
--str = str .. string.format("{item|%s}", recipe.inputs[i])
end
end
str = str .. ' || '
if #recipe.outputs == 0 then str = str .. '-' end
for i=1,7,2
do
if recipe.outputs[i] ~= nil then
if i ~= 1 then str = str .. ' + ' end
if recipe.outputs[i + 1] > 1 then str = str .. string.format('%d× ', recipe.outputs[i + 1]) end
str = str .. frame:expandTemplate{title = 'item', args = {recipe.outputs[i]}}
--str = str .. string.format("{item|%s}", recipe.outputs[i])
end
end
str = str .. ' || '
if string.find(recipe.frequency, '*') then
str = str .. '<span title="Duration is capped at 30 days" style="border-bottom:1px dotted">' .. recipe.duration .. '</span>'
.. ' || <span title="Nb per year is capped at 10" style="border-bottom:1px dotted">' .. recipe.frequency:sub(0, #recipe.frequency - 1) .. '</span>'
else str = str .. recipe.duration .. ' || ' .. recipe.frequency end
if recipe.pop ~= nil then str = str .. ' || ' .. recipe.pop end
return str .. '\n'
end
function CreateTableContent(frame, name, condition, recipes, title)
local tab = {}
local found = false
local needExplanation = false
for i, recipe in ipairs(recipes)
do
if condition(name, recipe)
then
found = true
factory = recipe.factory
if tab[factory] == nil then tab[factory] = CreateTabHeader(factory, frame, recipe.pop ~= nil) end
tab[factory] = tab[factory] .. CreateTableLine(recipe, frame)
end
end
finalStr = ''
for i, factory in pairs(tab)
do
finalStr = finalStr .. factory .. '|}'
--if string.find(factory, '*') ~= nil then finalStr = finalStr .. '<i style="font-size: 80%">* duration is capped at 30 days</i>' end
end
return finalStr, found
end
function p.main(frame, cfg)
local recipes = require('Module:Item_recipes_data')
local name = frame.args[1]
usedTo_table, hasAUse = CreateTableContent(frame, name, HasAUse, recipes, 'using')
madeWith_table, isMadeWith = CreateTableContent(frame, name, IsMadeWith, recipes, 'producing')
produces_table, produce = CreateTableContent(frame, name, Produces, recipes, 'made by')
str = ''
if isMadeWith then str = str .. '\n==How to make it==\n' .. madeWith_table end
if hasAUse then str = str .. '\n==What to make from it==\n' .. usedTo_table end
if produce then str = str .. '\n==What it can make==\n' .. produces_table end
return str:sub(2) -- removing first charachter which is a breakline
end
return p