From c4f038ab77309c5f757b35ecbfb1c28b69778949 Mon Sep 17 00:00:00 2001 From: kay27 Date: Sat, 24 Oct 2020 13:48:39 +0400 Subject: [PATCH] Final (hopefully) megre of XP to master, sorry for all possible conflicts --- mods/HUD/mcl_experience/init.lua | 13 ++++++++----- mods/HUD/mcl_experience/locale/mcl_experience.ru.tr | 4 ++-- mods/HUD/mcl_experience/locale/template.txt | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/mods/HUD/mcl_experience/init.lua b/mods/HUD/mcl_experience/init.lua index ddcdd1562..51346226b 100644 --- a/mods/HUD/mcl_experience/init.lua +++ b/mods/HUD/mcl_experience/init.lua @@ -181,7 +181,6 @@ minetest.register_on_joinplayer(function(player) offset = {x = 0, y = -(48 + 24 + 24)}, z_index = 12, }) - end) function mcl_experience.xp_to_level(xp) @@ -237,13 +236,15 @@ function mcl_experience.add_experience(player, experience) local temp_pool = pool[name] local old_bar, old_xp, old_level = temp_pool.bar, temp_pool.xp, temp_pool.level - temp_pool.xp = math.max(temp_pool.xp + experience, 0) + temp_pool.xp = math.min(math.max(temp_pool.xp + experience, 0), max_xp) if (temp_pool.xp >= temp_pool.xp_next_level) or (experience < 1) then temp_pool.level = mcl_experience.xp_to_level(temp_pool.xp) temp_pool.bar, temp_pool.bar_step, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level) if old_level ~= temp_pool.level then if minetest.get_us_time()/1000000 - temp_pool.last_time > 0.04 then - minetest.sound_play("level_up",{gain=0.2,to_player = name}) + if experience > 0 then + minetest.sound_play("level_up",{gain=0.2,to_player = name}) + end temp_pool.last_time = minetest.get_us_time()/1000000 end hud_manager.change_hud({player = player, hud_name = "xp_level", element = "text", data = tostring(temp_pool.level)}) @@ -251,7 +252,9 @@ function mcl_experience.add_experience(player, experience) else if minetest.get_us_time()/1000000 - temp_pool.last_time > 0.01 then temp_pool.last_time = minetest.get_us_time()/1000000 - minetest.sound_play("experience",{gain=0.1,to_player = name,pitch=math.random(75,99)/100}) + if experience > 0 then + minetest.sound_play("experience",{gain=0.1,to_player = name,pitch=math.random(75,99)/100}) + end end temp_pool.bar = temp_pool.bar + temp_pool.bar_step * experience end @@ -478,7 +481,7 @@ minetest.register_entity("mcl_experience:orb", { }) minetest.register_chatcommand("xp", { - params = S("[] []"), + params = S("[[] ]"), description = S("Gives a player some XP"), privs = {server=true}, func = function(name, params) diff --git a/mods/HUD/mcl_experience/locale/mcl_experience.ru.tr b/mods/HUD/mcl_experience/locale/mcl_experience.ru.tr index f4c0b714e..42cc9ec43 100644 --- a/mods/HUD/mcl_experience/locale/mcl_experience.ru.tr +++ b/mods/HUD/mcl_experience/locale/mcl_experience.ru.tr @@ -1,5 +1,5 @@ -[] []=[<игрок>] [] -Gives a player some XP= +[[] ]=[[<игрок>] ] +Gives a player some XP=Даёт игроку XP Error: Too many parameters!=Ошибка: слишком много параметров! Error: Incorrect value of XP=Ошибка: Недопустимое значение XP Error: Player not found=Ошибка: Игрок не найден diff --git a/mods/HUD/mcl_experience/locale/template.txt b/mods/HUD/mcl_experience/locale/template.txt index 02afd0927..19eb6cc60 100644 --- a/mods/HUD/mcl_experience/locale/template.txt +++ b/mods/HUD/mcl_experience/locale/template.txt @@ -1,4 +1,4 @@ -[] []= +[[] ]= Gives a player some XP= Error: Too many parameters!= Error: Incorrect value of XP=