forked from Mineclonia/Mineclonia
Better XP bar
This commit is contained in:
parent
a4d9d22bb0
commit
5fe64ff6f1
|
@ -77,6 +77,8 @@ hud_manager.add_hud = function(player,hud_name,def)
|
||||||
size = def.size,
|
size = def.size,
|
||||||
offset = def.offset,
|
offset = def.offset,
|
||||||
z_index = def.z_index,
|
z_index = def.z_index,
|
||||||
|
alignment = def.alignment,
|
||||||
|
scale = def.scale,
|
||||||
})
|
})
|
||||||
-- create new 3d array here
|
-- create new 3d array here
|
||||||
-- depends.txt is not needed
|
-- depends.txt is not needed
|
||||||
|
@ -164,14 +166,14 @@ minetest.register_on_joinplayer(function(player)
|
||||||
|
|
||||||
hud_manager.add_hud(player,"experience_bar",
|
hud_manager.add_hud(player,"experience_bar",
|
||||||
{
|
{
|
||||||
hud_elem_type = "statbar", position = {x=0.5, y=1},
|
hud_elem_type = "image",
|
||||||
name = "experience bar",
|
name = "experience bar",
|
||||||
text = "experience_bar.png",
|
text = "experience_bar_background.png^[lowpart:" .. math.floor(temp_pool.bar / 36 * 100) .. ":experience_bar.png^[transformR270",
|
||||||
text2 = "experience_bar_background.png",
|
position = {x=0.5, y=1},
|
||||||
number = temp_pool.bar, item = 36,
|
offset = {x = (-9 * 28), y = -(48 + 24 + 16 - 7)},
|
||||||
direction = 0,
|
scale = {x = 2.75, y = 2.75},
|
||||||
offset = {x = (-8 * 28) - 29, y = -(48 + 24 + 16)},
|
alignment = { x = 1, y = 1 },
|
||||||
size = { x=28, y=28 }, z_index = 11,
|
z_index = 11,
|
||||||
})
|
})
|
||||||
|
|
||||||
hud_manager.add_hud(player,"xp_level",
|
hud_manager.add_hud(player,"xp_level",
|
||||||
|
@ -247,7 +249,7 @@ function mcl_experience.add_experience(player, experience)
|
||||||
end
|
end
|
||||||
|
|
||||||
if old_bar ~= temp_pool.bar then
|
if old_bar ~= temp_pool.bar then
|
||||||
hud_manager.change_hud({player = player, hud_name = "experience_bar", element = "number", data = math.floor(temp_pool.bar)})
|
hud_manager.change_hud({player = player, hud_name = "experience_bar", element = "text", data = "experience_bar_background.png^[lowpart:" .. math.floor(temp_pool.bar / 36 * 100) .. ":experience_bar.png^[transformR270",})
|
||||||
end
|
end
|
||||||
|
|
||||||
if experience > 0 and minetest.get_us_time()/1000000 - temp_pool.last_time > 0.01 then
|
if experience > 0 and minetest.get_us_time()/1000000 - temp_pool.last_time > 0.01 then
|
||||||
|
@ -283,7 +285,7 @@ minetest.register_on_dieplayer(function(player)
|
||||||
temp_pool.bar, temp_pool.bar_step, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level)
|
temp_pool.bar, temp_pool.bar_step, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level)
|
||||||
|
|
||||||
hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(temp_pool.level)})
|
hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(temp_pool.level)})
|
||||||
hud_manager.change_hud({player = player, hud_name = "experience_bar", element = "number", data = math.floor(temp_pool.bar)})
|
hud_manager.change_hud({player = player, hud_name = "experience_bar", element = "text", data = "experience_bar_background.png^[lowpart:" .. math.floor(temp_pool.bar / 36 * 100) .. ":experience_bar.png^[transformR270",})
|
||||||
|
|
||||||
mcl_experience.throw_experience(player:get_pos(), xp_amount)
|
mcl_experience.throw_experience(player:get_pos(), xp_amount)
|
||||||
end)
|
end)
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in New Issue