Compare commits

..

No commits in common. "5b7d61d7d97904ba02e1d32cb37b88edfadca875" and "4b9b42c4091b48bea8323fd99f49770a863cf8d0" have entirely different histories.

3 changed files with 10 additions and 49 deletions

View File

@ -34,7 +34,6 @@ function fluid_lib.register_extractor_node(nodename, nodedef)
nodedef.on_punch = function (pos, node, puncher, pointed_thing) nodedef.on_punch = function (pos, node, puncher, pointed_thing)
minetest.get_node_timer(pos):start(1.0) minetest.get_node_timer(pos):start(1.0)
minetest.chat_send_player(puncher:get_player_name(),"Pump Started")
minetest.node_punch(pos, node, puncher, pointed_thing) minetest.node_punch(pos, node, puncher, pointed_thing)
end end

View File

@ -124,13 +124,12 @@ end
function fluid_lib.transfer_timer_tick(pos, elapsed) function fluid_lib.transfer_timer_tick(pos, elapsed)
local refresh = true local refresh = true
local node = minetest.get_node_or_nil(pos) local node = minetest.get_node_or_nil(pos)
local status = "Fluid Pump"
if not node then if not node then
return false return false
end end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local targets = {} local targets = {}
-- 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
@ -145,9 +144,9 @@ function fluid_lib.transfer_timer_tick(pos, elapsed)
-- Retrieve network -- Retrieve network
targets = fluid_targets(pos, tpos) targets = fluid_targets(pos, tpos)
-- No targets, don't proceed -- No targets, don't proceed
if #targets == 0 then if #targets == 0 then
meta:set_string("infotext", status.."\nNo Recieving Tank")
return true return true
end end
@ -157,7 +156,6 @@ function fluid_lib.transfer_timer_tick(pos, elapsed)
-- Make sure source node is not air -- Make sure source node is not air
if not srcnode or srcnode.name == "air" then if not srcnode or srcnode.name == "air" then
meta:set_string("infotext", status.."\nNo Source Tank")
return true return true
end end
@ -165,15 +163,11 @@ function fluid_lib.transfer_timer_tick(pos, elapsed)
-- Make sure source node is a registered fluid container -- Make sure source node is a registered fluid container
if not srcdef or not srcdef['node_io_can_take_liquid'] then if not srcdef or not srcdef['node_io_can_take_liquid'] then
meta:set_string("infotext", status.." Off")
return false return false
end end
local c = srcdef.node_io_can_take_liquid(srcpos, srcnode, "") local c = srcdef.node_io_can_take_liquid(srcpos, srcnode, "")
if not c then if not c then return false end
meta:set_string("infotext", status.." Off")
return false
end
local srcmeta = minetest.get_meta(srcpos) local srcmeta = minetest.get_meta(srcpos)
local fl_size = srcdef.node_io_get_liquid_size(srcpos, srcnode, "") local fl_size = srcdef.node_io_get_liquid_size(srcpos, srcnode, "")
@ -181,10 +175,7 @@ function fluid_lib.transfer_timer_tick(pos, elapsed)
for i = 1, fl_size do for i = 1, fl_size do
buffers[i] = srcdef.node_io_get_liquid_name(srcpos, srcnode, "", i) buffers[i] = srcdef.node_io_get_liquid_name(srcpos, srcnode, "", i)
end end
if not #buffers then if not #buffers then return true end
meta:set_string("infotext", status.."\nNo Source Tank")
return true
end
-- Limit the amount of fluid pumped per cycle -- Limit the amount of fluid pumped per cycle
local pcapability = get_node_property(meta, pos, "fluid_pump_capacity") local pcapability = get_node_property(meta, pos, "fluid_pump_capacity")
@ -193,9 +184,7 @@ function fluid_lib.transfer_timer_tick(pos, elapsed)
-- Transfer some fluid here -- Transfer some fluid here
for _,pos in pairs(targets) do for _,pos in pairs(targets) do
if not vector.equals(pos, srcpos) then if not vector.equals(pos, srcpos) then
if pumped >= pcapability then break end if pumped >= pcapability then break end
local destnode = minetest.get_node(pos) local destnode = minetest.get_node(pos)
local destdef = minetest.registered_nodes[destnode.name] local destdef = minetest.registered_nodes[destnode.name]
local pp = nil local pp = nil
@ -214,48 +203,24 @@ function fluid_lib.transfer_timer_tick(pos, elapsed)
local changed = false local changed = false
if pp ~= nil then if pp ~= nil then
for bindex,bfluid in pairs(pp) do -- bfluid = destination fluid name for bindex,bfluid in pairs(pp) do
for aindex,afluid in pairs(buffers) do -- afluid = source fluid name for aindex,afluid in pairs(buffers) do
if pumped >= pcapability then break end
-- get fluid names for pump status if (afluid == bfluid or bfluid == "") then
local bfluid_des = "" local idef = destdef.node_io_room_for_liquid(pos, destnode, "", afluid, pcapability)
local afluid_des = ""
if bfluid ~= "" then
bfluid_des = minetest.registered_nodes[bfluid].description
end
if afluid ~= "" then
afluid_des = minetest.registered_nodes[afluid].description
end
if pumped >= pcapability then
meta:set_string("infotext", status.."\nPumped Max Volume".." "..bfluid_des)
break
end
if (afluid == bfluid or bfluid == "") then -- bfluid = "", empty destiniation
local idef = destdef.node_io_room_for_liquid(pos, destnode, "", afluid, pcapability)
if idef > 0 then if idef > 0 then
local fluidcount = srcdef.node_io_get_liquid_stack(srcpos, srcnode, "", aindex):get_count() local fluidcount = srcdef.node_io_get_liquid_stack(srcpos, srcnode, "", aindex):get_count()
local defc = math.min(fluidcount, idef) local defc = math.min(fluidcount, idef)
local defi = srcdef.node_io_take_liquid(srcpos, srcnode, "", nil, afluid, defc) local defi = srcdef.node_io_take_liquid(srcpos, srcnode, "", nil, afluid, defc)
if defi and defi.millibuckets > 0 then if defi and defi.millibuckets > 0 then
local lo = destdef.node_io_put_liquid(pos, destnode, "", nil, afluid, defi.millibuckets) local lo = destdef.node_io_put_liquid(pos, destnode, "", nil, afluid, defi.millibuckets)
pumped = pumped + (defi.millibuckets - lo) pumped = pumped + (defi.millibuckets - lo)
meta:set_string("infotext", status.."\nPumping "..afluid_des)
changed = true changed = true
end end
else
meta:set_string("infotext", status.."\nStandby")
end end
end end
end end
end end
else
meta:set_string("infotext", status.."\nStandby")
end end
if changed then if changed then
@ -264,7 +229,7 @@ function fluid_lib.transfer_timer_tick(pos, elapsed)
end end
end end
end end
return refresh return refresh
end end

