From: Olav Bakke Svendsen Date: Thu, 12 Oct 2023 04:56:11 +0000 (+0200) Subject: Stop spinner when loading coal X-Git-Tag: stable-steam~20 X-Git-Url: http://git.olavbs.no/?a=commitdiff_plain;h=6d551724b00e825f7a3d243b8edfa5a432bdd1cf;p=cc.git Stop spinner when loading coal --- diff --git a/steam/temporary-coal-feeder.lua b/steam/temporary-coal-feeder.lua index 611661f..d18f3d6 100644 --- a/steam/temporary-coal-feeder.lua +++ b/steam/temporary-coal-feeder.lua @@ -79,31 +79,35 @@ local print_stats = function(monitor, stock) end local spinner_chars = {"\\","-","/","|"} -local spinner = function() +local spin = function() local c = table.remove(spinner_chars) table.insert(spinner_chars, 1, c) return c end +local print_spinner(monitor, x, y, spinning) = function() + local s = spin() + main_monitor.setTextColor(1) + main_monitor.setCursorPos(29,12) + main_monitor.write(spinning and s or "*") +end local main_timer = os.startTimer(0) local spinner_timer = os.startTimer(0) while true do local e = table.pack(os.pullEvent()) - if e[1] == "monitor_touch" and e[2] == treefarm_monitor then - treefarm_monitor.write(spinner()) - elseif e[1] == "timer" and e[2] == main_timer then +-- if e[1] == "monitor_touch" and e[2] == treefarm_monitor then +-- treefarm_monitor.write(spin()) + if e[1] == "timer" and e[2] == main_timer then main_timer = os.startTimer(60) os.cancelTimer(spinner_timer) + print_spinner(main_monitor, 29,12, false) local stock = balance_coal() print_stats(main_monitor, stock) feed(stock) spinner_timer = os.startTimer(0) elseif e[1] == "timer" and e[2] == spinner_timer then spinner_timer = os.startTimer(0.5) - local s = spinner() - main_monitor.setTextColor(1) - main_monitor.setCursorPos(29,12) - main_monitor.write(s) + print_spinner(main_monitor, 29, 12, true) end end