Commit 6ac498d2 authored by Fedja Beader's avatar Fedja Beader
Browse files

biofuel: support taking trunks from my main inv list

parent 1a7e3d23
......@@ -185,10 +185,10 @@ local function setup_multimove(from_locations_list, to_locations_list, item_name
end
end
l:debug("SM: Counted " .. input_stacks .. " input stacks")
l:debug("SM: Counted " .. input_stacks .. " input stacks of " .. item_name)
local per_dest = math.floor(input_stacks / #to_locations_list)
l:debug("SM: Will give each destination " .. per_dest .. " stacks.")
l:debug("SM: Will try to give each destination " .. per_dest .. " stacks.")
if per_dest == 0 then return end
......@@ -287,6 +287,17 @@ function biofuel_step()
return
end
local from = ItemLocations:new()
from:collect(nil, "main", biofuel.trunk_name)
local destinations = {}
for i,pos in pairs(biofuel.wood_crafters) do
local to = ItemLocations:new()
to:collect(pos, "src", "")
table.insert(destinations, to)
end
setup_multimove({ from }, destinations, biofuel.trunk_name)
setup_machine_network(biofuel.wood_crafters, biofuel.stick_crafters, biofuel.wood_name)
setup_machine_network(biofuel.stick_crafters, biofuel.refineries, "default:stick")
setup_machine_network(biofuel.refineries, biofuel.canister_crafters, "biofuel:bottle_fuel")
......@@ -321,6 +332,15 @@ core.register_on_punchnode(function(pos, node)
biofuel.wood_name = item_string
add_pos_to_list(biofuel.wood_crafters, pos)
l:info("Registered " .. item_string .. " as the item string of wood")
biofuel.trunk_name = "UNKNOWN"
for _,stack in pairs(inv["recipe"]) do
if stack:get_name() ~= "" then
biofuel.trunk_name = stack:get_name()
l:info("Registered " .. biofuel.trunk_name .. " as the item string of trunks")
break
end
end
end
else
l:info("Unknown node punched: " .. node.name)
......@@ -337,6 +357,7 @@ core.register_chatcommand("biofuel", {
biofuel.enable = false
biofuel.wood_name = nil
biofuel.trunk_name = nil
biofuel.canister_crafters = {}
biofuel.stick_crafters = {}
biofuel.wood_crafters = {}
......
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