Difference between revisions of "Module:Infobox"
Jump to navigation
Jump to search
m (Loaded Module:Arguments) |
m (Added item infobox) |
||
Line 8: | Line 8: | ||
local args = getArgs(frame, {inherited = true}) | local args = getArgs(frame, {inherited = true}) | ||
return p._block(args) | return p._block(args) | ||
+ | end | ||
+ | |||
+ | function p.item(frame) | ||
+ | local args = getArgs(frame, {inherited = true}) | ||
+ | return p._item(args) | ||
end | end | ||
Line 20: | Line 25: | ||
name = args.name or args.block_name or "A block", | name = args.name or args.block_name or "A block", | ||
image = args.image, | image = args.image, | ||
+ | imageSize = "150px", | ||
description = "A [[Blocks|block]]", | description = "A [[Blocks|block]]", | ||
wherein = args.wherein, | wherein = args.wherein, | ||
Line 31: | Line 37: | ||
addInfoRow(infobox, "'''[[:Category:Generated_blocks|Generated]]'''", args.generated or "Yes") | addInfoRow(infobox, "'''[[:Category:Generated_blocks|Generated]]'''", args.generated or "Yes") | ||
addInfoRow(infobox, "'''Renewable'''", args.renewable or "No") | addInfoRow(infobox, "'''Renewable'''", args.renewable or "No") | ||
+ | addInfoRow(infobox, "'''Stackable'''", args.stackable or "Yes (99)") | ||
+ | addInfoRow(infobox, "'''[[Itemstrings|Itemstring]]'''", args.itemstring or "''?''") | ||
+ | return tostring(infobox) | ||
+ | end | ||
+ | |||
+ | function p._item(args) | ||
+ | local infobox = p.infobox({ | ||
+ | name = args.name or args.item_name or "An item", | ||
+ | image = args.image, | ||
+ | imageSize = "160px", | ||
+ | description = "A [[Items|item]]", | ||
+ | wherein = args.wherein, | ||
+ | width = args.width | ||
+ | }) | ||
+ | addInfoRow(infobox, "'''Type'''", args.type or args.item_type or "Craftitem") | ||
+ | addInfoRow(infobox, "'''Renewable'''", args.renewable or "No") | ||
+ | addInfoRow(infobox, "'''Durability'''", args.durability or "''N/A''") | ||
addInfoRow(infobox, "'''Stackable'''", args.stackable or "Yes (99)") | addInfoRow(infobox, "'''Stackable'''", args.stackable or "Yes (99)") | ||
addInfoRow(infobox, "'''[[Itemstrings|Itemstring]]'''", args.itemstring or "''?''") | addInfoRow(infobox, "'''[[Itemstrings|Itemstring]]'''", args.itemstring or "''?''") | ||
Line 41: | Line 64: | ||
local description = args.description .. " in " .. (args.wherein or "[[Subgames/Minetest Game|Minetest Game]]") | local description = args.description .. " in " .. (args.wherein or "[[Subgames/Minetest Game|Minetest Game]]") | ||
local image = args.image or "Minetest logo.png" | local image = args.image or "Minetest logo.png" | ||
+ | local imageSize = args.imageSize | ||
local imageText | local imageText | ||
if string.match(image, ",") then | if string.match(image, ",") then | ||
− | imageText = animateImages({image, | + | imageText = animateImages({image, imageSize}) |
else | else | ||
− | imageText = "[[File:" .. image .. "| | + | imageText = "[[File:" .. image .. "|" .. imageSize .. "]]" |
end | end | ||
return HtmlBuilder.create("table") | return HtmlBuilder.create("table") |
Revision as of 00:38, 11 April 2017
local p = {}
local HtmlBuilder = require("Module:HtmlBuilder") local animateImages = require("Module:Animated")._images local getArgs = require('Module:Arguments').getArgs
function p.block(frame)
local args = getArgs(frame, {inherited = true}) return p._block(args)
end
function p.item(frame)
local args = getArgs(frame, {inherited = true}) return p._item(args)
end
local function addInfoRow(infobox, name, info)
local row = infobox:tag("tr") row:tag("td"):wikitext(name) row:tag("td"):wikitext(info)
end
function p._block(args)
local infobox = p.infobox({ name = args.name or args.block_name or "A block", image = args.image, imageSize = "150px", description = "A block", wherein = args.wherein, width = args.width }) addInfoRow(infobox, "Type", args.type or args.block_type or "Solid block") addInfoRow(infobox, "Drops", args.drops or "Itself") addInfoRow(infobox, "Physics", args.physics or "No") addInfoRow(infobox, "Luminance", args.luminance or "No") addInfoRow(infobox, "Flammable", args.flammable or "No") addInfoRow(infobox, "Generated", args.generated or "Yes") addInfoRow(infobox, "Renewable", args.renewable or "No") addInfoRow(infobox, "Stackable", args.stackable or "Yes (99)") addInfoRow(infobox, "Itemstring", args.itemstring or "?") return tostring(infobox)
end
function p._item(args)
local infobox = p.infobox({ name = args.name or args.item_name or "An item", image = args.image, imageSize = "160px", description = "A item", wherein = args.wherein, width = args.width }) addInfoRow(infobox, "Type", args.type or args.item_type or "Craftitem") addInfoRow(infobox, "Renewable", args.renewable or "No") addInfoRow(infobox, "Durability", args.durability or "N/A") addInfoRow(infobox, "Stackable", args.stackable or "Yes (99)") addInfoRow(infobox, "Itemstring", args.itemstring or "?") return tostring(infobox)
end
function p.infobox(args)
local name = args.name local width = args.width or "200px" local description = args.description .. " in " .. (args.wherein or "Minetest Game") local image = args.image or "Minetest logo.png" local imageSize = args.imageSize local imageText if string.match(image, ",") then imageText = animateImages({image, imageSize}) else imageText = "" .. imageSize .. "" end return HtmlBuilder.create("table") :addClass("wikitable") :css("float", "right") :css("text-align", "left") :css("margin", "0 0 0.5em 1em") :css("padding", "5px") :css("font-size", "90%") :css("position", "relative") :css("clear", "right") :css("overflow", "auto") :css("z-index", "1") :attr("width", width) :tag("tr") :tag("th") :attr("colspan", 2) :css("font-size", "110%") :css("text-align", "center") :wikitext(name) :done() :done() :tag("tr") :tag("th") :attr("colspan", 2) :tag("div") :addClass("center") :wikitext(imageText) :done() :done() :done() :tag("tr") :tag("th") :attr("colspan", 2) :attr("align", "center") :wikitext(description) :allDone()
end
return p