Commit 91a08e9b authored by Fedja Beader's avatar Fedja Beader
Browse files

biofuel: add drawer support (as dest)

parent 22574c49
......@@ -60,10 +60,12 @@ local biofuel = minetest.deserialize(mod_storage:get_string("biofuel_state")) o
wood_crafters = {},
refineries = {},
}
biofuel.drawer_controllers = biofuel.drawer_controllers or {}
register_on_jumpdrive_jump(function (jump)
l:info("translating coordinates on jump")
translate_position_list(jump, biofuel.canister_crafters)
translate_position_list(jump, biofuel.drawer_controllers)
translate_position_list(jump, biofuel.stick_crafters)
translate_position_list(jump, biofuel.wood_crafters)
translate_position_list(jump, biofuel.refineries)
......@@ -289,6 +291,20 @@ function biofuel_step()
setup_machine_network(biofuel.stick_crafters, biofuel.refineries, "default:stick")
setup_machine_network(biofuel.refineries, biofuel.canister_crafters, "biofuel:bottle_fuel")
-- move from fuel can crafter to drawers
local sources = {}
for i,pos in pairs(biofuel.canister_crafters) do
local from = ItemLocations:new()
from:collect(pos, "dst", "biofuel:fuel_can")
table.insert(sources, from)
end
local to = ItemLocations:new()
for _,pos in pairs(biofuel.drawer_controllers) do
to:collect(pos, "src", "")
end
setup_multimove(sources, { to }, "biofuel:fuel_can")
core.after(30, biofuel_step) -- use after as it takes forever
end
end
......@@ -299,6 +315,9 @@ core.register_on_punchnode(function(pos, node)
if node.name == "biofuel:refinery" or node.name == "biofuel:refinery_active" then
add_pos_to_list(biofuel.refineries, pos)
l:info("Added refinery")
elseif node.name == "drawers:controller" then
l:info("Setting default drawer controller")
biofuel.drawer_controllers[1] = pos
elseif node.name == "pipeworks:autocrafter" then
local inv = core.get_inventory(pos)
local item_string = inv["output"][1]:get_name()
......@@ -335,6 +354,7 @@ core.register_chatcommand("biofuel", {
biofuel.stick_crafters = {}
biofuel.wood_crafters = {}
biofuel.refineries = {}
biofuel.drawer_controllers = {}
elseif args[1] == "reg" then
l:info("punch autocrafters/refineries to add them")
wait_for_punch = true
......
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