Checking how far behind treefarm is
authorOlav Bakke Svendsen <mail@olavbs.no>
Thu, 12 Oct 2023 06:07:06 +0000 (08:07 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Thu, 12 Oct 2023 06:07:06 +0000 (08:07 +0200)
steam/temporary-coal-feeder.lua

index 3e96b54b62fcb240b968616159e74b917913ec1d..306d81350e3cb0c0eb19eea0052dd1ea4e5d16f0 100644 (file)
@@ -57,6 +57,9 @@ local feed = function(stock)
   end
 end
 
+local coal_at_boot = false
+local minutes_passed = -1
+
 local print_stats = function(monitor, stock)
   local total_coal = 0
   local str = ""
@@ -77,6 +80,14 @@ local print_stats = function(monitor, stock)
   monitor.write(string.gsub(str, "^%s++%s*", ""))
   monitor.setCursorPos(1,12)
   monitor.write("refreshes once every minute")
+
+  coal_at_boot = coal_at_boot or total_coal
+  minutes_passed = minutes_passed + 1
+  if minutes_passed < 0 then
+    local avg = (coal_at_boot - total_coal)/minutes_passed
+    monitor.setCursorPos(1,6)
+    monitor.write("losing on average "..avg.."cc/m")
+  end
 end
 
 local spinner_chars = {"\\","-","/","|"}