Fix sniper crosshairs being active after death (#726)

* Fix bug with crosshairs active after death

(hopefully) fixes issue with crosshairs remaining after player death. Requires testing.
How to test:
- die while scoped

Normally I would do this but I am unable to get to a proper platform to test.

* Use function

Slipped my mind, sorry :P

* Fix typo, comment

Fixed typo in line 100, also fixed comment for dieplayer function
This commit is contained in:
Apelta 2020-12-26 23:01:36 -06:00 committed by GitHub
parent fbf0126599
commit 2f3b09ff70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,6 +63,13 @@ local function hide_scope(name)
end
-- Be absolutely certain crosshair HUD gets removed on death
minetest.register_on_dieplayer(function(player)
if scoped_hud_id[player:get_player_name()] then
hide_scope(player:get_player_name())
end
end)
local function on_use(stack, user, pointed)
if scoped[user:get_player_name()] then
-- shooter checks for the return value of def.on_use, and executes
@ -90,7 +97,7 @@ local function on_rclick(item, placer, pointed_thing)
end
------------------
-- Sccope-check --
-- Scope-check --
------------------
-- Hide scope if currently wielded item is not the same item