ID:139537
 
Code:


Problem description:

Can you please show me how to add a level cap? the var of level is just level
Ask yourself, what's the definition of a cap? My definition for a level cap would be the maximum level attainable.

This is a basic limit that can simply take advantage of the greater than or less than operators. You would want to compare the current level with the level cap to see if the level cap is still greater than the current level. The code would go before the game actually raises your level, and it would stop the code from continuing at that point.
In response to Kaiochao
Ignore the comments. Probably something such as;

mob
var Level = 1 // your level
var LevelCap = 10
var Experience // current experience
var MaxExperience = 10// total exp needed to level up
proc
LevelUp() // the level up proc
while(Experience >= MaxExperience && Level < LevelCap) // while your experience is greater or equal to your current experience
src << "Level Up!"
Level ++ // +1 to your level
Experience = 0 // reset the experience
MaxExperience = round(MaxExperience * 1.5, 1) // just a random formula (from Lummox's post)
In response to Neimo
You'd want it to be Level < LevelCap, or else you'd be able to level up with a level equal to the cap, allowing level 11.
In response to Kaiochao
Kaiochao wrote:
You'd want it to be Level < LevelCap, or else you'd be able to level up with a level equal to the cap, allowing level 11.

Eh, i'll edit it. Overlooked it.