{ -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", {
-- 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)
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 = {}