forked from VoxeLibre/VoxeLibre
Fix loosing interact bug in mcl_shields
This commit is contained in:
parent
b136cbf9bb
commit
cffc8e0145
|
@ -211,16 +211,36 @@ local function set_interact(player, interact)
|
|||
return
|
||||
end
|
||||
local meta = player:get_meta()
|
||||
if meta:get_int("mcl_privs:interact_revoked") ~= 1 then
|
||||
privs.interact = interact
|
||||
minetest.set_player_privs(player_name, privs)
|
||||
meta:set_int("mcl_privs:interact_revoked",0)
|
||||
|
||||
if interact and meta:get_int("mcl_shields:interact_revoked") ~= 0 then
|
||||
meta:set_int("mcl_shields:interact_revoked", 0)
|
||||
privs.interact = true
|
||||
elseif not interact then
|
||||
meta:set_int("mcl_shields:interact_revoked", privs.interact and 1 or 0)
|
||||
privs.interact = nil
|
||||
end
|
||||
|
||||
minetest.set_player_privs(player_name, privs)
|
||||
end
|
||||
|
||||
-- Prevent player from being able to circumvent interact privilage removal by
|
||||
-- using shield.
|
||||
minetest.register_on_priv_revoke(function(name, revoker, priv)
|
||||
if priv == "interact" and revoker then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local meta = player:get_meta()
|
||||
meta:set_int("mcl_shields:interact_revoked", 0)
|
||||
end
|
||||
end)
|
||||
|
||||
local shield_hud = {}
|
||||
|
||||
local function remove_shield_hud(player)
|
||||
set_interact(player, true)
|
||||
|
||||
if not shield_hud[player] then return end --this function takes a long time. only run it when necessary
|
||||
player:hud_remove(shield_hud[player])
|
||||
shield_hud[player] = nil
|
||||
|
@ -233,7 +253,6 @@ local function remove_shield_hud(player)
|
|||
end
|
||||
|
||||
playerphysics.remove_physics_factor(player, "speed", "shield_speed")
|
||||
set_interact(player, true)
|
||||
end
|
||||
|
||||
local function add_shield_entity(player, i)
|
||||
|
@ -344,7 +363,7 @@ local function add_shield_hud(shieldstack, player, blocking)
|
|||
z_index = -200,
|
||||
})
|
||||
playerphysics.add_physics_factor(player, "speed", "shield_speed", 0.5)
|
||||
set_interact(player, nil)
|
||||
set_interact(player, false)
|
||||
end
|
||||
|
||||
local function update_shield_hud(player, blocking, shieldstack)
|
||||
|
|
Loading…
Reference in New Issue