Fix gauges crash when player leaves less than 1 second after joining
This commit is contained in:
parent
6a8e2bf0ea
commit
03ea18339e
1 changed files with 8 additions and 6 deletions
|
@ -44,12 +44,14 @@ minetest.register_entity("gauges:hp_bar", hp_bar)
|
||||||
|
|
||||||
local function add_HP_gauge(name)
|
local function add_HP_gauge(name)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
local pos = player:get_pos()
|
if player then
|
||||||
local ent = minetest.add_entity(pos, "gauges:hp_bar")
|
local pos = player:get_pos()
|
||||||
if ent ~= nil then
|
local ent = minetest.add_entity(pos, "gauges:hp_bar")
|
||||||
ent:set_attach(player, "", {x = 0, y = 10, z = 0}, {x = 0, y = 0, z = 0})
|
if ent ~= nil then
|
||||||
ent = ent:get_luaentity()
|
ent:set_attach(player, "", {x = 0, y = 10, z = 0}, {x = 0, y = 0, z = 0})
|
||||||
ent.wielder = player:get_player_name()
|
ent = ent:get_luaentity()
|
||||||
|
ent.wielder = player:get_player_name()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue