Anonymous

Module:Calculator/Summoning Interval Efficiency: Difference between revisions

From Melvor Idle
m
Fix formatting
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


-- Add a row to the table
-- Adds a row to a table.
-- If the value parameter is a negative number, colour the cell red.
-- 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 cell = row:tag("td")
     local headerCell = row:tag("th")
      
     local valueCell = row:tag("td")
    row:tag("th"):wikitext(header)


-- 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
         cell:css('color', 'red'):wikitext(value)
         valueCell = valueCell:css('color', 'red')
    else
        cell:wikitext(value)
     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 = {
2,875

edits