Module:Infobox Recipe/Sandbox: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(implement kp, put it next to xp)
(set to current version of main infobox)
 
Line 85: Line 85:


--Set SMW properties
--Set SMW properties
local smw_properties = {
for _,material in ipairs(argsMaterials) do
['Uses item'] = {},
mw.smw.set({
["Uses item"] = material.name,
['Uses item and quantity'] = {},
-- these are for when a recipe is called by a subsequent recipe that uses showFull
["Uses item_and_quantity"] = material.name .. ',' .. tostring(material.quantity)
['Uses facility'] = args.facility,
})
-- not implemented yet, for adding to duration if showfull is true
end
['Uses duration'] = args.duration,
}
-- these are for when a recipe is called by a subsequent recipe that uses showFull
for _, material in ipairs(argsMaterials) do
if args.facility then
table.insert(smw_properties['Uses item'], material.name)
mw.smw.set({
table.insert(smw_properties['Uses item and quantity'], ('%s,%s'):format(material.name, material.quantity))
["Uses facility"] = args.facility
})
end
-- not implemented yet, for addin to duration if showfull is true
if args.duration then
mw.smw.set({
["has duration"] = args.duration
})
end
if args.kp then
mw.smw.set({
["has kp"] = args.kp
})
end
end

mw.smw.set(smw_properties)


--Creates a row suitable for the raw materials section of the infobox.
--Creates a row suitable for the raw materials section of the infobox.
Line 222: Line 212:
:attr{ colspan = '5' }
:attr{ colspan = '5' }
:css{ ['text-align'] = 'center' }
:css{ ['text-align'] = 'center' }
:wikitext(hc(args.kp) and (args.kp) or editButton("'''?''' (edit)"))
:wikitext(hc(args.kp) and ('%s%%'):format(args.kp) or editButton("'''?''' (edit)"))
:done()
:done()
:tag('td')
:tag('td')
:attr{ colspan = '5' }
:attr{ colspan = '5' }
:css{ ['text-align'] = 'center' }
:css{ ['text-align'] = 'center' }
:wikitext(hc(args.xp) and (args.xp) or editButton("'''?''' (edit)"))
:wikitext(hc(args.exp) and (args.exp) or editButton("'''?''' (edit)"))
:done()
:done()
:done()
:done()