I found this response but the thread is closed:
https://gamedev.stackexchange.com/a/13639
level = constant * sqrt(XP)
I seem unable to properly get current level, this is how I tried to do it, and everything seems to work except the actual current level for some reason:
xpConstant = 0.05;
currentXp = 80;
-- with those two values, level 1 should require 20 xp:
-- xp = 1^2 / xpConstant;
-- with 80 xp, the player should be level 2, 2^2 / 0.05 = 80
-- this is 0.47 but it should be 2?
currentLevel = xpConstant * math.sqrt( currentXp );
-- and to retrieve xp until next level, this does seem to work:
nextLevel = currentLevel + 1;
XPUntilNextLevel = nextLevel ^2 / xpConstant;
XPUntilNextLevel = XPUntilNextLevel - currentXp;
so for some reason the currentLevel variable doesn't give 2 as expected,