Properly track players' LMB keypresses
Fixes automatic fire continuing after player's death and respawn
This commit is contained in:
parent
b8b1c6d368
commit
bc0fc7f43c
2 changed files with 7 additions and 4 deletions
|
@ -551,3 +551,7 @@ end
|
|||
shooter.set_shooting = function(name, is_shooting)
|
||||
shooting[name] = is_shooting and true or nil
|
||||
end
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
shooting[player:get_player_name()] = nil
|
||||
end)
|
||||
|
|
|
@ -67,11 +67,10 @@ minetest.register_entity("shooter:turret_entity", {
|
|||
|
||||
if shooter.config.automatic_weapons == true then
|
||||
minetest.register_globalstep(function()
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
if name then
|
||||
shooter.set_shooting(name,
|
||||
player:get_player_control().LMB == true)
|
||||
if shooter.get_shooting(name) and not player:get_player_control().LMB then
|
||||
shooter.set_shooting(name, nil)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Reference in a new issue