• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[LUA Function] getLevelByExperience(cexp)

Xagul

deathzot.net
Joined
Jun 30, 2008
Messages
1,294
Solutions
3
Reaction score
1,037
Hello, I recently found myself in need of a function like this... after about an hour of tearing my hair out working with a friend trying to reverse the getExperienceForLevel function we finally figured it out!
This function will output the level of given experience. For example:

Code:
getLevelByExperience(4200)
returns 8


Without further delay, here is the belly of the beast:

Code:
function getLevelByExperience(cexp)
	return math.floor(math.pow((math.sqrt(3)*math.sqrt(243*math.pow(cexp, 2)-48600*cexp+3680000)+27*cexp-2700),1/3) / math.pow(30,2/3)-((5*math.pow(10,2/3)) / (math.pow(3,1/3)*math.pow((math.sqrt(3)*math.sqrt(243*math.pow(cexp,2)-48600*cexp+3680000)+27*cexp-2700),1/3)))+1)+1
end

I don't know if this will be useful to anyone... but its here now, waiting for that 1 person like me that happens to have a use for it!

Credits to:
Lizardo (Original formula)
&
Myself (Converting the formula to lua)
 
35wks2.jpg
 
Back
Top