Debugging
authorOlav Bakke Svendsen <mail@olavbs.no>
Wed, 18 Oct 2023 01:22:02 +0000 (03:22 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Wed, 18 Oct 2023 01:22:02 +0000 (03:22 +0200)
steam/temporary-coal-feeder.lua

index d128340b9d5638f8dd448a11722da1afd4299b02..3761865492ede9266497baa9ee7dcbf5a9299bef 100644 (file)
@@ -10,7 +10,7 @@ local start_coal_when = function(amt) return amt < 500 end
 local stop_coal_when = function(amt) return amt > 8000 end
 local rs_coal_side = "back"
 
-local wood_to_keep_in_blaster = 10000
+local wood_to_keep_in_blaster = 1000
 
 -- peripherals
 
@@ -55,13 +55,22 @@ end
 local move_wood = function(wood_amount, farm_amount, farm_slot)
   local wood_amount, farm_amount = wood_amount, farm_amount
   local to_move = wood_to_keep_in_blaster - wood_amount
-  if to_move > 0 and to_move <= farm_amount then
-    local moved = farm_barrel.pushItems(peripheral.getName(wood_drawer), farm_slot, to_move)
+  print("move_wood pre:")
+  print("  in farm: "..tostring(farm_amount))
+  print("  in blst: "..tostring(wood_amount))
+  print("  to move: "..tostring(to_move))
+  if to_move > 0 then
+    local moved = farm_barrel.pushItems(peripheral.getName(wood_drawer), farm_slot, math.min(to_move, farm_amount))
   end
   if moved then
     wood_amount = wood_amount + moved
     farm_amount = farm_amount - moved
   end
+  print("move_wood post:")
+  print("  in farm: "..tostring(farm_amount))
+  print("  in blst: "..tostring(wood_amount))
+  print("    moved: "..tostring(moved))
+  print("")
   return wood_amount, farm_amount
 end
 
@@ -77,7 +86,7 @@ local feed = function(coal_amount)
       end
       local ok, e = f()
       if not ok then
-        print("Could not feed "..deployer_addr.."\n"..e)
+--         print("Could not feed "..deployer_addr.."\n"..e)
       end
     end
   end