I currently have a level system which adds xp and if the xp exceeds the needed xp to level up then it levels the player up. The problem is when you add a holy amount of xp it will only level up once and the remainder of the of the current xp - needed xp will still be a large amount. I know im missing a calculation but im too tired for this.
Code:
local NeededXp = self.Levels * 100
self.Xp += Change
if self.Xp >= NeededXp then
local Remainder = self.Xp - NeededXp
self.Levels += 1
self.Xp = Remainder
end
print(self.Levels, self.Xp)
if anybody could leave a comment, would be helpful
If you want to remove the loop, then yes - you should be able to come up with a formula using log.
The readability of it won’t be great though, so the loop is probably sufficient.