Module:Sandbox: Difference between revisions

m
Replaced content with "local p = {} function p.hello( frame ) return "Hello, world!" end return p"
mNo edit summary
m (Replaced content with "local p = {} function p.hello( frame ) return "Hello, world!" end return p")
Tag: Replaced
Line 2: Line 2:


function p.hello( frame )
function p.hello( frame )
     return "'''Hello, world!'''"
     return "Hello, world!"
end
 
function p.pmitem(frame)
local args = frame.args
local game = args.game or "PM"
local item = args[2] or args[1]
local link = args.link or args[1]
local text = args.text or item
local imageSize = args.size
if imageSize == nil then
if game == "TTYD" then
imageSize = "25x25px"
elseif game ~= "PM" and game ~= "SPM" then
imageSize = "50x50px"
end
end
local imagePrefix = ""
if game == "PM" then
imagePrefix = "PaperMario Items "
elseif game == "PMCS" then
imagePrefix = "PMCS Item "
end
local imageSuffix = ""
if game == "TTYD" or game == "SPM" then
imageSuffix = " " .. game
elseif game == "PMSS" then
imageSuffix = " Sticker PMSS"
elseif game == "PMTOK" then
imageSuffix = " PMTOK icon"
end
local imageBase = args.item or item
if game == "PMTOK" and imageBase == "Spring of Rainbows - VIP" then
imageBase = "Spring of Rainbows VIP"
else
imageBase = string.gsub(imageBase, "é", "e")
imageBase = string.gsub(imageBase, "×", "x")
imageBase = string.gsub(imageBase, "[.,'?!]", "")
imageBase = string.gsub(imageBase, '"', "")
if game == "PM" then
imageBase = string.gsub(imageBase, " ", "")
end
end
local image = "[[File:" .. imagePrefix .. imageBase .. imageSuffix .. ".png"
if imageSize ~= nil then
image = image .. "|" .. imageSize
end
image = image .. "|link=" .. link .. "]]"
local wikitext = args.wikitext
if wikitext == nil and text ~= "" then
local color = args.color
if link ~= "" then
if color ~= nil and color ~= "" then
wikitext = "{{color-link-piped|" .. link .. "|" .. color .. "|" .. text .. "}}"
else
wikitext = "[[" .. link .. "|" .. text .. "]]"
end
else
if color ~= nil and color ~= "" then
wikitext = '<span style="color:' .. color .. '">' .. text .. '</span>'
else
wikitext = text
end
end
end
if wikitext ~= nil then
local sep = args.sep or " "
local right = args.right
if right ~= nil and right ~= "" then
wikitext = wikitext .. sep .. image
else
wikitext = image .. sep .. wikitext
end
else
wikitext = image
end
return frame:expandTemplate { title = 'nowrap', args = { wikitext } }
end
end


return p
return p