ExperienceUtils
Calculate experience on an exponential curve and perform relevant calculations.
Uses formulas from https://stackoverflow.com/questions/6954874/php-game-formula-to-calculate-a-level-based-on-exp
local config = ExperienceUtils.createExperienceConfig({
factor = 200;
})
local totalExperience = 2000
local level = ExperienceUtils.getLevel(config, totalExperience)
local percentDone = ExperienceUtils.percentLevelComplete(config, totalExperience)
Functions
createExperienceConfig
ExperienceUtils.
createExperienceConfig
(
options:
ExperienceConfig
) →
ExperienceConfig
Creates a new experience configuration to be used
isExperienceConfig
ExperienceUtils.
isExperienceConfig
(
value:
any
) →
boolean
Returns whether a value is an experience config
getLevel
ExperienceUtils.
getLevel
(
config:
ExperienceConfig
,
totalExperience:
number
) →
number
--
Level
Gets the current level from experience.
experienceFromLevel
ExperienceUtils.
experienceFromLevel
(
config:
ExperienceConfig
,
level:
number
) →
number
--
Total experience required for a level
Gets experience required for a current level. Once the experience is equal to this threshold, or greater, then the level is considered earned.
levelExperienceEarned
ExperienceUtils.
levelExperienceEarned
(
config:
ExperienceConfig
,
totalExperience:
number
) →
number
For this level only, how much experience is earned.
levelExperienceLeft
ExperienceUtils.
levelExperienceLeft
(
config:
ExperienceConfig
,
totalExperience:
number
) →
number
For this level only, how much experience is left to earn.
levelExperienceRequired
ExperienceUtils.
levelExperienceRequired
(
config:
ExperienceConfig
,
totalExperience:
number
--
Current experience of player
) →
number
--
Total required for next level
For this level only, how much experience is required
percentLevelComplete
ExperienceUtils.
percentLevelComplete
(
config:
ExperienceConfig
,
totalExperience:
number
) →
number
Returns the percent of the level complete