Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- furn = peripheral.wrap("bottom")
- chest = peripheral.wrap("top")
- args = {...}
- function formatTime(s)
- totalTime = s
- hours = math.floor(totalTime/3600)
- totalTime = totalTime % 3600
- minutes = math.floor(totalTime/60)
- seconds = totalTime % 60
- output = ""
- if hours > 0 then
- output = output .. tostring(hours) .. " h "
- end
- if minutes > 0 then
- output = output .. tostring(minutes) .. " m "
- end
- output = output .. tostring(seconds) .. " s"
- return output
- end
- function showTime(s)
- term.clear()
- term.setCursorPos(1,1)
- print("Powering Flywheel...")
- if s then
- print("Time remaining: " .. formatTime(s))
- else
- print("Time remaining: 'till we run out of fuel or the server crashes!")
- end
- end
- function loop()
- furn.pullItems("top", 1, 1)
- sleep(0.5)
- chest.pullItems("bottom", 1, 1)
- sleep(0.5)
- end
- function parse(targs)
- if #targs == 0 then
- return -1
- elseif #targs == 1 then
- return tonumber(targs[1])
- else
- if targs[2] == 'h' then
- return tonumber(targs[1]) * 3600
- elseif targs[2] == 'm' then
- return tonumber(targs[1]) * 60
- elseif targs[2] == 's' then
- return tonumber(targs[1])
- end
- end
- end
- loops = parse(args)
- if loops >= 0 then
- for i = 1, loops do
- showTime(loops - i + 1)
- loop()
- end
- else
- while true do
- showTime()
- loop()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement