feat: disable invisible on sneak
This commit is contained in:
parent
5305b57309
commit
99e5bf15b7
7
init.lua
7
init.lua
@ -8,13 +8,12 @@ minetest.register_privilege("invisible", {
|
||||
give_to_singleplayer = false,
|
||||
})
|
||||
|
||||
invisible.toggle=function(user,sneak)
|
||||
invisible.toggle=function(user)
|
||||
local name=user:get_player_name()
|
||||
if minetest.check_player_privs(user:get_player_name(), {invisible=true}) then
|
||||
if not invisible[name] then
|
||||
user:set_nametag_attributes({color = {a = 0, r = 255, g = 255, b = 255}})
|
||||
invisible[name]={}
|
||||
invisible[name].tool=sneak
|
||||
invisible[name].visual_size=user:get_properties().visual_size
|
||||
invisible[name].textures=user:get_properties().textures
|
||||
user:set_properties({
|
||||
@ -73,9 +72,5 @@ minetest.register_globalstep(function(dtime)
|
||||
invisible.time=0
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local name=player:get_player_name()
|
||||
local sneak=player:get_player_control().sneak
|
||||
if (sneak and not invisible[name]) or (sneak==false and invisible[name] and not invisible[name].tool) then
|
||||
invisible.toggle(player)
|
||||
end
|
||||
end
|
||||
end)
|
Loading…
Reference in New Issue
Block a user