Module:Infobox Recipe: Difference between revisions
reorder sections so SMW properties are set earlier in the module
Tag: Undo |
(reorder sections so SMW properties are set earlier in the module) |
||
Line 27:
--If set to true, will check if any of the items passed as a rawmaterialparam are actually intermediate materials. Will then change the display order of the infobox.
local showFullRecipe = yn(args.showFull or 'no', false)
--Get each of the rawmatX parameters from params and store their values in a new table
Line 55 ⟶ 54:
end
--Set SMW properties early, so latter parts can potentially use it.
local smw_properties = {▼
['Uses item'] = {},▼
-- these are for when a recipe is called by a subsequent recipe that uses showFull▼
['Uses facility'] = args.facility,▼
-- these are for generating tables of profession xp rates and profits▼
['Activity XP'] = args.exp,▼
['Activity album XP'] = album_xp_data[tonumber(args.level)],▼
['Activity KP'] = args.kp,▼
['Activity duration'] = args.duration,▼
['Recipe JSON'] = mw.text.jsonEncode({▼
xp = args.exp and tonumber(args.exp),▼
kp = args.kp and tonumber(args.kp),▼
duration = args.duration,▼
materials = argsMaterials,▼
profession = args.profession,▼
level = args.level and tonumber(args.level),▼
-- Make sure to update this when multiple outputs are supported▼
output = {▼
{ name = args.output1, quantity = tonumber(args.output1qty) or 1 },▼
}▼
}),▼
-- Make sure to update this when multiple outputs are supported to be a list of all outputs▼
['Recipe output'] = { args.output1 }▼
}▼
for _, material in ipairs(argsMaterials) do▼
table.insert(smw_properties['Uses item'], material.name)▼
end▼
mw.smw.set(smw_properties)▼
Line 106 ⟶ 136:
album_xp = formatNum(album_xp)..' xp'
end
▲ local smw_properties = {
▲ ['Uses item'] = {},
▲ -- these are for when a recipe is called by a subsequent recipe that uses showFull
▲ ['Uses facility'] = args.facility,
▲ -- these are for generating tables of profession xp rates and profits
▲ ['Activity XP'] = args.exp,
▲ ['Activity album XP'] = album_xp_data[tonumber(args.level)],
▲ ['Activity KP'] = args.kp,
▲ ['Activity duration'] = args.duration,
▲ ['Recipe JSON'] = mw.text.jsonEncode({
▲ xp = args.exp and tonumber(args.exp),
▲ kp = args.kp and tonumber(args.kp),
▲ duration = args.duration,
▲ materials = argsMaterials,
▲ profession = args.profession,
▲ level = args.level and tonumber(args.level),
▲ -- Make sure to update this when multiple outputs are supported
▲ output = {
▲ { name = args.output1, quantity = tonumber(args.output1qty) or 1 },
▲ }
▲ }),
▲ -- Make sure to update this when multiple outputs are supported to be a list of all outputs
▲ ['Recipe output'] = { args.output1 }
▲ }
▲ for _, material in ipairs(argsMaterials) do
▲ table.insert(smw_properties['Uses item'], material.name)
▲ end
▲ mw.smw.set(smw_properties)
--Creates a row suitable for the raw materials section of the infobox.
|