Commit a327df00 authored by Fedja Beader's avatar Fedja Beader
Browse files

biofuel: cleanup & deactivate periodic timers for unconfigured stuff

parent 1daad7e6
......@@ -269,7 +269,6 @@ end
function biofuel_step()
if not biofuel.enable then return end
--l:debug("Biofuel production step")
local my_inv = core.get_inventory()
if not biofuel.wood_crafters then
l:err("missing wood autocrafter!")
elseif not biofuel.stick_crafters then
......@@ -279,6 +278,7 @@ function biofuel_step()
elseif #biofuel.refineries == 0 then
l:err("missing refineries!")
core.after(30, biofuel_step) -- use after as it would needlessly block other things
local my_pos = core.localplayer:get_pos()
if max_distance(my_pos, biofuel.wood_crafters) > 5
......@@ -305,27 +305,26 @@ function biofuel_step()
setup_machine_network(biofuel.refineries, biofuel.canister_crafters, "biofuel:bottle_fuel")
setup_machine_network(biofuel.canister_crafters, biofuel.drawer_controllers, "biofuel:fuel_can")
core.after(30, biofuel_step) -- use after as it takes forever
-- Use comp. cobble autocrafters to turn cobble in my inv to comp. cobble in drawer.
function convert_cobble()
if not biofuel.enable or #biofuel.cobble_compressors == 0 then return end
core.after(10, convert_cobble)
if 0 == #biofuel.cobble_compressors then
l:err("Missing compressed cobble autocrafters[s]!")
elseif 0 == #biofuel.drawer_controllers then
l:err("Missing drawer controller[s]!")
core.after(10, convert_cobble)
local my_pos = core.localplayer:get_pos()
local max_distance = math.max(max_distance(my_pos, biofuel.cobble_compressors),
max_distance(my_pos, biofuel.drawer_controllers) )
if max_distance > 8 then
l:debug("Too far (" .. max_distance .. " from compressed cobble autocrafter[s], waiting")
if max_distance < 9 then
--l:debug("Too far (" .. max_distance .. " from compressed cobble autocrafter[s], waiting")
local from = ItemLocations:new()
from:collect(nil, "main", "default:cobble")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment