mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 23:42:59 +00:00
Fix eta calculations
This commit is contained in:
parent
2b29334d82
commit
a360f06138
3 changed files with 12 additions and 4 deletions
|
@ -111,7 +111,11 @@ local function subdivide_step_afterload(state_emerge, state_ours)
|
||||||
end
|
end
|
||||||
state_ours.times.steps_total = state_ours.times.steps_total + state_ours.times.step_last
|
state_ours.times.steps_total = state_ours.times.steps_total + state_ours.times.step_last
|
||||||
state_ours.times.step_start_abs = wea.get_ms_time()
|
state_ours.times.step_start_abs = wea.get_ms_time()
|
||||||
state_ours.eta = wea.eta(state_ours.times.steps, state_ours.chunks_total)
|
state_ours.eta = wea.eta(
|
||||||
|
state_ours.times.steps,
|
||||||
|
state_ours.chunks_completed,
|
||||||
|
state_ours.chunks_total
|
||||||
|
)
|
||||||
if state_ours.chunks_completed > 0 then
|
if state_ours.chunks_completed > 0 then
|
||||||
state_ours.emerge_overhead = state_ours.times.emerge_total / state_ours.times.steps_total
|
state_ours.emerge_overhead = state_ours.times.emerge_total / state_ours.times.steps_total
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,12 +31,12 @@ function worldeditadditions.get_ms_time()
|
||||||
return minetest.get_us_time() / 1000
|
return minetest.get_us_time() / 1000
|
||||||
end
|
end
|
||||||
|
|
||||||
function worldeditadditions.eta(existing_times, times_total_count)
|
function worldeditadditions.eta(existing_times, done_count, total_count)
|
||||||
local max = 100
|
local max = 100
|
||||||
local average = worldeditadditions.average(
|
local average = worldeditadditions.average(
|
||||||
worldeditadditions.table_get_last(existing_times, max)
|
worldeditadditions.table_get_last(existing_times, max)
|
||||||
)
|
)
|
||||||
local times_left = times_total_count - math.min(100, #existing_times)
|
local times_left = total_count - done_count
|
||||||
if times_left == 0 then return 0 end
|
if times_left == 0 then return 0 end
|
||||||
return average * times_left
|
return average * times_left
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,7 +41,11 @@ local function step(params)
|
||||||
((params.i + 1) / params.count)*100,
|
((params.i + 1) / params.count)*100,
|
||||||
worldeditadditions.human_time(params.times[#params.times] or 0),
|
worldeditadditions.human_time(params.times[#params.times] or 0),
|
||||||
worldeditadditions.human_time(worldeditadditions.average(params.times)),
|
worldeditadditions.human_time(worldeditadditions.average(params.times)),
|
||||||
worldeditadditions.human_time(worldeditadditions.eta(params.times, params.count))
|
worldeditadditions.human_time(worldeditadditions.eta(
|
||||||
|
params.times,
|
||||||
|
params.i,
|
||||||
|
params.count
|
||||||
|
))
|
||||||
))
|
))
|
||||||
|
|
||||||
local cmd = minetest.chatcommands[params.cmd_name]
|
local cmd = minetest.chatcommands[params.cmd_name]
|
||||||
|
|
Loading…
Reference in a new issue