FANDOM


 
-- See [[Module:Special/doc]] for documentation
 
p = {}
 
local statistics = {
	[1] = "Strength",
	[2] = "Perception",
	[3] = "Endurance",
	[4] = "Charisma",
	[5] = "Intelligence",
	[6] = "Agility",
	[7] = "Luck"
}
 
local links = {
	[1] = "[[Strength|ST]]",
	[2] = "[[Perception|PE]]",
	[3] = "[[Endurance|EN]]",
	[4] = "[[Charisma|CH]]",
	[5] = "[[Intelligence|IN]]",
	[6] = "[[Agility|AG]]",
	[7] = "[[Luck|LK]]"
}
 
function tooltip(value, text)
	return '<span class="va-tooltip" style="cursor: help; border-bottom: 1px dotted;" title="' .. text .. ' modified by armor and clothing">' .. value .. '</span>'
end
 
function p.table(frame)
	local value = mw.text.split(frame.args[1], ",")      -- Splits the values into an array
	local modifier = mw.text.split(frame.args[2], ",")   -- Splits the modifiers into an array
	local title = frame.args[3]                                     -- If a game title is declared, this will be transfered to a variable
	local perk = 1                                                 -- Used for readings the arrays
	local result = "<span class='special-shell'>"                   -- Wrapper shell for SPECIAL stats to allow additional CSS handling
 
-- Adds the game title if one has been denoted, otherwise nothing is added.
	if string.len(title) > 0 then
		result = result .. "<div class='special-title'>" .. title .. "</div>"
	end
 
-- Circular script that sets each stat to table cell	
	while perk <= 7 do
	    if tonumber(value[perk]) ~= nil then
       	    thisPerk = tonumber(value[perk])
       	else
       	    thisPerk = 0
       	end
 
		if perk == 1 then
			result = result .. '<table><tr>'
		elseif perk == 5 then
			result = result .. '</tr></table><table><tr>'
		end 
		result = result .. '<td class="'
		-- Classes are required for CSS alignment of stats
        if perk > 4 then
			result = result .. 'special-bottom">' -- Bottom row
		else
			result = result .. 'special-top">' -- Top row
		end
 
		-- Checks for if the stat is modified by armor/clothing and calls the tooltip function
		if modifier[perk] ~= nil and modifier[perk] ~= "" then
			result = result .. tooltip( thisPerk + tonumber(modifier[perk]), statistics[perk] ) .. " "
		else
			result = result .. thisPerk .. " "
		end
		result = result .. links[perk] .. "</td> "
		perk = perk + 1
	end
 
	result = result .. "</tr></table></div>"
	return result
end
 
function p.string(frame)
    local value = mw.text.split(frame.args[1], ",")      -- Splits the values into an array
	local modifier = mw.text.split(frame.args[2], ",")   -- Splits the modifiers into an array
	local title = frame.args[3]                          -- If a game title is declared, this will be transfered to a variable
	local maximum = mw.text.split(frame.args[4], ",")    -- 
	local perk = 1                                                 -- Used for readings the arrays
	local result = "<span class='special-shell'>"                   -- Wrapper shell for SPECIAL stats to allow additional CSS handling
 
-- Adds the game title if one has been denoted, otherwise nothing is added.
	if title ~= nil or title ~= "" then
		result = result .. "<div class='special-title'>" .. title .. "</div>"
	end
 
    while perk <= 7 do
        if tonumber(value[perk]) ~= nil then
       	    thisPerk = tonumber(value[perk])
       	else
       	    thisPerk = 0
       	end
 
       	if tonumber(value[perk]) ~= nil then
       	    perkMax = tonumber(maximum[perk])
       	else
       	    perkMax = 0
       	end
 
        if perkMax > thisPerk then
            perkArr = " &rarr; "
        else
            perkArr = " &larr; "
        end
 
       	if modifier[perk] ~= nil and modifier[perk] ~= "" then
       	    if perkMax ~= 0 then
       	        perkString = thisPerk + tonumber(modifier[perk]) .. perkArr .. perkMax + tonumber(modifier[perk])
       	    else
       	        perkString = thisPerk + tonumber(modifier[perk])
       	    end
			result = result .. tooltip( perkString, statistics[perk] ) .. " "
		else
		    if perkMax ~= 0 then
       	        perkString = thisPerk .. perkArr .. perkMax
       	    else
       	        perkString = thisPerk
       	    end
			result = result .. perkString .. " "
		end
 
		result = result .. links[perk]
 
		if perk <7 then
		    result = result .. ", "
		end
 
		perk = perk + 1
	end
    result = result .. "</span>"    
    return result
 
end
 
function p.test(frame)
    return string.len(tostring(frame.args[3]))
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+