diff options
| author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2013-06-08 01:00:49 -0400 | 
|---|---|---|
| committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2013-06-08 01:00:49 -0400 | 
| commit | b68a66ef4ac159705a734df967e3fe29a87aeaaf (patch) | |
| tree | 2e71d71a22ac6ab06b5d051b839c15ee8bd84648 | |
| parent | a6faa00bdfc82be521c2c2a23246dabe7c401b14 (diff) | |
Add vertical version of airtight pipe entry
if automatically rotates to connect to the thing you point at, if a connection
is possible.
| -rw-r--r-- | autoplace.lua | 11 | ||||
| -rw-r--r-- | devices.lua | 53 | ||||
| -rw-r--r-- | init.lua | 39 | 
3 files changed, 102 insertions, 1 deletions
| diff --git a/autoplace.lua b/autoplace.lua index ddfdb76..c58a58b 100644 --- a/autoplace.lua +++ b/autoplace.lua @@ -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 diff --git a/devices.lua b/devices.lua index 3cbf71a..a97c290 100644 --- a/devices.lua +++ b/devices.lua @@ -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", { @@ -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 = {} | 
