Transfer and machinery fixes
This commit is contained in:
parent
b4e897ccf5
commit
33631dbd2e
@ -29,13 +29,14 @@ local function check_node(targets, all_nodes, pos, p_pos, pnodeid, queue)
|
|||||||
ele.helpers.get_or_load_node(pos)
|
ele.helpers.get_or_load_node(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
|
|
||||||
if ele.helpers.get_item_group(node.name, "elefluid_transport") then
|
if 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)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not ele.helpers.get_item_group(node.name, "fluid_container") then
|
if not ndef['node_io_can_put_liquid'] or not ndef['node_io_can_put_liquid'](pos, node, "") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ local function fluid_targets(p_pos, pos)
|
|||||||
local ndef = minetest.registered_nodes[node.name]
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
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 ndef['node_io_put_liquid'] and ndef['node_io_room_for_liquid'] then
|
elseif node and ndef['node_io_can_put_liquid'] and ndef['node_io_can_put_liquid'](pos, node, "") then
|
||||||
queue = {p_pos}
|
queue = {p_pos}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -98,10 +99,10 @@ function elefluid.transfer_timer_tick(pos, elapsed)
|
|||||||
|
|
||||||
-- Only allow the node directly behind to be a start of a network
|
-- Only allow the node directly behind to be a start of a network
|
||||||
local tpos = vector.add(minetest.facedir_to_dir(node.param2), pos)
|
local tpos = vector.add(minetest.facedir_to_dir(node.param2), pos)
|
||||||
local tname = minetest.get_node(tpos).name
|
local tnode = minetest.get_node(tpos)
|
||||||
local ndef = minetest.registered_nodes[tname]
|
local ndef = minetest.registered_nodes[tnode.name]
|
||||||
if not ele.helpers.get_item_group(tname, "elefluid_transport") and
|
if not ele.helpers.get_item_group(tnode.name, "elefluid_transport") and
|
||||||
not ndef['node_io_put_liquid'] and ndef['node_io_room_for_liquid'] then
|
(not ndef['node_io_can_put_liquid'] or not ndef['node_io_can_put_liquid'](tpos, tnode, "")) then
|
||||||
minetest.forceload_free_block(pos)
|
minetest.forceload_free_block(pos)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -126,7 +127,7 @@ function elefluid.transfer_timer_tick(pos, elapsed)
|
|||||||
local srcdef = minetest.registered_nodes[srcnode.name]
|
local srcdef = minetest.registered_nodes[srcnode.name]
|
||||||
|
|
||||||
-- Make sure source node is a registered fluid container
|
-- Make sure source node is a registered fluid container
|
||||||
if not srcdef['node_io_take_liquid'] or not srcdef['node_io_can_take_liquid'] then
|
if not srcdef['node_io_can_take_liquid'] then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -172,15 +173,16 @@ function elefluid.transfer_timer_tick(pos, elapsed)
|
|||||||
for aindex,afluid in pairs(buffers) do
|
for aindex,afluid in pairs(buffers) do
|
||||||
if pumped >= pcapability then break end
|
if pumped >= pcapability then break end
|
||||||
if (afluid == bfluid or bfluid == "") then
|
if (afluid == bfluid or bfluid == "") then
|
||||||
local defi = srcdef.node_io_take_liquid(srcpos, srcnode, "", nil, afluid, pcapability)
|
local idef = destdef.node_io_room_for_liquid(pos, destnode, "", afluid, pcapability)
|
||||||
if defi.millibuckets > 0 then
|
if idef > 0 then
|
||||||
local idef = destdef.node_io_room_for_liquid(pos, destnode, "", afluid, defi.millibuckets)
|
local fluidcount = srcdef.node_io_get_liquid_stack(srcpos, srcnode, "", aindex):get_count()
|
||||||
if idef > 0 then
|
local defc = math.min(fluidcount, idef)
|
||||||
local lo = destdef.node_io_put_liquid(pos, destnode, "", nil, afluid, idef)
|
local defi = srcdef.node_io_take_liquid(srcpos, srcnode, "", nil, afluid, defc)
|
||||||
idef = idef - lo
|
if defi.millibuckets > 0 then
|
||||||
|
local lo = destdef.node_io_put_liquid(pos, destnode, "", nil, afluid, defi.millibuckets)
|
||||||
|
pumped = pumped + (defi.millibuckets - lo)
|
||||||
|
changed = true
|
||||||
end
|
end
|
||||||
pumped = pumped + idef
|
|
||||||
changed = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -67,3 +67,5 @@ minetest.register_abm({
|
|||||||
meta:set_string("infotext", fluid_lib.buffer_to_string(buffer))
|
meta:set_string("infotext", fluid_lib.buffer_to_string(buffer))
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
fluid_lib.register_node("elepower_farming:tree_extractor")
|
||||||
|
@ -59,6 +59,9 @@ minetest.register_abm({
|
|||||||
buffer.amount = buffer.amount + give
|
buffer.amount = buffer.amount + give
|
||||||
|
|
||||||
meta:set_int("water_fluid_storage", buffer.amount)
|
meta:set_int("water_fluid_storage", buffer.amount)
|
||||||
|
meta:set_string("water_fluid", "default:water_source")
|
||||||
meta:set_string("infotext", fluid_lib.buffer_to_string(buffer))
|
meta:set_string("infotext", fluid_lib.buffer_to_string(buffer))
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
fluid_lib.register_node("elepower_machines:accumulator")
|
||||||
|
@ -312,7 +312,7 @@ function ele.register_base_device(nodename, nodedef)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Node IO Support
|
-- Node IO Support
|
||||||
if minetest.get_modpath("node_io") and (nodedef.groups["tubedevice"] or nodedef.groups["tube"]) then
|
if nodedef.groups["tubedevice"] or nodedef.groups["tube"] then
|
||||||
nodedef.node_io_can_put_item = function(pos, node, side) return true end
|
nodedef.node_io_can_put_item = function(pos, node, side) return true end
|
||||||
nodedef.node_io_room_for_item = function(pos, node, side, itemstack, count)
|
nodedef.node_io_room_for_item = function(pos, node, side, itemstack, count)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
@ -324,6 +324,10 @@ function ele.register_base_device(nodename, nodedef)
|
|||||||
nodedef.node_io_put_item = function(pos, node, side, putter, itemstack)
|
nodedef.node_io_put_item = function(pos, node, side, putter, itemstack)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
local t = minetest.get_node_timer(pos)
|
||||||
|
if not t:is_started() then
|
||||||
|
t:start(1.0)
|
||||||
|
end
|
||||||
return inv:add_item("src", itemstack)
|
return inv:add_item("src", itemstack)
|
||||||
end
|
end
|
||||||
nodedef.node_io_can_take_item = function(pos, node, side) return true end
|
nodedef.node_io_can_take_item = function(pos, node, side) return true end
|
||||||
@ -347,6 +351,10 @@ function ele.register_base_device(nodename, nodedef)
|
|||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local stack = ItemStack(want_item)
|
local stack = ItemStack(want_item)
|
||||||
stack:set_count(want_count)
|
stack:set_count(want_count)
|
||||||
|
local t = minetest.get_node_timer(pos)
|
||||||
|
if not t:is_started() then
|
||||||
|
t:start(1.0)
|
||||||
|
end
|
||||||
return inv:take_item("dst", stack)
|
return inv:take_item("dst", stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user