Sawmill recipe

This commit is contained in:
Evert Prants 2018-06-18 22:31:46 +03:00
parent 78d4a9ac7b
commit b11ec4a220
No known key found for this signature in database
GPG Key ID: 1688DA83D222D0B5
4 changed files with 28 additions and 34 deletions

@ -9,7 +9,7 @@ end
function elefluid.get_node_buffers(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
end
@ -17,7 +17,7 @@ function elefluid.get_node_buffers(pos)
return {fluidity = {}}
end
return nodedef['ele_fluid_container']
return nodedef['fluid_buffers']
end
function elefluid.get_buffer_data(pos, buffer)
@ -60,6 +60,10 @@ function elefluid.buffer_accepts_fluid(pos, buffer, fluid)
return true
end
if bfdata.fluid ~= "" and bfdata.fluid ~= fluid then
return false
end
if type(bfdata.accepts) ~= "table" then
bfdata.accepts = { bfdata.accepts }
end
@ -67,7 +71,7 @@ function elefluid.buffer_accepts_fluid(pos, buffer, fluid)
for _,pf in pairs(bfdata.accepts) do
if pf == fluid then
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
end
end
@ -152,5 +156,5 @@ function elefluid.take_from_buffer(pos, buffer, count)
meta:set_int(buffer .. "_fluid_storage", new_storage)
meta:set_string(buffer .. "_fluid", fluid)
return fluid, take_count
return bfdata.fluid, take_count
end

@ -14,8 +14,9 @@ end
local function add_node(nodes, pos, pnodeid)
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
end
if nodes[node_id] then
return false
end
@ -39,18 +40,11 @@ local function check_node(targets, all_nodes, pos, p_pos, pnodeid, queue)
return
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
return
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)
end
@ -86,7 +80,7 @@ local function fluid_targets(p_pos, positions)
local node = minetest.get_node(pos)
if node and ele.helpers.get_item_group(node.name, "elefluid_transport") then
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
queue = {p_pos}
end
@ -124,19 +118,6 @@ minetest.register_abm({
local meta = minetest.get_meta(pos)
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 source = minetest.registered_nodes[node.name]
@ -178,7 +159,7 @@ minetest.register_abm({
end
-- 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
return
end
@ -241,8 +222,8 @@ local function check_connections(pos)
for _,connected_pos in pairs(positions) do
local name = minetest.get_node(connected_pos).name
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, "fluid_container") or
ele.helpers.get_item_group(name, "fluidity_tank") then
table.insert(connections, connected_pos)
end
@ -284,9 +265,8 @@ function elefluid.clear_networks(pos)
table.insert(network.all_nodes, pos)
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
meta:set_string("ele_network", network_id)
table.insert(network.targets, pos)
end
elseif dead_end and not placed then

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

@ -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
minetest.register_craft({
output = "elepower_machines:power_cell_0",