forked from VoxeLibre/VoxeLibre
update fork #6
|
@ -156,7 +156,20 @@ function mcl_experience.throw_xp(pos, total_xp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setup_hud(player)
|
function mcl_experience.remove_hud(player)
|
||||||
|
if hud_bars[player] then
|
||||||
|
player:hud_remove(hud_bars[player])
|
||||||
|
hud_bars[player] = nil
|
||||||
|
end
|
||||||
|
if hud_levels[player] then
|
||||||
|
player:hud_remove(hud_levels[player])
|
||||||
|
hud_levels[player] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function mcl_experience.setup_hud(player)
|
||||||
|
if hud_bars[player] and hud_levels[player] then return end
|
||||||
|
mcl_experience.remove_hud(player)
|
||||||
caches[player] = {
|
caches[player] = {
|
||||||
last_time = get_time(),
|
last_time = get_time(),
|
||||||
}
|
}
|
||||||
|
@ -189,7 +202,7 @@ function mcl_experience.update(player)
|
||||||
|
|
||||||
if not minetest.is_creative_enabled(player:get_player_name()) then
|
if not minetest.is_creative_enabled(player:get_player_name()) then
|
||||||
if not hud_bars[player] then
|
if not hud_bars[player] then
|
||||||
setup_hud(player)
|
mcl_experience.setup_hud(player)
|
||||||
end
|
end
|
||||||
player:hud_change(hud_bars[player], "text", "mcl_experience_bar_background.png^[lowpart:"
|
player:hud_change(hud_bars[player], "text", "mcl_experience_bar_background.png^[lowpart:"
|
||||||
.. math.floor(math.floor(xp_to_bar(xp, cache.level) * 18) / 18 * 100)
|
.. math.floor(math.floor(xp_to_bar(xp, cache.level) * 18) / 18 * 100)
|
||||||
|
@ -211,7 +224,7 @@ end
|
||||||
-- callbacks
|
-- callbacks
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
setup_hud(player)
|
mcl_experience.setup_hud(player)
|
||||||
mcl_experience.update(player)
|
mcl_experience.update(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -206,6 +206,12 @@ local gamemodes = {
|
||||||
function mcl_inventory.player_set_gamemode(p,g)
|
function mcl_inventory.player_set_gamemode(p,g)
|
||||||
local m = p:get_meta()
|
local m = p:get_meta()
|
||||||
m:set_string("gamemode",g)
|
m:set_string("gamemode",g)
|
||||||
|
if g == "survival" then
|
||||||
|
mcl_experience.setup_hud(p)
|
||||||
|
mcl_experience.update(p)
|
||||||
|
elseif g == "creative" then
|
||||||
|
mcl_experience.remove_hud(p)
|
||||||
|
end
|
||||||
set_inventory(p)
|
set_inventory(p)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue