1
0
mirror of https://github.com/Sokomine/replacer.git synced 2024-11-15 06:10:21 +01:00
replacer/check_owner.lua

45 lines
1.8 KiB
Lua
Raw Normal View History

-- taken from Vanessa Ezekowitz' homedecor mod
-- see http://forum.minetest.net/viewtopic.php?pid=26061 or https://github.com/VanessaE/homedecor for details!
2013-02-02 03:21:23 +01:00
function replacer_homedecor_node_is_owned(pos, placer)
2017-12-09 20:20:43 +01:00
if( not( placer ) or not(pos )) then
return true;
end
local pname = placer:get_player_name();
if (type( minetest.is_protected ) == "function") then
local res = minetest.is_protected( pos, pname );
if( res ) then
minetest.chat_send_player( pname, "Cannot replace node. It is protected." );
end
return res;
end
2013-02-02 03:21:23 +01:00
local ownername = false
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
if HasOwner(pos, placer) then -- returns true if the node is owned
2017-12-09 20:20:43 +01:00
if not IsPlayerNodeOwner(pos, pname) then
2013-02-02 03:21:23 +01:00
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
2017-12-09 20:20:43 +01:00
minetest.chat_send_player( pname, "Sorry, "..ownername.." owns that spot." )
2013-02-02 03:21:23 +01:00
return true
else
return false
end
end