-
What do you want to achieve? Keep it simple and clear!
So my code is expected to work when modulus of current formula level and required one is more than -0.05(just in case of weird rounding sometimes). So let’s say formula Level is 6 and required is 5 and function seems to do weird stuff, like increasing exponent 2 times a row(when it shouldn’t), exponent should only increase when formula level % required level == 0
Code:
function CalculateExponent(formulaLevel, requiredLevel, perExpo)
local exponent = 1
if formulaLevel >= requiredLevel then
while formulaLevel > 0 and math.round(formulaLevel) % requiredLevel >= -0.05 do
print(formulaLevel, formulaLevel % requiredLevel)
formulaLevel -= requiredLevel
exponent *= perExpo
end
end
return exponent
end
Also here is screenshot of what happens:
So as you can see on level 5 and level 6 exponent increase. Also on level 10 it not increase
but on level 11 it increase. Weird.