mirror of
https://github.com/sirrobzeroone/elepower.git
synced 2024-08-20 12:54:05 +02:00
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)
|
||||
local node = minetest.get_node(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
|
||||
add_duct_node(all_nodes, pos, pnodeid, queue)
|
||||
return
|
||||
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
|
||||
end
|
||||
|
||||
@ -67,7 +68,7 @@ local function fluid_targets(p_pos, pos)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if node and ele.helpers.get_item_group(node.name, "elefluid_transport") then
|
||||
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}
|
||||
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
|
||||
local tpos = vector.add(minetest.facedir_to_dir(node.param2), pos)
|
||||
local tname = minetest.get_node(tpos).name
|
||||
local ndef = minetest.registered_nodes[tname]
|
||||
if not ele.helpers.get_item_group(tname, "elefluid_transport") and
|
||||
not ndef['node_io_put_liquid'] and ndef['node_io_room_for_liquid'] then
|
||||
local tnode = minetest.get_node(tpos)
|
||||
local ndef = minetest.registered_nodes[tnode.name]
|
||||
if not ele.helpers.get_item_group(tnode.name, "elefluid_transport") and
|
||||
(not ndef['node_io_can_put_liquid'] or not ndef['node_io_can_put_liquid'](tpos, tnode, "")) then
|
||||
minetest.forceload_free_block(pos)
|
||||
return
|
||||
end
|
||||
@ -126,7 +127,7 @@ function elefluid.transfer_timer_tick(pos, elapsed)
|
||||
local srcdef = minetest.registered_nodes[srcnode.name]
|
||||
|
||||
-- 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
|
||||
end
|
||||
|
||||
@ -172,15 +173,16 @@ function elefluid.transfer_timer_tick(pos, elapsed)
|
||||
for aindex,afluid in pairs(buffers) do
|
||||
if pumped >= pcapability then break end
|
||||
if (afluid == bfluid or bfluid == "") then
|
||||
local defi = srcdef.node_io_take_liquid(srcpos, srcnode, "", nil, afluid, pcapability)
|
||||
if defi.millibuckets > 0 then
|
||||
local idef = destdef.node_io_room_for_liquid(pos, destnode, "", afluid, defi.millibuckets)
|
||||
if idef > 0 then
|
||||
local lo = destdef.node_io_put_liquid(pos, destnode, "", nil, afluid, idef)
|
||||
idef = idef - lo
|
||||
local idef = destdef.node_io_room_for_liquid(pos, destnode, "", afluid, pcapability)
|
||||
if idef > 0 then
|
||||
local fluidcount = srcdef.node_io_get_liquid_stack(srcpos, srcnode, "", aindex):get_count()
|
||||
local defc = math.min(fluidcount, idef)
|
||||
local defi = srcdef.node_io_take_liquid(srcpos, srcnode, "", nil, afluid, defc)
|
||||
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
|
||||
pumped = pumped + idef
|
||||
changed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -67,3 +67,5 @@ minetest.register_abm({
|
||||
meta:set_string("infotext", fluid_lib.buffer_to_string(buffer))
|
||||
end
|
||||
})
|
||||
|
||||
fluid_lib.register_node("elepower_farming:tree_extractor")
|
||||
|
@ -59,6 +59,9 @@ minetest.register_abm({
|
||||
buffer.amount = buffer.amount + give
|
||||
|
||||
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))
|
||||
end
|
||||
})
|
||||
|
||||
fluid_lib.register_node("elepower_machines:accumulator")
|
||||
|
@ -312,7 +312,7 @@ function ele.register_base_device(nodename, nodedef)
|
||||
end
|
||||
|
||||
-- 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_room_for_item = function(pos, node, side, itemstack, count)
|
||||
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)
|
||||
local meta = minetest.get_meta(pos)
|
||||
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)
|
||||
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 stack = ItemStack(want_item)
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user