2,875
edits
m (Check if the table value is a number based on tonumber) |
m (Fix formatting) |
||
Line 4: | Line 4: | ||
local p = {} | local p = {} | ||
-- Calculates the time economy of using summoning synergies that decrease action interval | |||
-- based on the player's stats. | |||
local function calculateTimeEfficiency(playerStats) | local function calculateTimeEfficiency(playerStats) | ||
local result = { | local result = { | ||
Line 45: | Line 47: | ||
end | end | ||
-- | -- Adds a row to a table. | ||
-- | -- Optionally adds a suffix to the 'value' parameter. | ||
local function addTableRow(tbl, header, value) | local function addTableRow(tbl, header, value, suffix) | ||
local row = tbl:tag("tr") | local row = tbl:tag("tr") | ||
local | local headerCell = row:tag("th") | ||
local valueCell = row:tag("td") | |||
-- Check if the value is, or can be converted to a number. | |||
local numValue = tonumber(value) | local numValue = tonumber(value) | ||
if suffix then | |||
value = value .. suffix | |||
end | |||
-- If the numeric value is negative, colour the cell red. | |||
if numValue and numValue < 0 then | if numValue and numValue < 0 then | ||
valueCell = valueCell:css('color', 'red') | |||
end | end | ||
-- Fill cells with data. | |||
headerCell:wikitext(header) | |||
valueCell:wikitext(value) | |||
return tbl | return tbl | ||
end | end | ||
-- Format the calculated data and output a table. | |||
local function createTable(calcResult) | local function createTable(calcResult) | ||
local tableData = { | local tableData = { |
edits