Dumb mistake that took too long to figure out
authorOlav Bakke Svendsen <mail@olavbs.no>
Wed, 11 Oct 2023 22:02:11 +0000 (00:02 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Wed, 11 Oct 2023 22:02:11 +0000 (00:02 +0200)
steam/temporary-coal-feeder.lua

index 86aac3e43e260284997170f056d21b335c11d533..a3a20cc2d47209d4619433e94a98b4b8bf004680 100644 (file)
@@ -37,7 +37,7 @@ local feed = function(stock)
       for barrel_addr,count in pairs(stock) do
         if count >= refill_amt then
           stock[barrel_addr] = count - refill_amt
-          f = function() deployer.pullItems(barrel_addr, 1, refill_amt, 1) end
+          f = function() return deployer.pullItems(barrel_addr, 1, refill_amt, 1) end
           break
         end
       end
@@ -50,6 +50,17 @@ local feed = function(stock)
 end
 
 while true do
-  feed(locate_coal())
+  local stock = locate_coal()
+  local total_coal = 0
+
+  local str = ""
+  for k,v in pairs(stock) do
+    total_coal = total_coal + v
+    str = str..tostring(v).." in "..string.match(k, "barrel_%d+$").."\n"
+  end
+  print(tostring(total_coal).." coal available")
+  print(str)
+
+  feed(stock)
   os.sleep(60)
 end