Module:Calculator/ETA: Difference between revisions

m
Make resulting table vertical instead of horizontal
m (Don't show days if daycount = 0)
m (Make resulting table vertical instead of horizontal)
Line 10: Line 10:
     local days = math.floor(timeInHundredths / (3600000 * 24))
     local days = math.floor(timeInHundredths / (3600000 * 24))


local formatString = "%d days %02dh %02dm %02ds"
if days == 0 then
if days == 0 then
formatString = "%02dh %02dm %02ds"
return string.format("%02dh %02dm %02ds", hrs % 24, min % 60, sec % 60)
else
return string.format("%d days %02dh %02dm %02ds", days, hrs % 24, min % 60, sec % 60)
end
end
end
function p._addTableRow(tbl, c1, c2)
tbl:tag("tr")
:tag("th"):wikitext(c1)
:tag("td"):wikitext(c2)
    return string.format(formatString, days, hrs % 24, min % 60, sec % 60)
return tbl
end
end


Line 31: Line 38:
         :addClass("wikitable sticky-header text-align-right align-left-1")
         :addClass("wikitable sticky-header text-align-right align-left-1")


    tbl:tag("tr")
p._addTableRow(tbl, "Current Experience", shared.formatnum(currentExp))
        :tag("th"):wikitext("Current Experience")
p._addTableRow(tbl, "Target Level", targetLvl)
        :tag("th"):wikitext("Target Level")
p._addTableRow(tbl, "Target Experience", shared.formatnum(targetExp))
        :tag("th"):wikitext("Target Experience")
p._addTableRow(tbl, "Experience Remaining", shared.formatnum(expRemaining))
        :tag("th"):wikitext("Experience Remaining")
p._addTableRow(tbl, "Actions Left", shared.formatnum(actionsToTarget))
        :tag("th"):wikitext("Actions Left")
p._addTableRow(tbl, "Time Left", p._formatTime(timeToTarget))
        :tag("th"):wikitext("Time Left")
 
    tbl:tag("tr")
        :tag("td"):wikitext(shared.formatnum(currentExp))
        :tag("td"):wikitext(targetLvl)
        :tag("td"):wikitext(shared.formatnum(targetExp))
        :tag("td"):wikitext(shared.formatnum(expRemaining))
        :tag("td"):wikitext(shared.formatnum(actionsToTarget))
        :tag("td"):wikitext(p._formatTime(timeToTarget))


     return tostring(tbl)
     return tostring(tbl)
918

edits