Add vertical version of airtight pipe entry
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>
Sat, 8 Jun 2013 05:00:49 +0000 (01:00 -0400)
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>
Sat, 8 Jun 2013 05:00:49 +0000 (01:00 -0400)
if automatically rotates to connect to the thing you point at, if a connection
is possible.

autoplace.lua
devices.lua
init.lua

index ddfdb76b3e72d8854b0fd49faf531315abf64522..c58a58b9ec82951d6bd4d1cab47d5ab93666f8d4 100644 (file)
@@ -209,6 +209,17 @@ function pipes_scansurroundings(pos)
                pzp=1
        end
 
+       if (string.find(nym.name, "pipeworks:entry_panel") ~= nil)
+         and nym.param2 == 13 then
+               pym=1
+       end
+
+       if (string.find(nyp.name, "pipeworks:entry_panel") ~= nil)
+         and nyp.param2 == 13 then
+               pyp=1
+       end
+
+
 -- ...pumps, grates...
 
        if (string.find(nym.name, "pipeworks:grating") ~= nil) or
index 3cbf71a9992f2535ee19937ddf5771dcad50180a..a97c29002ca4377d5d5ab582a108afc3c7852c25 100644 (file)
@@ -413,7 +413,58 @@ minetest.register_node("pipeworks:entry_panel_empty", {
                        { -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
                        { -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 }
                }
-       }
+       },
+       on_place = function(itemstack, placer, pointed_thing)
+               if not pipeworks_node_is_owned(pointed_thing.under, placer) 
+                  and not pipeworks_node_is_owned(pointed_thing.above, placer) then
+                       local node = minetest.env:get_node(pointed_thing.under)
+
+                       if not minetest.registered_nodes[node.name]
+                           or not minetest.registered_nodes[node.name].on_rightclick then
+                               local pitch = placer:get_look_pitch()
+                               local above = pointed_thing.above
+                               local under = pointed_thing.under
+                               local fdir = minetest.dir_to_facedir(placer:get_look_dir())
+                               local undernode = minetest.env:get_node(under)
+                               local abovenode = minetest.env:get_node(above)
+                               local uname = undernode.name
+                               local aname = abovenode.name
+                               local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
+                               local pos1 = above
+
+                               if above.x == under.x
+                                   and above.z == under.z
+                                   and ( string.find(uname, "pipeworks:pipe_")
+                                        or string.find(uname, "pipeworks:storage_")
+                                        or string.find(uname, "pipeworks:expansion_")
+                                        or ( string.find(uname, "pipeworks:grating") and not isabove )
+                                        or ( string.find(uname, "pipeworks:pump_") and not isabove )
+                                        or ( string.find(uname, "pipeworks:entry_panel")
+                                             and undernode.param2 == 13 )
+                                        )
+                               then
+                                       fdir = 13
+                               end
+
+                               if minetest.registered_nodes[uname]["buildable_to"] then
+                                       pos1 = under
+                               end
+
+                               if not minetest.registered_nodes[minetest.env:get_node(pos1).name]["buildable_to"] then return end
+
+                               minetest.env:add_node(pos1, {name = "pipeworks:entry_panel_empty", param2 = fdir })
+                               pipe_scanforobjects(pos1)
+
+                               if not pipeworks_expect_infinite_stacks then
+                                       itemstack:take_item()
+                               end
+
+                       else
+                               minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
+                       end
+               end
+               return itemstack
+       end
 })
 
 minetest.register_node("pipeworks:entry_panel_loaded", {
index 87210273c59447935fc4f4d3acdf68a62a6f9c1f..a0b4b72307f635bacd2b81caf91003b3ecc38355 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -114,6 +114,12 @@ pipe_bendsphere = {
 
 --  Functions
 
+if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then
+       pipeworks_expect_infinite_stacks = false
+else
+       pipeworks_expect_infinite_stacks = true
+end
+
 dbg = function(s)
        if DEBUG then
                print('[PIPEWORKS] ' .. s)
@@ -135,6 +141,39 @@ function pipe_addbox(t, b)
        end
 end
 
+function pipeworks_node_is_owned(pos, placer)
+       local ownername = false
+       if type(IsPlayerNodeOwner) == "function" then                                   -- node_ownership mod
+               if HasOwner(pos, placer) then                                           -- returns true if the node is owned
+                       if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
+                               if type(getLastOwner) == "function" then                -- ...is an old version
+                                       ownername = getLastOwner(pos)
+                               elseif type(GetNodeOwnerName) == "function" then        -- ...is a recent version
+                                       ownername = GetNodeOwnerName(pos)
+                               else
+                                       ownername = S("someone")
+                               end
+                       end
+               end
+
+       elseif type(isprotect)=="function" then                                         -- glomie's protection mod
+               if not isprotect(5, pos, placer) then
+                       ownername = S("someone")
+               end
+       elseif type(protector)=="table" and type(protector.can_dig)=="function" then    -- Zeg9's protection mod
+               if not protector.can_dig(5, pos, placer) then
+                       ownername = S("someone")
+               end
+       end
+
+       if ownername ~= false then
+               minetest.chat_send_player( placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
+               return true
+       else
+               return false
+       end
+end
+
 -- now define the nodes!
 
 pipes_empty_nodenames = {}