Fix mobs crash on no XP found

This commit is contained in:
rubenwardy 2016-07-08 18:25:47 +01:00
parent 2b976e3dc7
commit b5a4a889ea
2 changed files with 21 additions and 20 deletions

View File

@ -135,8 +135,8 @@ function mobs.register_mob(name, def)
end
function mobs.get_mob(lvl)
a = {}
found_mob = false
local a = {}
local found_mob = false
for i,n in ipairs(mobs.mobs) do
if n[2] < lvl +5 and n[2] > lvl-5 then
found_mob = true
@ -380,4 +380,3 @@ mobs.register_mob("mobs:lava_flower", {
range = 2,
drops = {"money:coin 2"}
})

View File

@ -71,6 +71,8 @@ minetest.register_on_joinplayer(function(player)
offset = {x=0, y=-(48*2+16)},
})
else
xp.player_xp[player:get_player_name()] = 0
xp.player_levels[player:get_player_name()] = 1
xp.xp_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = {x=0.5,y=1.0},