Module:TV: Difference between revisions

From Terra Invicta Official Wiki
Redwah (talk | contribs)
m 76561199014279152 moved page Module:VT to Module:TV
Redwah (talk | contribs)
No edit summary
Line 1: Line 1:
-- This is a LUA version of the Template:VT page.
-- This is a LUA version of the Template:TV page.
-- The idea is to standardize how Value-Type pairs are presented.
-- The idea is to standardize how Type-Value pairs are presented.


local p = {}
local p = {}


local VTData = mw.loadData('Module:VT/data')
local TVData = mw.loadData('Module:TV/data')


local slower = string.lower
local slower = string.lower
local spanSettings = '<span style="border: 2px solid powderblue; border-radius: 7px; padding: 0px 4px 2px; background-color: black; color: white;">'
local spanSettings = '<span style="border: 2px solid powderblue; border-radius: 7px; padding: 0px 4px 2px; background-color: black; color: white;">'


function p.VT( frame )
function p.TV( frame )
local VTtype = frame.args[1]
local TVtype = frame.args[1]
local VTvalue = frame.args[2]
local TVvalue = frame.args[2]
local VTshort = frame.args[3]
local TVshort = frame.args[3]
if not VTtype then
if not TVtype then
return 'ERROR: No type specified for VT Module'
return 'ERROR: No type specified for TV Module'
end
end
VTtype = slower(VTtype)
TVtype = slower(TVtype)
VTtype = mw.text.trim(VTtype)
TVtype = mw.text.trim(TVtype)
local returnString = spanSettings .. VTvalue .. ' ' .. VTData[VTtype][1]
local returnString = spanSettings .. TVvalue .. ' ' .. TVData[TVtype][1]
if VTshort ~= 'true' then
if TVshort ~= 'true' then
returnString = returnString .. VTData[VTtype][2]
returnString = returnString .. TVData[TVtype][2]
end
end
returnString = returnString .. '</span>'
returnString = returnString .. '</span>'

Revision as of 22:09, 2 January 2026

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

-- This is a LUA version of the Template:TV page.
-- The idea is to standardize how Type-Value pairs are presented.

local p = {}

local TVData = mw.loadData('Module:TV/data')

local slower = string.lower
local spanSettings = '<span style="border: 2px solid powderblue; border-radius: 7px; padding: 0px 4px 2px; background-color: black; color: white;">'

function p.TV( frame )
	local TVtype = frame.args[1]
	local TVvalue = frame.args[2]
	local TVshort = frame.args[3]
	if not TVtype then
		return 'ERROR: No type specified for TV Module'
	end
	TVtype = slower(TVtype)
	TVtype = mw.text.trim(TVtype)
	local returnString = spanSettings .. TVvalue .. ' ' .. TVData[TVtype][1]
	if TVshort ~= 'true' then
		returnString = returnString .. TVData[TVtype][2]
	end
	returnString = returnString .. '</span>'
	return returnString
end

return p