1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-11-14 14:20:37 +01:00

made signs check for node ownership/protection before allowing placement.

This commit is contained in:
Vanessa Ezekowitz 2013-02-10 19:23:29 -05:00
parent bd68f563bb
commit aa04eac212
3 changed files with 67 additions and 59 deletions

View File

@ -174,35 +174,6 @@ for i in ipairs(sides) do
end
end
function homedecor_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 = "someone"
end
end
end
elseif type(isprotect)=="function" then -- glomie's protection mod
if not isprotect(5, pos, placer) then
ownername = "someone"
end
end
if ownername ~= false then
minetest.chat_send_player( placer:get_player_name(), "Sorry, "..ownername.." owns that spot." )
return true
else
return false
end
end
function homedecor_place_door(itemstack, placer, pointed_thing, name, side)
local pos = pointed_thing.above
if homedecor_node_is_owned(pointed_thing.under, placer) == false then

View File

@ -15,24 +15,28 @@ minetest.register_node("homedecor:fence_brass", {
sounds = default.node_sound_wood_defaults(),
walkable = true,
on_rightclick = function(pos, node, clicker)
local fdir = minetest.dir_to_facedir(clicker:get_look_dir())
local itemstack = clicker:get_wielded_item()
if itemstack:get_name() == "default:sign_wall" then
minetest.env:add_node(pos, {name = "homedecor:fence_brass_with_sign", param2 = fdir})
itemstack:take_item()
return itemstack
else
print("want to simply place the wielded item like usual.")
-- What goes here if I want to just place the wielded node (dirt, cobble, etc) normally?
if not homedecor_node_is_owned(pos, clicker) then
local fdir = minetest.dir_to_facedir(clicker:get_look_dir())
local itemstack = clicker:get_wielded_item()
if itemstack:get_name() == "default:sign_wall" then
minetest.env:add_node(pos, {name = "homedecor:fence_brass_with_sign", param2 = fdir})
itemstack:take_item()
return itemstack
else
print("want to simply place the wielded item like usual.")
-- What goes here if I want to just place the wielded node (dirt, cobble, etc) normally?
end
end
end,
on_place = function(itemstack, placer, pointed_thing)
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_brass", param2 = fdir})
itemstack:take_item()
placer:set_wielded_item(itemstack)
return itemstack
if not homedecor_node_is_owned(pointed_thing.under, placer) then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_brass", param2 = fdir})
itemstack:take_item()
placer:set_wielded_item(itemstack)
return itemstack
end
end
})
@ -51,25 +55,29 @@ minetest.register_node("homedecor:fence_wrought_iron", {
sounds = default.node_sound_wood_defaults(),
walkable = true,
on_rightclick = function(pos, node, clicker)
local fdir = minetest.dir_to_facedir(clicker:get_look_dir())
local itemstack = clicker:get_wielded_item()
if itemstack:get_name() == "default:sign_wall" then
minetest.env:add_node(pos, {name = "homedecor:fence_wrought_iron_with_sign", param2 = fdir})
itemstack:take_item()
clicker:set_wielded_item(itemstack)
return itemstack
else
print("want to simply place the wielded item like usual.")
-- What goes here if I want to just place the wielded node (dirt, cobble, etc) normally?
if not homedecor_node_is_owned(pos, clicker) then
local fdir = minetest.dir_to_facedir(clicker:get_look_dir())
local itemstack = clicker:get_wielded_item()
if itemstack:get_name() == "default:sign_wall" then
minetest.env:add_node(pos, {name = "homedecor:fence_wrought_iron_with_sign", param2 = fdir})
itemstack:take_item()
clicker:set_wielded_item(itemstack)
return itemstack
else
print("want to simply place the wielded item like usual.")
-- What goes here if I want to just place the wielded node (dirt, cobble, etc) normally?
end
end
end,
on_place = function(itemstack, placer, pointed_thing)
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_wrought_iron", param2 = fdir})
itemstack:take_item()
placer:set_wielded_item(itemstack)
return itemstack
if not homedecor_node_is_owned(pointed_thing.under, placer) then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_wrought_iron", param2 = fdir})
itemstack:take_item()
placer:set_wielded_item(itemstack)
return itemstack
end
end
})

View File

@ -13,7 +13,7 @@
local DEBUG = 0
-- Local Functions
-- Various Functions
local dbg = function(s)
if DEBUG == 1 then
@ -21,6 +21,35 @@ local dbg = function(s)
end
end
function homedecor_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 = "someone"
end
end
end
elseif type(isprotect)=="function" then -- glomie's protection mod
if not isprotect(5, pos, placer) then
ownername = "someone"
end
end
if ownername ~= false then
minetest.chat_send_player( placer:get_player_name(), "Sorry, "..ownername.." owns that spot." )
return true
else
return false
end
end
-- Nodes
minetest.register_node('homedecor:shingles_wood', {