Mobius Final Fantasy Wiki
mNo edit summary
No edit summary
 
(40 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
local p = {}
 
local p = {}
  +
local getArgs = require("Module:Arguments").getArgs
 
 
local util = require( 'Module:Utils' )
 
local util = require( 'Module:Utils' )
 
local aa = mw.loadData( 'Module:AutoAbilities/data' )
 
local aa = mw.loadData( 'Module:AutoAbilities/data' )
Line 7: Line 7:
 
green = "Icon Auto-Abilities Green.png",
 
green = "Icon Auto-Abilities Green.png",
 
blue = "Icon Auto-Abilities Blue.png",
 
blue = "Icon Auto-Abilities Blue.png",
yellox = "Icon Auto-Abilities Yellow.png",
+
yellow = "Icon Auto-Abilities Yellow.png",
  +
locked = "Icon Auto-Abilities Locked.png",
 
unknown = "Icon question.png"
 
unknown = "Icon question.png"
 
}
 
}
   
 
function p.getColor( name )
 
function p.getColor( name )
  +
local c = icons.unknown
 
for color, v in pairs( aa ) do
 
for color, v in pairs( aa ) do
 
for k, desc in pairs( v ) do
 
for k, desc in pairs( v ) do
if k == name then return icons[color] end
+
if k == name then c = icons[color]; break end
 
end
 
end
 
end
 
end
return icons.unknown
+
return c
 
end
 
end
   
function p.getDescription( name )
+
function p._formatString( str, size )
  +
local size = size or "18px"
for color, v in pairs( aa ) do
 
 
local t = mw.text.split( str, "+" )
for k, desc in pairs( v ) do
 
 
local img = "[[File:" .. p.getColor( mw.text.trim(t[1]) ) .. "|" .. size .. "]] "
if k == name then return desc
 
  +
if #t == 1 and img == "[[File:Icon question.png|18px]] " then
else return ""
 
  +
t = mw.text.split( str, "%(" )
end
 
  +
img = "[[File:" .. p.getColor( mw.text.trim(t[1]) ) .. "|" .. size .. "]] "
 
if #t == 1 then
 
return img .. '[['..t[1]..']]'
 
else
 
return img .. '[['..t[1]..']]' .. "(" .. t[2]
 
end
 
end
 
end
 
if #t == 1 then
  +
return img .. '[['..t[1]..']]'
  +
else
  +
return img .. '[['..t[1]..']]' .. " +" .. t[2]
 
end
 
end
 
end
 
end
   
function p.formatString( str, size )
+
function p.formatString(frame)
local size = size or "20px"
+
local args = getArgs(frame)
  +
return p._formatString(args[1], args.size)
local aa = util.explode( '+', str )
 
local img = "[[File:" .. p.getColor( aa[1] ) .. "|" .. size .. "]] "
 
if #aa == 1 then
 
return img .. aa[1]
 
else
 
return img .. aa[1] .. " +" .. aa[2]
 
end
 
 
end
 
end
   

Latest revision as of 10:35, 9 August 2019


local p = {}
local getArgs = require("Module:Arguments").getArgs
local util = require( 'Module:Utils' )
local aa = mw.loadData( 'Module:AutoAbilities/data' )
local icons = {
	red = "Icon Auto-Abilities Red.png",
	green = "Icon Auto-Abilities Green.png",
	blue = "Icon Auto-Abilities Blue.png",
	yellow = "Icon Auto-Abilities Yellow.png",
	locked = "Icon Auto-Abilities Locked.png",
	unknown = "Icon question.png"
}

function p.getColor( name )
	local c = icons.unknown
	for color, v in pairs( aa ) do
		for k, desc in pairs( v ) do
			if k == name then c = icons[color]; break end
		end
	end
	return c
end

function p._formatString( str, size )
	local size = size or "18px"
	local t = mw.text.split( str, "+" )
	local img = "[[File:" .. p.getColor(  mw.text.trim(t[1]) ) .. "|" .. size .. "]] "
	if #t == 1 and img == "[[File:Icon question.png|18px]] "  then
		t = mw.text.split( str, "%(" )
		img =  "[[File:" .. p.getColor(  mw.text.trim(t[1]) ) .. "|" .. size .. "]] "
		if #t == 1 then
			return img .. '[['..t[1]..']]'
		else
			return img .. '[['..t[1]..']]' .. "(" .. t[2]
		end
	end
	if #t == 1 then
		return img .. '[['..t[1]..']]'
	else
		return img .. '[['..t[1]..']]' .. " +" .. t[2]
	end
end

function p.formatString(frame)
	local args = getArgs(frame)
	return p._formatString(args[1], args.size)
end

return p