Module:Infobox Recipe: Difference between revisions
no edit summary
(Link all images to the item/facility; Get rid of border between item image and name) |
The Gaffer (talk | contribs) No edit summary |
||
Line 17:
--Get each of the rawmatX parameters from params and store their values in a new table
local argsMaterials = p._extractRawMaterials(args)
--mw.logObject(argsMaterials)
--empty tables to hold materials
local rawMaterials = {}
Line 27 ⟶ 28:
local output1Value = args.output1 and mw.smw.ask('[[:+]][[' .. args.output1 .. ']]|?Value|limit=1')
local output1TotalValue = 0
if output1Value[1]['Value'] ~= nil then
output1TotalValue = output1Value[1]['Value'] * (tonumber(args.output1qty) or 1)
Line 36:
--Check if any of the raw mats provided are intermediate products, if they are, return their own raw materials
if showFullRecipe then
local
if next(
rawMaterials =
intermediateMaterials = argsMaterials▼
intermediateMaterials = Materials.intermediateMaterials
end
else
rawMaterials = argsMaterials
end
--Simple query to get the shop buy price for the provided material, if no buy price is available returns 0
local function getBuyPrice(material)
Line 300 ⟶ 301:
function p._getTrueRawMaterials(argsMaterials)
local
for _, item in pairs(argsMaterials) do
if item["name"] then
Line 306 ⟶ 309:
if result and result[1] and result[1]["Uses item"] then
-- The item is an intermediate material, add it to intermediateMaterials
table.insert(intermediateMaterials, { ["name"] = item["name"], ["quantity"] = item["quantity"] })
-- Add the raw materials used by this intermediate material to rawMaterials
local usesItems = result[1]["Uses item"]
if type(usesItems) == "table" then
for _, usedItem in ipairs(usesItems) do
local pageName = usedItem:gsub("%[%[", ""):gsub("%]%]", ""):gsub("|.*", ""):gsub("^:", "")
table.insert(
end
else
local pageName = usesItems:gsub("%[%[", ""):gsub("%]%]", ""):gsub("|.*", ""):gsub("^:", "")
table.insert(
end
else
-- The item is a raw material, add it to rawMaterials
table.insert(rawMaterials, { ["name"] = item["name"], ["quantity"] = item["quantity"] })
end
end
end
return { rawMaterials = rawMaterials, intermediateMaterials = intermediateMaterials }
end
|