1
0
mirror of https://github.com/Sokomine/cottages.git synced 2024-11-13 05:50:30 +01:00

more protection logic fixes

This commit is contained in:
flux 2022-10-10 14:35:32 -07:00
parent c087e513ff
commit 05cd830f98
No known key found for this signature in database
GPG Key ID: 9333B27816848A15

View File

@ -15,31 +15,33 @@ function util.player_can_use(pos, player)
local owner = meta:get_string("owner")
local public = meta:get_int("public")
return (
(owner == player_name or owner == "" or owner == " ") or
public > 0
)
if owner == player_name then
return true
elseif owner == "" or owner == " " or public == 1 then
return not minetest.is_protected(pos, player_name)
else
return true
end
end
function util.toggle_public(pos, sender)
local sender_name = sender:get_player_name()
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local public = meta:get_string("public")
if public == "public" then
public = 2
meta:set_int("public", 2)
else
public = meta:get_int("public")
end
if (owner == "" or owner == " ") and not minetest.is_protected(pos, sender_name) then
meta:set_string("owner", sender_name)
owner = sender_name
end
if meta:get_string("public") == "public" then
meta:set_int("public", 2)
end
local public = meta:get_int("public")
if public == 0 and owner == sender_name then
-- owner can switch private to protected
meta:set_int("public", 1)