Commit 5538e285 authored by Fedja Beader's avatar Fedja Beader
Browse files

biofuel: + cobble-in-inv -> compressed cobble autocrafters -> drawers

parent 6ac498d2
......@@ -60,12 +60,14 @@ local biofuel = minetest.deserialize(mod_storage:get_string("biofuel_state")) o
wood_crafters = {},
refineries = {},
}
biofuel.cobble_compressors = biofuel.cobble_compressors or {}
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.cobble_compressors)
translate_position_list(jump, biofuel.stick_crafters)
translate_position_list(jump, biofuel.wood_crafters)
translate_position_list(jump, biofuel.refineries)
......@@ -307,6 +309,45 @@ function biofuel_step()
end
end
-- 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]!")
else
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")
else
local from = ItemLocations:new()
from:collect(nil, "main", "default:cobble")
local destinations = {}
for _,pos in pairs(biofuel.cobble_compressors) do
local to = ItemLocations:new()
--to:collect(pos, "src", item_name)
to:collect(pos, "src", "")
table.insert(destinations, to)
end
setup_multimove({ from }, destinations, "default:cobble")
-- move from cobble compressors to drawers
setup_machine_network(biofuel.cobble_compressors, biofuel.drawer_controllers, "moreblocks:cobble_compressed")
queue:walk()
end
end
end
local wait_for_punch = false
core.register_on_punchnode(function(pos, node)
if wait_for_punch then
......@@ -326,6 +367,9 @@ core.register_on_punchnode(function(pos, node)
elseif item_string == "biofuel:fuel_can" then
add_pos_to_list(biofuel.canister_crafters, pos)
l:info("Added canister autocrafter")
elseif item_string == "moreblocks:cobble_compressed" then
add_pos_to_list(biofuel.cobble_compressors, pos)
l:info("Added cobble autocrafter")
elseif item_string == "" then
l:err("autocrafter unconfigured")
elseif not biofuel.wood_name then
......@@ -363,6 +407,7 @@ core.register_chatcommand("biofuel", {
biofuel.wood_crafters = {}
biofuel.refineries = {}
biofuel.drawer_controllers = {}
biofuel.cobble_compressors = {}
elseif args[1] == "reg" then
l:info("punch autocrafters/refineries to add them")
wait_for_punch = true
......@@ -370,6 +415,7 @@ core.register_chatcommand("biofuel", {
wait_for_punch = false
elseif args[1] == "start" then
biofuel.enable = true
convert_cobble()
queue:prepend(biofuel_step)
queue:walk()
elseif args[1] == "stop" then
......
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