diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-03-17 09:02:34 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-03-17 10:07:34 -0400 |
commit | 88ad79163dab74d247d6e70aba5ec7b1f7d4a3b8 (patch) | |
tree | e9b38d370410b17eb0ee59098de9b8899a5368cf /flowing_logic.lua | |
parent | bd4a27d1722a8e31a5f47a2405f1f9a3871e3341 (diff) |
add screwdriver rotation handling on most pipes-related nodes
caveats: in order to cleanly handle the entry panel, valve, and sensor
I had to rotate the valve and sensor models 90 degrees
so that their in-/outlet pipes point the same direction as the
entry panel.
This also enables proper handling of a valve or sensor turned vertically.
Some objects have rotation disabled entirely (as flipping them over/around makes
no sense)
When a valve is rotated, it is turned off automatically, to work around a glitch in
the rotation code.
Diffstat (limited to 'flowing_logic.lua')
-rw-r--r-- | flowing_logic.lua | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/flowing_logic.lua b/flowing_logic.lua index 5166b15..e1c0bf5 100644 --- a/flowing_logic.lua +++ b/flowing_logic.lua @@ -31,19 +31,32 @@ pipeworks.check_for_inflows = function(pos,node) {x=pos.x-1,y=pos.y,z=pos.z}, {x=pos.x+1,y=pos.y,z=pos.z}, {x=pos.x,y=pos.y,z=pos.z-1}, - {x=pos.x,y=pos.y,z=pos.z+1}, } + {x=pos.x,y=pos.y,z=pos.z+1}, + } local newnode = false local source = false - for i =1,6 do + for i = 1, 6 do if newnode then break end - local name = minetest.get_node(coords[i]).name + local testnode = minetest.get_node(coords[i]) + local name = testnode.name if name and (name == "pipeworks:pump_on" and pipeworks.check_for_liquids(coords[i])) or string.find(name,"_loaded") then if string.find(name,"_loaded") then source = minetest.get_meta(coords[i]):get_string("source") if source == minetest.pos_to_string(pos) then break end end - newnode = string.gsub(node.name,"empty","loaded") - source = {x=coords[i].x,y=coords[i].y,z=coords[i].z} + if string.find(name, "valve") or string.find(name, "sensor") then + + if ((i == 3 or i == 4) and minetest.facedir_to_dir(testnode.param2).x ~= 0) + or ((i == 5 or i == 6) and minetest.facedir_to_dir(testnode.param2).z ~= 0) + or ((i == 1 or i == 2) and minetest.facedir_to_dir(testnode.param2).y ~= 0) then + + newnode = string.gsub(node.name,"empty","loaded") + source = {x=coords[i].x,y=coords[i].y,z=coords[i].z} + end + else + newnode = string.gsub(node.name,"empty","loaded") + source = {x=coords[i].x,y=coords[i].y,z=coords[i].z} + end end end if newnode then |