Fix a bug in Xpro making the game crash when xp_atual is nil
parent
22ba21077a
commit
fd061ac282
1
TODO
1
TODO
|
@ -11,4 +11,5 @@ minetest-solebull - LGPL-2.1 - A PVP/faction game for minetest based on Cobalt.
|
|||
|
||||
|
||||
* v0.0.2-5 (02 Jan. 2019 - ???) CLOC ???,???
|
||||
- Fix a bug in Xpro making the game crash when xp_atual is nil
|
||||
- Add more mc mobs with XPs
|
||||
|
|
|
@ -110,6 +110,13 @@ xpro.add_xp = function(name, xp_add)
|
|||
local tb_name = "jogador_"..name
|
||||
|
||||
local xp_atual = xpro.get_player_xp(name)
|
||||
|
||||
-- In rare case, xp_atual can be nil. So, better than nothing
|
||||
-- do not let the game crash
|
||||
if xp_atual == nil then
|
||||
minetest.log("warning", "xp_atual is nil. Will not add XPs")
|
||||
return
|
||||
end
|
||||
|
||||
-- Evita salvar xp negativo
|
||||
local new_xp = xp_atual+xp_add
|
||||
|
|
Loading…
Reference in New Issue