1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-09 13:37:02 +02:00

Update show_health.lua

Fixed to it doesn't trigger when the player dies.
This commit is contained in:
Gerkiz 2019-07-03 21:29:31 +02:00 committed by GitHub
parent cedffd65a8
commit a55f882b7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ local game = require 'utils.game'
event.add(defines.events.on_entity_damaged, function(event)
if event.entity.name ~= 'character' then return end
local player = game.get_player(event.entity.player)
if not player.character then return end
if player.character then
if player.character.health == nil then return end
local index = player.index
@ -23,4 +24,4 @@ event.add(defines.events.on_entity_damaged, function(event)
global.player_health[index] = health
end
end
end)
end)