Module:Test
From Bulbapedia, the community-driven Pokémon encyclopedia.
Jump to navigationJump to search
Documentation for this module may be created at Module:Test/doc
Script error: Lua error: Internal error: The interpreter exited with status 127.
--[[ This is just a module for showcase! It doesn't do anything useful. ]] local p = {} function p.divisor(frame) -- need to convert dividend to a number because technically -- all forms of wikitext are strings -- also, this "or" here is a fallback value local dividend = tonumber(frame.args[1]) or 1 local list = mw.html.create("div") if dividend == 0 then list:tag("p"):wikitext("0 has no divisors!") else list :tag("p"):wikitext("The divisors for " .. dividend .. " are:"):done() :tag("ul") for i = 1, dividend do if dividend % i == 0 then list:tag("li"):wikitext(i) end end end return tostring(list) end local colors = { attack = { regular = "efcc18", dark = "9b8510", light = "f5de69", }, defense = { regular = "e86412", dark = "97410c", light = "f09a65", }, hp = { regular = "69dc12", dark = "448f0c", light = "9ee865", }, spattack = { regular = "14c3f1", dark = "0d7f9d", light = "66d8f6", }, spdefense = { regular = "4a6adf", dark = "304591", light = "899eea", }, speed = { regular = "d51dad", dark = "8b1370", light = "e46cca", }, } function p.colors(frame) local color = frame.args["color"] or frame.args[1] or "attack" local shade = frame.args["shade"] or frame.args[2] or "regular" return tostring(colors[color][shade]) end function p.listcolors() local container = mw.html.create("div") for color, group in pairs(colors) do container :tag("p"):wikitext(color .. " colors:"):done() :tag("ul") for shade, value in pairs(group) do container :tag("li") :wikitext(shade .. ": ") :tag("span") :css("background-color", "#" .. value) :css("padding", "2px 5px") :wikitext(value) :done() end end return tostring(container) end return p