Sawmill recipe

This commit is contained in:
Evert Prants 2018-06-18 22:31:46 +03:00
parent 78d4a9ac7b
commit b11ec4a220
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
4 changed files with 28 additions and 34 deletions

View File

@ -9,7 +9,7 @@ end
function elefluid.get_node_buffers(pos) function elefluid.get_node_buffers(pos)
local node, nodedef = node_data(pos) local node, nodedef = node_data(pos)
if not nodedef['ele_fluid_container'] and not ele.helpers.get_item_group(node.name, "fluidity_tank") then if not nodedef['fluid_buffers'] and not ele.helpers.get_item_group(node.name, "fluidity_tank") then
return nil return nil
end end
@ -17,7 +17,7 @@ function elefluid.get_node_buffers(pos)
return {fluidity = {}} return {fluidity = {}}
end end
return nodedef['ele_fluid_container'] return nodedef['fluid_buffers']
end end
function elefluid.get_buffer_data(pos, buffer) function elefluid.get_buffer_data(pos, buffer)
@ -60,6 +60,10 @@ function elefluid.buffer_accepts_fluid(pos, buffer, fluid)
return true return true
end end
if bfdata.fluid ~= "" and bfdata.fluid ~= fluid then
return false
end
if type(bfdata.accepts) ~= "table" then if type(bfdata.accepts) ~= "table" then
bfdata.accepts = { bfdata.accepts } bfdata.accepts = { bfdata.accepts }
end end
@ -67,7 +71,7 @@ function elefluid.buffer_accepts_fluid(pos, buffer, fluid)
for _,pf in pairs(bfdata.accepts) do for _,pf in pairs(bfdata.accepts) do
if pf == fluid then if pf == fluid then
return true return true
elseif pf:match("^group") and ele.helpers.get_item_group(fluid, pf) then elseif pf:match("^group") and ele.helpers.get_item_group(fluid, pf:gsub("group:", "")) then
return true return true
end end
end end
@ -152,5 +156,5 @@ function elefluid.take_from_buffer(pos, buffer, count)
meta:set_int(buffer .. "_fluid_storage", new_storage) meta:set_int(buffer .. "_fluid_storage", new_storage)
meta:set_string(buffer .. "_fluid", fluid) meta:set_string(buffer .. "_fluid", fluid)
return fluid, take_count return bfdata.fluid, take_count
end end

View File

