From 88ad79163dab74d247d6e70aba5ec7b1f7d4a3b8 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Fri, 17 Mar 2017 09:02:34 -0400 Subject: 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. --- flowing_logic.lua | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'flowing_logic.lua') 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 -- cgit v1.2.3