1
0
Fork 0

Hard-cap XP at 2^31-1

objects
Wuzzy 2020-10-23 23:16:46 +02:00
parent 6706104c3a
commit fe1c8ca758
1 changed files with 2 additions and 1 deletions

View File

@ -2,6 +2,7 @@ local S = minetest.get_translator("mcl_experience")
mcl_experience = {} mcl_experience = {}
local pool = {} local pool = {}
local registered_nodes local registered_nodes
local max_xp = 2^31-1
local gravity = {x = 0, y = -((tonumber(minetest.settings:get("movement_gravity"))) or 9.81), z = 0} local gravity = {x = 0, y = -((tonumber(minetest.settings:get("movement_gravity"))) or 9.81), z = 0}
local size_min, size_max = 20, 59 -- percents local size_min, size_max = 20, 59 -- percents
@ -235,7 +236,7 @@ function mcl_experience.add_experience(player, experience)
local temp_pool = pool[name] local temp_pool = pool[name]
local old_bar, old_xp, old_level = temp_pool.bar, temp_pool.xp, temp_pool.level 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)
temp_pool.level = mcl_experience.xp_to_level(temp_pool.xp) temp_pool.level = mcl_experience.xp_to_level(temp_pool.xp)
temp_pool.bar, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level) temp_pool.bar, temp_pool.xp_next_level = mcl_experience.xp_to_bar(temp_pool.xp, temp_pool.level)
if old_level ~= temp_pool.level then if old_level ~= temp_pool.level then