Fix gauges crash when player leaves less than 1 second after joining

This commit is contained in:
rubenwardy 2017-10-12 19:20:43 +01:00
parent 6a8e2bf0ea
commit 03ea18339e

View file

@ -44,12 +44,14 @@ minetest.register_entity("gauges:hp_bar", hp_bar)
local function add_HP_gauge(name)
local player = minetest.get_player_by_name(name)
local pos = player:get_pos()
local ent = minetest.add_entity(pos, "gauges:hp_bar")
if ent ~= nil then
ent:set_attach(player, "", {x = 0, y = 10, z = 0}, {x = 0, y = 0, z = 0})
ent = ent:get_luaentity()
ent.wielder = player:get_player_name()
if player then
local pos = player:get_pos()
local ent = minetest.add_entity(pos, "gauges:hp_bar")
if ent ~= nil then
ent:set_attach(player, "", {x = 0, y = 10, z = 0}, {x = 0, y = 0, z = 0})
ent = ent:get_luaentity()
ent.wielder = player:get_player_name()
end
end
end