2,875
edits
m (Fix erroneous calculation of time remainder) |
m (Use local functions) |
||
Line 4: | Line 4: | ||
local shared = require('Module:Shared') | local shared = require('Module:Shared') | ||
function | local function formatTime(timeInHundredths) | ||
local sec = math.floor(timeInHundredths / 100) | local sec = math.floor(timeInHundredths / 100) | ||
local min = math.floor(timeInHundredths / 60000) | local min = math.floor(timeInHundredths / 60000) | ||
Line 17: | Line 17: | ||
end | end | ||
function | local function addTableRow(tbl, c1, c2) | ||
tbl:tag("tr") | tbl:tag("tr") | ||
:tag("th"):wikitext(c1) | :tag("th"):wikitext(c1) | ||
Line 25: | Line 25: | ||
end | end | ||
function | local function calc(currentExp, targetLvl, expPerAction, actionTime) | ||
-- ActionTime is represented in hundreds of a second. | -- ActionTime is represented in hundreds of a second. | ||
-- 1.6 seconds = 160 | -- 1.6 seconds = 160 | ||
Line 38: | Line 38: | ||
:addClass("wikitable sticky-header text-align-right align-left-1") | :addClass("wikitable sticky-header text-align-right align-left-1") | ||
addTableRow(tbl, "Current Experience", shared.formatnum(currentExp)) | |||
addTableRow(tbl, "Target Level", targetLvl) | |||
addTableRow(tbl, "Target Experience", shared.formatnum(targetExp)) | |||
addTableRow(tbl, "Experience Remaining", shared.formatnum(expRemaining)) | |||
addTableRow(tbl, "Actions Left", shared.formatnum(actionsToTarget)) | |||
addTableRow(tbl, "Time Left", formatTime(timeToTarget)) | |||
return tostring(tbl) | return tostring(tbl) | ||
Line 67: | Line 67: | ||
end | end | ||
return | return calc(currentExp, targetLvl, actionExp, actionTime) | ||
end | end | ||
return p | return p |
edits