From 5fe64ff6f140859d80e5ecc93b4ff9877dbf7b1d Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 21 Dec 2020 17:02:39 +0100 Subject: [PATCH] Better XP bar --- mods/HUD/mcl_experience/init.lua | 24 ++++++++++-------- .../textures/experience_bar.png | Bin 3745 -> 1540 bytes .../textures/experience_bar_background.png | Bin 2861 -> 1538 bytes 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/mods/HUD/mcl_experience/init.lua b/mods/HUD/mcl_experience/init.lua index 28ac779f..eb963905 100644 --- a/mods/HUD/mcl_experience/init.lua +++ b/mods/HUD/mcl_experience/init.lua @@ -77,6 +77,8 @@ hud_manager.add_hud = function(player,hud_name,def) size = def.size, offset = def.offset, z_index = def.z_index, + alignment = def.alignment, + scale = def.scale, }) -- create new 3d array here -- depends.txt is not needed @@ -164,14 +166,14 @@ minetest.register_on_joinplayer(function(player) hud_manager.add_hud(player,"experience_bar", { - hud_elem_type = "statbar", position = {x=0.5, y=1}, - name = "experience bar", - text = "experience_bar.png", - text2 = "experience_bar_background.png", - number = temp_pool.bar, item = 36, - direction = 0, - offset = {x = (-8 * 28) - 29, y = -(48 + 24 + 16)}, - size = { x=28, y=28 }, z_index = 11, + hud_elem_type = "image", + name = "experience bar", + text = "experience_bar_background.png^[lowpart:" .. math.floor(temp_pool.bar / 36 * 100) .. ":experience_bar.png^[transformR270", + position = {x=0.5, y=1}, + offset = {x = (-9 * 28), y = -(48 + 24 + 16 - 7)}, + scale = {x = 2.75, y = 2.75}, + alignment = { x = 1, y = 1 }, + z_index = 11, }) hud_manager.add_hud(player,"xp_level", @@ -181,7 +183,7 @@ minetest.register_on_joinplayer(function(player) number = 0xFFFFFF, offset = {x = 0, y = -(48 + 24 + 24)}, z_index = 12, - }) + }) end) function mcl_experience.xp_to_level(xp) @@ -247,7 +249,7 @@ function mcl_experience.add_experience(player, experience) end 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 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) 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) end) diff --git a/mods/HUD/mcl_experience/textures/experience_bar.png b/mods/HUD/mcl_experience/textures/experience_bar.png index d43a03d641f48a750d8971a6724f8d9f645df5ff..19a2c029d8d47ad9b08c0f53e45a95786a98d41f 100644 GIT binary patch literal 1540 zcma)+4NMbf7{^~$DNx2&p+mlAVGfxH>y@wC0HM%Q>I&Qdiy(|%+bccS_UiQ*9}}m{ zfK(HK8HNfh+guUH#~i~%lsP5>A={h_3__T)$<&~Zsca0`=3a0zO=_~_-g|S;|M$P= zdG2|0)o7a3h2_fv0Jz9f#2Ik6hwJnj2E1Qem+Jz6-7X?22_@8O077cZYvWQbB=}z} z$owd1)K%fWa|mtPWU&Z#a4cxx2&-M#khf@`>RadKE$!=`ni^D%_Fc@$cE}dF{|Ro^To5^eTC}iDB`N?F$7;jkft0Cqto$&b-j+5Tw9N9kU4!8 zP%!`N-QU88yC&XSGS8jJIbauGTT<_1O+6=y?Irvg=c_NYaX;?A(f?s^e$5}Xw=9EX zwT@sXojFGKBF$ID($@dQTUb+55etYj5H&o_Qo~m!40IUnO=Vu51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