View File

@ -2,7 +2,6 @@
fluid_lib.register_extractor_node("fluid_transfer:fluid_transfer_pump", { fluid_lib.register_extractor_node("fluid_transfer:fluid_transfer_pump", {
description = "Fluid Transfer Pump\nPunch to start pumping", description = "Fluid Transfer Pump\nPunch to start pumping",
tiles = {"fluid_transfer_pump.png"}, tiles = {"fluid_transfer_pump.png"},
use_texture_alpha = "clip",
drawtype = "mesh", drawtype = "mesh",
mesh = "fluid_transfer_pump.obj", mesh = "fluid_transfer_pump.obj",
groups = {oddly_breakable_by_hand = 1, cracky = 1}, groups = {oddly_breakable_by_hand = 1, cracky = 1},
@ -19,7 +18,6 @@ fluid_lib.register_extractor_node("fluid_transfer:fluid_transfer_pump", {
fluid_lib.register_transfer_node("fluid_transfer:fluid_duct", { fluid_lib.register_transfer_node("fluid_transfer:fluid_duct", {
description = "Fluid Duct", description = "Fluid Duct",
tiles = {"fluid_transfer_duct.png"}, tiles = {"fluid_transfer_duct.png"},
use_texture_alpha = "clip",
groups = {oddly_breakable_by_hand = 1, cracky = 1} groups = {oddly_breakable_by_hand = 1, cracky = 1}
}) })
@ -28,7 +26,6 @@ minetest.register_node("fluid_transfer:fluid_trash", {
drawtype = "mesh", drawtype = "mesh",
mesh = "fluid_transfer_trash.obj", mesh = "fluid_transfer_trash.obj",
tiles = {"fluid_transfer_trash.png"}, tiles = {"fluid_transfer_trash.png"},
use_texture_alpha = "clip",
groups = {oddly_breakable_by_hand = 1, cracky = 1, fluid_container = 1}, groups = {oddly_breakable_by_hand = 1, cracky = 1, fluid_container = 1},
node_io_can_put_liquid = function (pos, node, side) node_io_can_put_liquid = function (pos, node, side)
return true return true