mirror of
https://codeberg.org/Wuzzy/pride_flags.git
synced 2025-03-15 04:41:21 +00:00
No longer need server priv to change flag, check protection instead
This commit is contained in:
parent
889744fc7a
commit
7698ceebd0
2 changed files with 22 additions and 18 deletions
|
@ -10,8 +10,7 @@ conspicuous location, such as atop a building or along a promenade.
|
|||
/giveme pride_flags:mast_upper
|
||||
|
||||
Initially, the rainbow pride flag will appear when the upper mast is placed.
|
||||
Right-click or punch the node to select a different flag
|
||||
(this requires the "server" privilege).
|
||||
Right-click or punch the node to select a different flag.
|
||||
|
||||
|
||||
Repository
|
||||
|
|
37
init.lua
37
init.lua
|
@ -256,26 +256,31 @@ local function spawn_flag_and_set_texture( pos )
|
|||
end
|
||||
|
||||
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 )
|
||||
|
||||
if minetest.check_player_privs( player:get_player_name( ), "server" ) then
|
||||
local aflag = active_flags[ node_idx ]
|
||||
local flag
|
||||
if aflag then
|
||||
flag = aflag:get_luaentity( )
|
||||
end
|
||||
if flag then
|
||||
local flag_idx
|
||||
if cycle_backwards then
|
||||
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)
|
||||
local aflag = active_flags[ node_idx ]
|
||||
local flag
|
||||
if aflag then
|
||||
flag = aflag:get_luaentity( )
|
||||
end
|
||||
if flag then
|
||||
local flag_idx
|
||||
if cycle_backwards then
|
||||
flag_idx = flag:reset_texture( -1 )
|
||||
else
|
||||
spawn_flag_and_set_texture( pos )
|
||||
flag_idx = flag:reset_texture( )
|
||||
end
|
||||
local meta = minetest.get_meta( pos )
|
||||
meta:set_int("flag_idx", flag_idx)
|
||||
else
|
||||
spawn_flag_and_set_texture( pos )
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue