Fortnite Esports Wiki
No edit summary
m (Reverted edits by Donut (talk) to last revision by RheingoldRiver)
Line 3: Line 3:
 
function p.team ( frame )
 
function p.team ( frame )
 
local args = frame
 
local args = frame
  +
local text = ''
 
if frame == mw.getCurrentFrame() then
 
if frame == mw.getCurrentFrame() then
 
args = require( 'Module:ProcessArgs' ).merge( true )
 
args = require( 'Module:ProcessArgs' ).merge( true )
Line 8: Line 9:
 
frame = mw.getCurrentFrame()
 
frame = mw.getCurrentFrame()
 
end
 
end
  +
 
 
local teaminput = mw.ustring.lower(args[1] or '')
 
local teaminput = mw.ustring.lower(args[1] or '')
local teamstyle = mw.ustring.lower(args[2] or 'rightlonglinked')
+
local teamstyle = mw.ustring.lower(args[2] or 'default')
 
local size = args['size']
 
 
local exceptionCases = mw.loadData('Module:Teamexceptions')
+
local exceptionCases = mw.loadData( 'Module:Teamexceptions' )
 
 
 
--Empty
 
--Empty
Line 20: Line 22:
 
--Special Cases
 
--Special Cases
 
elseif exceptionCases[teaminput] then
 
elseif exceptionCases[teaminput] then
namevars = exceptionCases[teaminput]
+
exception = exceptionCases[teaminput]
Styles = require('Module:Teamexceptionstyles')
+
tstyles = mw.loadData( 'Module:Teamexceptionstyles' )
 
 
settings = Styles.styleNames(teamstyle)
+
text = tstyles[teamstyle]
 
 
if args['size'] then settings.size = args['size'] end
+
if not size then
  +
text = text:gsub("REPLACESIZE","")
  +
else
  +
text = text:gsub("REPLACESIZE(%d+)px",size)
  +
end
  +
  +
text = text:gsub("REPLACE(%u+)", { ["TEXT"] = exception["text"], ["SHORT"] = exception["text"], ["FILE"] = exception["image"], ["TITLE"] = exception["hover"] })
 
 
  +
return text
return Styles[settings.style](namevars, settings)
 
 
 
 
-- Normal Teams
 
-- Normal Teams
 
else
 
else
local tnames = mw.loadData('Module:Teamnames')
+
local tnames = mw.loadData( 'Module:Teamnames' )
local Styles = require('Module:Teamstyles')
 
 
local namevars = tnames[teaminput]
 
local namevars = tnames[teaminput]
local settings = {
+
local logo = ""
size = args['size']
 
}
 
   
 
if not namevars then
 
if not namevars then
namevars = { link = args[1], long = args[1], medium = args[1], short = args['short'] or args[1] }
+
namevars = {link = args[1], long = args[1], medium = args[1], short = args['short'] or args[1] }
settings.logo = ""
 
 
elseif type(namevars) == 'string' then
 
elseif type(namevars) == 'string' then
 
namevars = tnames[namevars]
 
namevars = tnames[namevars]
  +
logo = namevars.link:gsub("+", " ")
  +
else
  +
logo = namevars.link:gsub("+", " ")
  +
end
  +
 
local tstyles = mw.loadData('Module:Teamstyles')
  +
  +
text = tstyles[teamstyle]
  +
  +
if not size then
  +
text = text:gsub("REPLACESIZE","")
  +
else
  +
text = text:gsub("REPLACESIZE(%d+)px",size)
 
end
 
end
 
 
  +
text = text:gsub("REPLACE(%u+)", { ["LINK"] = namevars.link, ["LONG"] = namevars.long, ["MEDIUM"] = namevars.medium, ["SHORT"] = namevars.short, ["FILE"] = logo })
return Styles[teamstyle](namevars, settings)
 
 
 
  +
return text
  +
  +
 
end
 
end
 
end
 
end

Revision as of 16:00, 15 August 2018

Documentation for this module may be created at Module:Team/doc

local p = {}

function p.team ( frame )
	local args = frame 
	local text = ''
	if frame == mw.getCurrentFrame() then
		args = require( 'Module:ProcessArgs' ).merge( true )
	else
		frame = mw.getCurrentFrame()
	end

	local teaminput = mw.ustring.lower(args[1] or '')
	local teamstyle = mw.ustring.lower(args[2] or 'default')
	local size = args['size']
		
	local exceptionCases = mw.loadData( 'Module:Teamexceptions' )
	
	--Empty
	if not args[1] or args[1] == '' then
		return ''	
	
	--Special Cases
	elseif exceptionCases[teaminput] then
		exception = exceptionCases[teaminput]
		tstyles = mw.loadData( 'Module:Teamexceptionstyles' )
		
		text = tstyles[teamstyle]
		
		if not size then
			text = text:gsub("REPLACESIZE","")
		else
			text = text:gsub("REPLACESIZE(%d+)px",size)
		end
		
		text = text:gsub("REPLACE(%u+)", { ["TEXT"] = exception["text"], ["SHORT"] = exception["text"], ["FILE"] = exception["image"], ["TITLE"] = exception["hover"] })
		
		return text
	
	-- Normal Teams	
	else	
		local tnames = mw.loadData( 'Module:Teamnames' )
		local namevars = tnames[teaminput]
		local logo = ""

		if not namevars then
			namevars = {link = args[1], long = args[1], medium = args[1], short = args['short'] or args[1] }
		elseif type(namevars) == 'string' then
			namevars = tnames[namevars]
			logo = namevars.link:gsub("+", " ")
		else
			logo = namevars.link:gsub("+", " ")
		end	
		
		local tstyles = mw.loadData('Module:Teamstyles')
		
		text = tstyles[teamstyle]
		
		if not size then
			text = text:gsub("REPLACESIZE","")
		else
			text = text:gsub("REPLACESIZE(%d+)px",size)
		end
		
		text = text:gsub("REPLACE(%u+)", { ["LINK"] = namevars.link, ["LONG"] = namevars.long, ["MEDIUM"] = namevars.medium, ["SHORT"] = namevars.short, ["FILE"] = logo })
		
        return text


	end
end
return p