Reboot on click
authorOlav Bakke Svendsen <mail@olavbs.no>
Thu, 12 Oct 2023 05:30:38 +0000 (07:30 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Thu, 12 Oct 2023 05:30:38 +0000 (07:30 +0200)
steam/temporary-coal-feeder.lua

index 530d8763b2930bf215bf332db7e1cd3f0c347454..f7c2d8056391638b8cbdf4dba0f14a3df8370cf6 100644 (file)
@@ -3,7 +3,8 @@
 local refill_when = function(amt) return amt < 2 end
 local refill_amt  = 2
 
-local main_monitor = peripheral.wrap("monitor_3")
+local main_monitor_name = "monitor_3"
+local main_monitor = peripheral.wrap(main_monitor_name)
 -- local treefarm_monitor = peripheral.wrap("monitor_0")
 
 local coal_barrels = {}
@@ -74,7 +75,7 @@ local print_stats = function(monitor, stock)
   monitor.setCursorPos(1,4)
   monitor.setTextColor(128)
   monitor.write(string.gsub(str, "^%s++%s*", ""))
-  monitor.setCursorPos(1,6)
+  monitor.setCursorPos(1,12)
   monitor.write("refreshes once every minute")
 end
 
@@ -96,8 +97,11 @@ 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(spin())
+  if e[1] == "monitor_touch" and e[2] == main_monitor_name then
+    main_monitor.clear()
+    main_monitor.setCursorPos(1,1)
+    main_monitor.write("rebooting...")
+    os.reboot()
   if e[1] == "timer" and e[2] == main_timer then
     main_timer = os.startTimer(60)
     os.cancelTimer(spinner_timer)