No longer need server priv to change flag, check protection instead

This commit is contained in:
Wuzzy 2022-07-04 18:33:06 +02:00
parent 889744fc7a
commit 7698ceebd0
2 changed files with 22 additions and 18 deletions

View file

@ -10,8 +10,7 @@ conspicuous location, such as atop a building or along a promenade.
/giveme pride_flags:mast_upper /giveme pride_flags:mast_upper
Initially, the rainbow pride flag will appear when the upper mast is placed. Initially, the rainbow pride flag will appear when the upper mast is placed.
Right-click or punch the node to select a different flag Right-click or punch the node to select a different flag.
(this requires the "server" privilege).
Repository Repository

View file

@ -256,26 +256,31 @@ local function spawn_flag_and_set_texture( pos )
end end
local function cycle_flag( pos, player, cycle_backwards ) local function cycle_flag( pos, player, cycle_backwards )
local pname = player:get_player_name( )
if minetest.is_protected( pos, pname ) and not
minetest.check_player_privs( pname, "protection_bypass") then
minetest.register_protection_violation( pos, pname )
return
end
local node_idx = minetest.hash_node_position( pos ) local node_idx = minetest.hash_node_position( pos )
if minetest.check_player_privs( player:get_player_name( ), "server" ) then local aflag = active_flags[ node_idx ]
local aflag = active_flags[ node_idx ] local flag
local flag if aflag then
if aflag then flag = aflag:get_luaentity( )
flag = aflag:get_luaentity( ) end
end if flag then
if flag then local flag_idx
local flag_idx if cycle_backwards then
if cycle_backwards then flag_idx = flag:reset_texture( -1 )
flag_idx = flag:reset_texture( -1 )
else
flag_idx = flag:reset_texture( )
end
local meta = minetest.get_meta( pos )
meta:set_int("flag_idx", flag_idx)
else else
spawn_flag_and_set_texture( pos ) flag_idx = flag:reset_texture( )
end end
local meta = minetest.get_meta( pos )
meta:set_int("flag_idx", flag_idx)
else
spawn_flag_and_set_texture( pos )
end end
end end