Commit 929ee4b8 authored by Fedja Beader's avatar Fedja Beader
Browse files

Add invnet config <n> recipe ... command, can now designate chests as

destinations for items
parent b694a790
......@@ -50,8 +50,8 @@ local function invnet_reset()
end
local function invnet_list()
for i,m in pairs(invnet.machines) do
local function invnet_list(machines)
for i,m in pairs(machines) do
l:info("Machine #" .. i .. " at " .. minetest.pos_to_string(m.pos) .. ": ")
for name,count in pairs(m.recipe or {}) do
l:info(" recipe consumes " .. count .. " of " .. name)
......@@ -228,7 +228,7 @@ core.register_on_punchnode(function(pos, node)
l:info("Added autocrafter for: " .. output_gain .. " of " .. item_string)
end
else
l:info("Unknown node punched: " .. node.name .. " adding it as source chest")
l:info("Unknown node punched: " .. node.name .. " adding as chest. Use .invnet config to [re]configure.")
local inv = core.get_inventory(pos)
local m = {}
if inv["src"] then
......@@ -258,6 +258,7 @@ end)
local function help()
return ".invnet: inventory networks (automatic item moving between inventories), usage:\n"
.. ".invnet add -- toggles adding nodes to the network\n"
.. ".invnet config <n> recipe [crafting grid slot 1 itemstring] ... -- changes machine's recipe\n"
.. ".invnet list -- lists all inventories in the network\n"
.. ".invnet reset -- clears the entire network\n"
.. ".invnet start -- make other players jealous\n"
......@@ -276,8 +277,25 @@ core.register_chatcommand("invnet", {
l:info("punch nodes to add them into inventory network. repeat this command to stop")
wait_for_punch = true
end
elseif args[1] == "config" then
local index = tonumber(args[2])
if not index or not invnet.machines[index] then
l:err(help() .. "Must provide index!")
return
end
local m = invnet.machines[index]
if args[3] == "recipe" then
m.recipe = {}
for item_i = 4,#args do
local item = args[item_i]
m.recipe[item] = (m.recipe[item] or 0) + 1
end
invnet_list({ [index] = m })
end
elseif args[1] == "list" then
invnet_list()
invnet_list(invnet.machines)
elseif args[1] == "reset" then
invnet_reset()
elseif args[1] == "start" 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