Anonymous

Module:Calculator/ETA: Difference between revisions

From Melvor Idle
no edit summary
m (Add experience per hour row)
No edit summary
 
Line 3: Line 3:
local MEXP = require('Module:Experience')
local MEXP = require('Module:Experience')
local number = require('Module:Number')
local number = require('Module:Number')
local TimeSpan = require('Module:TimeSpan')


local function formatTime(timeInHundredths)
local function formatTime(seconds)
local timespan = number.actionTimeToTimeSpan(timeInHundredths)
local timespan = TimeSpan.fromSeconds(seconds)
 
return timespan:toStringLong()
if timespan.days == 0 then
return string.format("%02dh %02dm %02ds", timespan.hours, timespan.minutes, timespan.seconds)
else
return string.format("%d days %02dh %02dm %02ds", timespan.days, timespan.hours, timespan.minutes, timespan.seconds)
end
end
end


Line 23: Line 19:


local function calc(currentExp, targetLvl, expPerAction, actionTime)
local function calc(currentExp, targetLvl, expPerAction, actionTime)
-- ActionTime is represented in hundreds of a second.
local actionsPerHour = math.floor(3600 / actionTime)
-- 1.6 seconds = 160
local actionsPerHour = math.floor(360000 / actionTime)
local targetExp = MEXP.expForLevel(targetLvl)
local targetExp = MEXP.expForLevel(targetLvl)
local expRemaining = math.max(targetExp - currentExp, 0)
local expRemaining = math.max(targetExp - currentExp, 0)
local expPerHour = math.floor(360000 / actionTime * expPerAction)
local expPerHour = math.floor(3600 / actionTime * expPerAction)
local actionsToTarget = math.ceil(expRemaining / expPerAction)
local actionsToTarget = math.ceil(expRemaining / expPerAction)
Line 59: Line 53:
local targetLvl = number.toNumberOrError(args.targetLvl)
local targetLvl = number.toNumberOrError(args.targetLvl)
local actionExp = number.toNumberOrError(args.actionExp)
local actionExp = number.toNumberOrError(args.actionExp)
local actionTime = number.toNumberOrError(args.actionTime) * 100
local actionTime = number.toNumberOrError(args.actionTime)


-- Check Exp param for validity first, then Lvl
-- Check Exp param for validity first, then Lvl
2,875

edits