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:
parent
bd68f563bb
commit
aa04eac212
|
@ -174,35 +174,6 @@ for i in ipairs(sides) do
|
||||||
end
|
end
|
||||||
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)
|
function homedecor_place_door(itemstack, placer, pointed_thing, name, side)
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
if homedecor_node_is_owned(pointed_thing.under, placer) == false then
|
if homedecor_node_is_owned(pointed_thing.under, placer) == false then
|
||||||
|
|
66
fences.lua
66
fences.lua
|
@ -15,24 +15,28 @@ minetest.register_node("homedecor:fence_brass", {
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
walkable = true,
|
walkable = true,
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
local fdir = minetest.dir_to_facedir(clicker:get_look_dir())
|
if not homedecor_node_is_owned(pos, clicker) then
|
||||||
local itemstack = clicker:get_wielded_item()
|
local fdir = minetest.dir_to_facedir(clicker:get_look_dir())
|
||||||
if itemstack:get_name() == "default:sign_wall" then
|
local itemstack = clicker:get_wielded_item()
|
||||||
minetest.env:add_node(pos, {name = "homedecor:fence_brass_with_sign", param2 = fdir})
|
if itemstack:get_name() == "default:sign_wall" then
|
||||||
itemstack:take_item()
|
minetest.env:add_node(pos, {name = "homedecor:fence_brass_with_sign", param2 = fdir})
|
||||||
return itemstack
|
itemstack:take_item()
|
||||||
else
|
return itemstack
|
||||||
print("want to simply place the wielded item like usual.")
|
else
|
||||||
-- What goes here if I want to just place the wielded node (dirt, cobble, etc) normally?
|
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
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
if not homedecor_node_is_owned(pointed_thing.under, placer) then
|
||||||
minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_brass", param2 = fdir})
|
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||||
itemstack:take_item()
|
minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_brass", param2 = fdir})
|
||||||
placer:set_wielded_item(itemstack)
|
itemstack:take_item()
|
||||||
return itemstack
|
placer:set_wielded_item(itemstack)
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -51,25 +55,29 @@ minetest.register_node("homedecor:fence_wrought_iron", {
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
walkable = true,
|
walkable = true,
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
local fdir = minetest.dir_to_facedir(clicker:get_look_dir())
|
if not homedecor_node_is_owned(pos, clicker) then
|
||||||
local itemstack = clicker:get_wielded_item()
|
local fdir = minetest.dir_to_facedir(clicker:get_look_dir())
|
||||||
if itemstack:get_name() == "default:sign_wall" then
|
local itemstack = clicker:get_wielded_item()
|
||||||
minetest.env:add_node(pos, {name = "homedecor:fence_wrought_iron_with_sign", param2 = fdir})
|
if itemstack:get_name() == "default:sign_wall" then
|
||||||
itemstack:take_item()
|
minetest.env:add_node(pos, {name = "homedecor:fence_wrought_iron_with_sign", param2 = fdir})
|
||||||
clicker:set_wielded_item(itemstack)
|
itemstack:take_item()
|
||||||
return itemstack
|
clicker:set_wielded_item(itemstack)
|
||||||
else
|
return itemstack
|
||||||
print("want to simply place the wielded item like usual.")
|
else
|
||||||
-- What goes here if I want to just place the wielded node (dirt, cobble, etc) normally?
|
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
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
if not homedecor_node_is_owned(pointed_thing.under, placer) then
|
||||||
minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_wrought_iron", param2 = fdir})
|
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||||
itemstack:take_item()
|
minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_wrought_iron", param2 = fdir})
|
||||||
placer:set_wielded_item(itemstack)
|
itemstack:take_item()
|
||||||
return itemstack
|
placer:set_wielded_item(itemstack)
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
31
init.lua
31
init.lua
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
local DEBUG = 0
|
local DEBUG = 0
|
||||||
|
|
||||||
-- Local Functions
|
-- Various Functions
|
||||||
|
|
||||||
local dbg = function(s)
|
local dbg = function(s)
|
||||||
if DEBUG == 1 then
|
if DEBUG == 1 then
|
||||||
|
@ -21,6 +21,35 @@ local dbg = function(s)
|
||||||
end
|
end
|
||||||
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
|
-- Nodes
|
||||||
|
|
||||||
minetest.register_node('homedecor:shingles_wood', {
|
minetest.register_node('homedecor:shingles_wood', {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user