trusted
167
edits
(Show fractionator percentage instead of time, possibly add infobox recipes?) |
(Add support for oil seeps and oceans (water pumps)) |
||
Line 13: | Line 13: | ||
Mine='Mining Machine', | Mine='Mining Machine', | ||
Gas='Orbital Collector', | Gas='Orbital Collector', | ||
Ocean='Water Pump', | |||
Oil='Oil Extractor', | |||
} | } | ||
local OilSeepID = 7 | |||
function funcs.recipesMaking(frame) | function funcs.recipesMaking(frame) | ||
Line 28: | Line 31: | ||
local vein = veinMakingByID(item.ID) | local vein = veinMakingByID(item.ID) | ||
local gas = deduplicateGiants(gasGiantsMakingByID(item.ID)) | local gas = deduplicateGiants(gasGiantsMakingByID(item.ID)) | ||
return tableRecipes(item, recipes, vein, gas, frame) | local isocean = isItemOcean(item.ID) | ||
return tableRecipes(item, recipes, vein, gas, isocean, frame) | |||
end | end | ||
Line 45: | Line 49: | ||
if next(components) then | if next(components) then | ||
table.insert(output, '=== Components ===') | table.insert(output, '=== Components ===') | ||
table.insert(output, tableRecipes(item, components, nil, nil, frame)) | table.insert(output, tableRecipes(item, components, nil, nil, false, frame)) | ||
end | end | ||
if next(buildings) then | if next(buildings) then | ||
table.insert(output, '=== Buildings ===') | table.insert(output, '=== Buildings ===') | ||
table.insert(output, tableRecipes(item, buildings, nil, nil, frame)) | table.insert(output, tableRecipes(item, buildings, nil, nil, false, frame)) | ||
end | end | ||
return table.concat(output, '\n') | return table.concat(output, '\n') | ||
Line 77: | Line 81: | ||
end | end | ||
function tableRecipes(item, recipes, vein, gas, frame) | function funcs.itemField(frame) | ||
return itemFieldByName(frame:getParent().args[1], frame:getParent().args[2]) | |||
end | |||
function funcs.itemFieldDirect(frame) | |||
return itemFieldByName(frame.args[1], frame.args[2]) | |||
end | |||
function itemFieldByName(itemname, fieldname) | |||
local item = itemByName(itemname) | |||
return item[fieldname] | |||
end | |||
function tableRecipes(item, recipes, vein, gas, isocean, frame) | |||
local result = {} | local result = {} | ||
for _, recipe in pairs(recipes) do | for _, recipe in pairs(recipes) do | ||
Line 97: | Line 113: | ||
table.insert(result, '| ' .. frame:expandTemplate{title='ProductionChain', args=data}) | table.insert(result, '| ' .. frame:expandTemplate{title='ProductionChain', args=data}) | ||
end | end | ||
if vein then | if vein and vein.ID == OilSeepID then -- I don't have a better test for oil right now | ||
local extractor = itemByName(machines.Oil) | |||
local extractorTech = technologyForRecipeID(recipesMakingByID(extractor.ID)[1].ID) | |||
local oildata = { | |||
Building = titleCase(extractor.Name), | |||
Replicator = 'No', | |||
Technology = titleCase(extractorTech.Name), | |||
Recipe = oilRecipe(item, vein, frame), | |||
} | |||
table.insert(result, '| ' .. frame:expandTemplate{title='ProductionChain', args=oildata}) | |||
elseif vein then | |||
local miner = itemByName(machines.Mine) | local miner = itemByName(machines.Mine) | ||
local minerTech = technologyForRecipeID(recipesMakingByID(miner.ID)[1].ID) | local minerTech = technologyForRecipeID(recipesMakingByID(miner.ID)[1].ID) | ||
Line 120: | Line 146: | ||
table.insert(result, '| ' .. frame:expandTemplate{title='ProductionChain', args=gasdata}) | table.insert(result, '| ' .. frame:expandTemplate{title='ProductionChain', args=gasdata}) | ||
end | end | ||
end | |||
if isocean then | |||
local pump = itemByName(machines.Ocean) | |||
local pumpTech = technologyForRecipeID(recipesMakingByID(pump.ID)[1].ID) | |||
local oceandata = { | |||
Building = titleCase(pump.Name), | |||
Replicator = 'No', | |||
Technology = titleCase(pumpTech.Name), | |||
Recipe = oceanRecipe(item, frame) | |||
} | |||
table.insert(result, '| ' .. frame:expandTemplate{title='ProductionChain', args=oceandata}) | |||
end | end | ||
local prefix = frame:expandTemplate{title='ProductionChainTable/head', args={}} | local prefix = frame:expandTemplate{title='ProductionChainTable/head', args={}} | ||
Line 169: | Line 206: | ||
} | } | ||
return frame:expandTemplate{title='ItemRecipe', args=idata} | return frame:expandTemplate{title='ItemRecipe', args=idata} | ||
end | |||
function oilRecipe(item, vein, frame) | |||
local odata = { | |||
In1 = titleCase(vein.Name), | |||
In1Qty = '', | |||
Out1 = titleCase(item.Name), | |||
Out1Qty = '1', | |||
CraftTime = '?', | |||
} | |||
return frame:expandTemplate{title='ItemRecipe', args=odata} | |||
end | end | ||
Line 183: | Line 231: | ||
end | end | ||
return frame:expandTemplate{title='ItemRecipe', args=gdata} | return frame:expandTemplate{title='ItemRecipe', args=gdata} | ||
end | |||
function oceanRecipe(item, frame) | |||
local odata = { | |||
CraftTime = '1.2 s', | |||
Out1 = titleCase(item.Name), | |||
Out1Qty = 1, | |||
} | |||
return frame:expandTemplate{title='ItemRecipe', args=odata} | |||
end | end | ||
Line 264: | Line 321: | ||
end | end | ||
return giants | return giants | ||
end | |||
function isItemOcean(id) | |||
for _, planet in pairs(protosets.ThemeProtoSet.dataArray) do | |||
if id == planet.WaterItemId then | |||
return true | |||
end | |||
end | |||
return false | |||
end | end | ||