summaryrefslogtreecommitdiff
path: root/flowing_logic.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-05-10 15:59:56 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-05-10 15:59:56 -0400
commitb0d92dd358a6339504783fc0022e970b87af70fb (patch)
treea28818aab80b056a784853da4e604cf826fa5467 /flowing_logic.lua
parent8f12d18b1dc785cd3a3bbbd390554e295aa00738 (diff)
downloadpipeworks-b0d92dd358a6339504783fc0022e970b87af70fb.tar
pipeworks-b0d92dd358a6339504783fc0022e970b87af70fb.tar.gz
pipeworks-b0d92dd358a6339504783fc0022e970b87af70fb.tar.bz2
pipeworks-b0d92dd358a6339504783fc0022e970b87af70fb.tar.xz
pipeworks-b0d92dd358a6339504783fc0022e970b87af70fb.zip
periodically remove one water node next to each "on" pump that's also flowing
This should make it work more or less correctly with finite water. also, fix a bug where a blocked spigot still looks like its pouring, and check for blockages on every step.
Diffstat (limited to 'flowing_logic.lua')
-rw-r--r--flowing_logic.lua21
1 files changed, 12 insertions, 9 deletions
diff --git a/flowing_logic.lua b/flowing_logic.lua
index e943488..7503296 100644
--- a/flowing_logic.lua
+++ b/flowing_logic.lua
@@ -14,7 +14,10 @@ local check4liquids = function(pos)
{x=pos.x,y=pos.y,z=pos.z+1}, }
for i =1,6 do
local name = minetest.env:get_node(coords[i]).name
- if string.find(name,'water') then return true end
+ if string.find(name,'water') then
+ minetest.env:remove_node(coords[i])
+ return true
+ end
end
return false
end
@@ -67,7 +70,8 @@ end
local update_outlet = function(pos)
local top = minetest.env:get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
if string.find(top,'_loaded') then
- if minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == 'air' then
+ local name = minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
+ if name == 'air' or name == "default:water_source" or name == "default:water_flowing" then
minetest.env:add_node({x=pos.x,y=pos.y-1,z=pos.z},{name='default:water_source'})
end
elseif minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == 'default:water_source' then
@@ -81,14 +85,13 @@ local spigot_check = function(pos,node)
dbg(fdir..' checking '..minetest.pos_to_string(check[fdir+1])..' for spigot at '..minetest.pos_to_string(pos))
local top = minetest.env:get_node(check[fdir+1]).name
dbg('found '..top)
- if string.find(top,'_loaded') then
- minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{name='pipeworks:spigot_pouring', param2 = fdir})
- if minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == 'air' then
- minetest.env:add_node({x=pos.x,y=pos.y-1,z=pos.z},{name='default:water_source'})
- end
+ local name = minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
+ if string.find(top,'_loaded') and (name == 'air' or name == "default:water_source" or name == "default:water_flowing") then
+ minetest.env:add_node({x=pos.x,y=pos.y-1,z=pos.z},{name='default:water_source'})
+ minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{name='pipeworks:spigot_pouring', param2 = fdir})
else
- minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{name='pipeworks:spigot', param2 = fdir})
- if minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == 'default:water_source' then
+ minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{name='pipeworks:spigot', param2 = fdir})
+ if name == 'air' or name == "default:water_source" or name == "default:water_flowing" then
minetest.env:remove_node({x=pos.x,y=pos.y-1,z=pos.z})
end
end