[bug fix] xp system fix
This commit is contained in:
parent
8ce447e6ca
commit
6fe74e6f8c
@ -19,7 +19,7 @@ function xp.add_xp(player, num)
|
||||
|
||||
if xp.player_levels[player:get_player_name()] then
|
||||
if xp.player_xp[player:get_player_name()] > xp.lvl*xp.player_levels[player:get_player_name()] then
|
||||
xp.player_xp[player:get_player_name()] = 0
|
||||
xp.player_xp[player:get_player_name()] = xp.player_xp[player:get_player_name()] - xp.lvl*xp.player_levels[player:get_player_name()]
|
||||
xp.add_lvl(player)
|
||||
end
|
||||
else
|
||||
@ -42,22 +42,41 @@ function xp.add_lvl(player)
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
xp.xp_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = {x=0.5,y=1.0},
|
||||
size = {x=16, y=16},
|
||||
offset = {x=-(32*8+16), y=-(48*2+16)},
|
||||
text = "xp_xp.png",
|
||||
number = 20*((xp.player_xp[player:get_player_name()])/(xp.lvl*xp.player_levels[player:get_player_name()])),
|
||||
})
|
||||
xp.level_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0.5,y=1},
|
||||
text = xp.player_levels[player:get_player_name()],
|
||||
number = 0xFFFFFF,
|
||||
alignment = {x=0.5,y=1},
|
||||
offset = {x=0, y=-(48*2+16)},
|
||||
})
|
||||
if xp.player_xp[player:get_player_name()] then
|
||||
xp.xp_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = {x=0.5,y=1.0},
|
||||
size = {x=16, y=16},
|
||||
offset = {x=-(32*8+16), y=-(48*2+16)},
|
||||
text = "xp_xp.png",
|
||||
number = 20*((xp.player_xp[player:get_player_name()])/(xp.lvl*xp.player_levels[player:get_player_name()])),
|
||||
})
|
||||
xp.level_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0.5,y=1},
|
||||
text = xp.player_levels[player:get_player_name()],
|
||||
number = 0xFFFFFF,
|
||||
alignment = {x=0.5,y=1},
|
||||
offset = {x=0, y=-(48*2+16)},
|
||||
})
|
||||
else
|
||||
xp.xp_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = {x=0.5,y=1.0},
|
||||
size = {x=16, y=16},
|
||||
offset = {x=-(32*8+16), y=-(48*2+16)},
|
||||
text = "xp_xp.png",
|
||||
number = 0,
|
||||
})
|
||||
xp.level_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0.5,y=1},
|
||||
text = "1",
|
||||
number = 0xFFFFFF,
|
||||
alignment = {x=0.5,y=1},
|
||||
offset = {x=0, y=-(48*2+16)},
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
function xp.load_xp()
|
||||
|
@ -19,7 +19,7 @@ function xp.add_xp(player, num)
|
||||
|
||||
if xp.player_levels[player:get_player_name()] then
|
||||
if xp.player_xp[player:get_player_name()] > xp.lvl*xp.player_levels[player:get_player_name()] then
|
||||
xp.player_xp[player:get_player_name()] = 0
|
||||
xp.player_xp[player:get_player_name()] = xp.player_xp[player:get_player_name()] - xp.lvl*xp.player_levels[player:get_player_name()]
|
||||
xp.add_lvl(player)
|
||||
end
|
||||
else
|
||||
@ -42,22 +42,41 @@ function xp.add_lvl(player)
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
xp.xp_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = {x=0.5,y=1.0},
|
||||
size = {x=16, y=16},
|
||||
offset = {x=-(32*8+16), y=-(48*2+16)},
|
||||
text = "xp_xp.png",
|
||||
number = 20*((xp.player_xp[player:get_player_name()])/(xp.lvl*xp.player_levels[player:get_player_name()])),
|
||||
})
|
||||
xp.level_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0.5,y=1},
|
||||
text = xp.player_levels[player:get_player_name()],
|
||||
number = 0xFFFFFF,
|
||||
alignment = {x=0.5,y=1},
|
||||
offset = {x=0, y=-(48*2+16)},
|
||||
})
|
||||
if xp.player_xp[player:get_player_name()] then
|
||||
xp.xp_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = {x=0.5,y=1.0},
|
||||
size = {x=16, y=16},
|
||||
offset = {x=-(32*8+16), y=-(48*2+16)},
|
||||
text = "xp_xp.png",
|
||||
number = 20*((xp.player_xp[player:get_player_name()])/(xp.lvl*xp.player_levels[player:get_player_name()])),
|
||||
})
|
||||
xp.level_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0.5,y=1},
|
||||
text = xp.player_levels[player:get_player_name()],
|
||||
number = 0xFFFFFF,
|
||||
alignment = {x=0.5,y=1},
|
||||
offset = {x=0, y=-(48*2+16)},
|
||||
})
|
||||
else
|
||||
xp.xp_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = {x=0.5,y=1.0},
|
||||
size = {x=16, y=16},
|
||||
offset = {x=-(32*8+16), y=-(48*2+16)},
|
||||
text = "xp_xp.png",
|
||||
number = 0,
|
||||
})
|
||||
xp.level_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0.5,y=1},
|
||||
text = "1",
|
||||
number = 0xFFFFFF,
|
||||
alignment = {x=0.5,y=1},
|
||||
offset = {x=0, y=-(48*2+16)},
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
function xp.load_xp()
|
||||
|
Loading…
x
Reference in New Issue
Block a user