Mobius Final Fantasy Wiki
(using already implemented ucfirst, rather than rolling our own.)
(simplifying module as icon only.)
Line 1: Line 1:
 
local p = {}
 
local p = {}
 
local getArgs = require("Module:Arguments").getArgs
 
local util = require( 'Module:Utils' )
 
local lang = mw.getLanguage('en')
 
   
 
function p.main( frame )
 
function p.main( frame )
local element = frame.args[1]
+
local args = getArgs(frame, {
  +
wrappers = "Template:Orb"
local size = frame.args[2] or "20px"
 
  +
})
local text = lang:ucfirst( element )
 
  +
return p._main(args)
local color = ""
 
  +
end
local orb = "[[File:" .. element .. "_Icon.png|link=|" .. size .. "]]"
 
  +
function p._main( args )
if frame.args.color then color = element end
 
 
local element = lower(args[1] or "")
if frame.args.text then
 
  +
local size = tonumber(args.size) or 20
orb = orb .. " " .. util.colorText( text, color )
 
 
local icon, name
  +
  +
if element == "fire" then
  +
icon = "Fire Icon.png"
  +
name = "[FIRE]"
  +
elseif element == "water" then
  +
icon = "Water Icon.png"
  +
name = "[WATER]"
  +
elseif element == "wind" then
  +
icon = "Wind Icon.png"
  +
name = "[WIND]"
  +
elseif element == "earth" then
  +
icon = "Earth Icon.png"
  +
name = "[EARTH]"
  +
elseif element == "light" then
  +
icon = "Light Icon.png"
  +
name = "[LIGHT]"
  +
elseif element == "dark" then
  +
icon = "Dark Icon.png"
  +
name = "[DARK]"
  +
elseif element == "restoration" or element == "life" then
  +
icon = "Life Icon.png"
  +
name = "[LIFE]"
  +
elseif element == "prismatic" then
  +
icon = "Prismatic Icon.png"
  +
name = "[PRISMATIC]"
  +
elseif element == "none" then
  +
icon = "None Icon.png"
  +
name = "[NONE]"
 
end
 
end
  +
local fmt = "[[File:%s|link=|%spx|%s]]"
return orb
 
  +
return string.format(fmt, icon, size, name)
 
end
 
end
   

Revision as of 13:52, 1 June 2018


local p = {}
local getArgs = require("Module:Arguments").getArgs

function p.main( frame )
	local args = getArgs(frame, {
		wrappers = "Template:Orb"
	})
	return p._main(args)
end
function p._main( args )
	local element = lower(args[1] or "")
	local size = tonumber(args.size) or 20
	local icon, name
	
	if element == "fire" then
		icon = "Fire Icon.png"
		name = "[FIRE]"
	elseif element == "water" then
		icon = "Water Icon.png"
		name = "[WATER]"
	elseif element == "wind" then
		icon = "Wind Icon.png"
		name = "[WIND]"
	elseif element == "earth" then
		icon = "Earth Icon.png"
		name = "[EARTH]"
	elseif element == "light" then
		icon = "Light Icon.png"
		name = "[LIGHT]"
	elseif element == "dark" then
		icon = "Dark Icon.png"
		name = "[DARK]"
	elseif element == "restoration" or element == "life" then
		icon = "Life Icon.png"
		name = "[LIFE]"
	elseif element == "prismatic" then
		icon = "Prismatic Icon.png"
		name = "[PRISMATIC]"
	elseif element == "none" then
		icon = "None Icon.png"
		name = "[NONE]"
	end
	local fmt = "[[File:%s|link=|%spx|%s]]"
	return string.format(fmt, icon, size, name)
end

return p