testing node ownership workaround for one of the doors. Others to follow.

This commit is contained in:
Vanessa Ezekowitz 2012-10-09 04:18:31 -04:00
parent b099d5717c
commit ead549405e

View File

@ -70,6 +70,12 @@ minetest.register_node("homedecor:door_wood_plain_bottom_left", {
fixed = { -0.5, -0.5, 6/16, 0.5, 0.5, 8/16 } fixed = { -0.5, -0.5, 6/16, 0.5, 0.5, 8/16 }
}, },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if type(IsPlayerNodeOwner)=="function" then
if not IsPlayerNodeOwner(pos, user:get_player_name()) then
minetest.chat_send_player( placer:get_player_name(), "Sorry, "..getLastOwner(pos).." owns that spot." )
end
else
fdir = minetest.dir_to_facedir(placer:get_look_dir()) fdir = minetest.dir_to_facedir(placer:get_look_dir())
local pos = pointed_thing.above local pos = pointed_thing.above
if minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "air" then if minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "air" then
@ -78,6 +84,7 @@ minetest.register_node("homedecor:door_wood_plain_bottom_left", {
end end
minetest.env:add_node({x=pos.x, y=pos.y+1, z=pos.z}, { name = "homedecor:door_wood_plain_top_left", param2=fdir}) minetest.env:add_node({x=pos.x, y=pos.y+1, z=pos.z}, { name = "homedecor:door_wood_plain_top_left", param2=fdir})
return minetest.item_place(itemstack, placer, pointed_thing) return minetest.item_place(itemstack, placer, pointed_thing)
end
end, end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
@ -164,6 +171,11 @@ minetest.register_node("homedecor:door_wood_plain_bottom_right", {
}, },
drop = "homedecor:door_wood_plain_bottom_left", drop = "homedecor:door_wood_plain_bottom_left",
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if type(IsPlayerNodeOwner)=="function" then
if not IsPlayerNodeOwner(pos, user:get_player_name()) then
minetest.chat_send_player( placer:get_player_name(), "Sorry, "..getLastOwner(pos).." owns that spot." )
end
else
fdir = minetest.dir_to_facedir(placer:get_look_dir()) fdir = minetest.dir_to_facedir(placer:get_look_dir())
local pos = pointed_thing.above local pos = pointed_thing.above
if minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "air" then if minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "air" then
@ -172,6 +184,7 @@ minetest.register_node("homedecor:door_wood_plain_bottom_right", {
end end
minetest.env:add_node({x=pos.x, y=pos.y+1, z=pos.z}, { name = "homedecor:door_wood_plain_top_right", param2=fdir}) minetest.env:add_node({x=pos.x, y=pos.y+1, z=pos.z}, { name = "homedecor:door_wood_plain_top_right", param2=fdir})
return minetest.item_place(itemstack, placer, pointed_thing) return minetest.item_place(itemstack, placer, pointed_thing)
end
end, end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)