# Level And Experience

**URL:** <https://forum.kirupa.com/t/level-and-experience/54708>\
**Category:** programming\
**Created:** [June 16, 2004, 11:19pm UTC](https://forum.kirupa.com/t/level-and-experience/54708 "2004-06-16T23:19:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krayzie](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@Krayzie](https://forum.kirupa.com/u/Krayzie)\
**Post date:** [June 16, 2004, 11:19pm UTC](https://forum.kirupa.com/t/level-and-experience/54708/1 "2004-06-16T23:19:55Z")

</div>

ok. say i have 2 dynamic boxes one named “experience” and the other “lvl”. how would i make it so that when experience is greater or equal to 1000, lvl goes + 1 i tried this but it doesn’t seem to work. Any suggestions?

[left] if (\_root.exper\>=100) {  
\_root.lvl += 1;  
}[/left]  
[left] [/left]  
[left] [/left]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 13, 2004, 6:52pm UTC](https://forum.kirupa.com/t/level-and-experience/54708/2 "2004-07-13T18:52:49Z")

</div>

You should have \_global.variables instead, or at least variables, and update the experience and level textbox every second or so using these. This way you can access the variables, not just the textboxes.

You’d get:  
if( exp \>= (\_root[“level”+(current\_level+1)+"\_requisite"]) ) {  
current\_level +=1;  
}  
_[size=1]What this syntax does is check for variables with a nomenclature as described after the following paragraph…[/size]_

–\>Where **exp** is the current variable which holds the total experience points gained and **current\_level** the variable which holds what level the player is actually at.

Nomenclature:  
You could define level\_prerequisites (that variable name is too long but you get the idea) for levels as much as 1 to 100…

On(load) = function(){  
level1\_requisite = 1000;  
level2\_requisite = 2500;  
level3\_requisite = 5000;  
//_and so on…_  
}

If you know how to use them, it would be easier to stock the levels and their prerequisited exp points in an **array** , this array made global just for sheer usability (in items which require player to be level 35, you need to check the current level; in a status screen which shows how much more exp you need to get to the next level, you take the one after the current level and you substract the xp for next level with the current and you see how much more xp you need…etc)

I’m not gonna explain here on how to use arrays, look around the kirupa tutorials for more info 🙂 Hope this helped.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 15, 2004, 9:04pm UTC](https://forum.kirupa.com/t/level-and-experience/54708/3 "2004-07-15T21:04:47Z")

</div>

Yo thanks:)

---

<div class="post-metadata">

**Author:** ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)\
**Post date:** [April 2, 2006, 6:47pm UTC](https://forum.kirupa.com/t/level-and-experience/54708/4 "2006-04-02T18:47:55Z")

</div>

Where should i put those 2 codes? 0.o

---

<div class="post-metadata">

**Author:** ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)\
**Post date:** [April 3, 2006, 3:07pm UTC](https://forum.kirupa.com/t/level-and-experience/54708/5 "2006-04-03T15:07:10Z")

</div>

This is an quite old thread…  
But im sure he explained it in his post 😕