@ -14,8 +14,9 @@ end
local function add_node(nodes, pos, pnodeid) local function add_node(nodes, pos, pnodeid)
local node_id = minetest.hash_node_position(pos) local node_id = minetest.hash_node_position(pos)
if elefluid.graphcache.nodes[node_id] and elefluid.graphcache.nodes[node_id] ~= pnodeid then return end if elefluid.graphcache.nodes[node_id] == "" then
elefluid.graphcache.nodes[node_id] = pnodeid elefluid.graphcache.nodes[node_id] = pnodeid
end
if nodes[node_id] then if nodes[node_id] then
return false return false
end end
@ -39,18 +40,11 @@ local function check_node(targets, all_nodes, pos, p_pos, pnodeid, queue)
return return
end end
if not ele.helpers.get_item_group(node.name, "ele_fluid_container") and if not ele.helpers.get_item_group(node.name, "fluid_container") and
not ele.helpers.get_item_group(node.name, "fluidity_tank") then not ele.helpers.get_item_group(node.name, "fluidity_tank") then
return return
end end
-- Don't add already networked nodes to this network
if meta:get_string("network_id") ~= "" and meta:get_string("network_id") ~= pnodeid then
return
end
meta:set_string("network_id", pnodeid)
add_node(targets, pos, pnodeid) add_node(targets, pos, pnodeid)
end end
@ -86,7 +80,7 @@ local function fluid_targets(p_pos, positions)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if node and ele.helpers.get_item_group(node.name, "elefluid_transport") then if node and ele.helpers.get_item_group(node.name, "elefluid_transport") then
add_duct_node(all_nodes, pos, pnodeid, queue) add_duct_node(all_nodes, pos, pnodeid, queue)
elseif node and (ele.helpers.get_item_group(node.name, "ele_fluid_container") or elseif node and (ele.helpers.get_item_group(node.name, "fluid_container") or
ele.helpers.get_item_group(node.name, "fluidity_tank")) then ele.helpers.get_item_group(node.name, "fluidity_tank")) then
queue = {p_pos} queue = {p_pos}
end end
@ -124,19 +118,6 @@ minetest.register_abm({
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local meta1 = nil local meta1 = nil
-- Check if a source is attached to a network.
-- If that network has been abolished, we will use this node as the network's root this time.
local netwrkto = meta:get_string("ele_network")
if netwrkto ~= "" and netwrkto ~= nil then
local lpos = minetest.string_to_pos(netwrkto)
if ele.helpers.get_item_group(minetest.get_node(lpos).name, "elefluid_transport_source") then
return
else
elefluid.graphcache[netwrkto] = nil
end
meta:set_string("ele_network", "")
end
local targets = {} local targets = {}
local source = minetest.registered_nodes[node.name] local source = minetest.registered_nodes[node.name]
@ -178,7 +159,7 @@ minetest.register_abm({
end end
-- Make sure source node is a registered fluid container -- Make sure source node is a registered fluid container
if not ele.helpers.get_item_group(srcnode.name, "ele_fluid_container") and if not ele.helpers.get_item_group(srcnode.name, "fluid_container") and
not ele.helpers.get_item_group(srcnode.name, "fluidity_tank") then not ele.helpers.get_item_group(srcnode.name, "fluidity_tank") then
return return
end end
@ -241,8 +222,8 @@ local function check_connections(pos)
for _,connected_pos in pairs(positions) do for _,connected_pos in pairs(positions) do
local name = minetest.get_node(connected_pos).name local name = minetest.get_node(connected_pos).name
if ele.helpers.get_item_group(name, "elefluid_transport") or if ele.helpers.get_item_group(name, "elefluid_transport") or
ele.helpers.get_item_group(name, "ele_fluid_container") or ele.helpers.get_item_group(name, "elefluid_transport_source") or
ele.helpers.get_item_group(name, "elefluid_transport_source") or ele.helpers.get_item_group(name, "fluid_container") or
ele.helpers.get_item_group(name, "fluidity_tank") then ele.helpers.get_item_group(name, "fluidity_tank") then
table.insert(connections, connected_pos) table.insert(connections, connected_pos)
end end
@ -284,9 +265,8 @@ function elefluid.clear_networks(pos)
table.insert(network.all_nodes, pos) table.insert(network.all_nodes, pos)
end end
if ele.helpers.get_item_group(name, "ele_fluid_container") or if ele.helpers.get_item_group(name, "fluid_container") or
ele.helpers.get_item_group(name, "fluidity_tank") then ele.helpers.get_item_group(name, "fluidity_tank") then
meta:set_string("ele_network", network_id)
table.insert(network.targets, pos) table.insert(network.targets, pos)
end end
elseif dead_end and not placed then elseif dead_end and not placed then

View File

@ -81,7 +81,7 @@ function elefluid.register_transfer_duct(nodename, nodedef)
connects_to = { connects_to = {
"group:elefluid_transport", "group:elefluid_transport",
"group:elefluid_transport_source", "group:elefluid_transport_source",
"group:ele_fluid_container", "group:fluid_container",
"group:fluidity_tank" "group:fluidity_tank"
}, },
} }

View File

@ -251,6 +251,16 @@ minetest.register_craft({
} }
}) })
-- Sawmill
minetest.register_craft({
output = "elepower_machines:sawmill",
recipe = {
{"", "elepower_dynamics:copper_wire", ""},
{"elepower_dynamics:steel_gear", "elepower_machines:machine_block", "elepower_dynamics:steel_gear"},
{"elepower_dynamics:lead_ingot", "elepower_dynamics:diamond_gear", "elepower_dynamics:lead_ingot"},
}
})
-- Power Cell -- Power Cell
minetest.register_craft({ minetest.register_craft({
output = "elepower_machines:power_cell_0", output = "elepower_machines:power_cell_0",