80 lines
No EOL
2 KiB
Lua
80 lines
No EOL
2 KiB
Lua
basin = peripheral.wrap("top")
|
|
|
|
base_item = "dirt"
|
|
|
|
levels = {
|
|
compressed = 1,
|
|
double_compressed = 2,
|
|
triple_compressed = 3,
|
|
quadruple_compressed = 4,
|
|
quintuple_compressed = 5,
|
|
sextuple_compressed = 6,
|
|
septuple_compressed = 7,
|
|
octuple_compressed = 8,
|
|
}
|
|
|
|
unpacked = {
|
|
9,
|
|
81,
|
|
729,
|
|
6561,
|
|
59049,
|
|
531441,
|
|
4782969,
|
|
43046721
|
|
}
|
|
|
|
last_total = 0
|
|
last_estimate_time = 0
|
|
estimate_interval_h = 30/3600
|
|
estimated_speed = 0
|
|
|
|
function update()
|
|
local counts = {}
|
|
local raw = basin.list()
|
|
local total = 0
|
|
for _, item in pairs(raw) do
|
|
name = string.sub(item.name, string.len("compressor:_"), -string.len(base_item)-2)
|
|
count = item.count
|
|
if levels[name] then
|
|
counts[levels[name]] = count
|
|
total = total + unpacked[levels[name]] * count
|
|
end
|
|
end
|
|
|
|
local time = os.time("utc")
|
|
if time - last_estimate_time >= estimate_interval_h then
|
|
last_estimate_time = time
|
|
estimated_speed = (total - last_total) / (estimate_interval_h * 3600)
|
|
last_total = total
|
|
end
|
|
|
|
-- draw
|
|
|
|
term.clear()
|
|
term.setCursorPos(1,1)
|
|
print(base_item, "progress")
|
|
for level = 1, 7 do
|
|
local count = counts[level] or 0
|
|
local bar = string.rep("#", count) .. string.rep(".", 9 - count)
|
|
print("lvl", level, bar)
|
|
end
|
|
print("total: ", total)
|
|
local progress = math.floor(total / unpacked[8] * 10000) / 100
|
|
print("progress to octuple: " .. progress .. "%")
|
|
print("speed:", estimated_speed, base_item.."/s")
|
|
local eta = math.floor((unpacked[8] - progress) / estimated_speed + 0.5)
|
|
local eta_s = eta % 60
|
|
local eta_m = math.floor(eta / 60) % 60
|
|
local eta_h = math.floor(eta / 3600) % 24
|
|
local eta_d = math.floor(eta / 86400)
|
|
-- print(eta)
|
|
print("time remaining: ", eta_d .. "d", eta_h .. ":" .. eta_m .. ":" .. eta_s)
|
|
local n = math.floor(30 * (time - last_estimate_time) / estimate_interval_h)
|
|
print(string.rep(",", n)..string.rep(".", 32-n))
|
|
end
|
|
|
|
while true do
|
|
update()
|
|
sleep(2)
|
|
end |