ID:142600
 
Code:
        proc
Levelcheck()
if (experience >= level * 100)
level += 1
world << "[usr] gained a level!"
world << "[usr] is now level [level]"


Problem description:
I defined "level" earlier:
mob
pc
icon = 'person.dmi'
var
HP = 100 * stamina
wealth
level = 1
Experience

But I end up with:

TestWorld2.dm:68:error:level:undefined var
TestWorld2.dm:69:error:level:undefined var
TestWorld2.dm:71:error:level:undefined var

Does anyone know why?

Also the same thing happens with experience.
And it says that = needs a constant expression.
I am sorta new to coding so help would be really appreciated.

TestWorld2.dm:42:error:= :expected a constant expression
TestWorld2.dm:68:error:experience:undefined var
FireBallHatePeace wrote:
Code:
        proc
> Levelcheck()
> if (experience >= level * 100)
> level += 1
> world << "[usr] gained a level!"
> world << "[usr] is now level [level]"
>

Problem description:
I defined "level" earlier:
mob
> pc
> icon = 'person.dmi'
> var
> HP = 100 * stamina
> wealth
> level = 1
> Experience


i can see why experience doesn't work: in the definition it is capitolized in the process it's not, you have to be careful about that, it has to be exactly the same

it *might* fix the level prob if you fix that ;)
In response to FireBallHatePeace
let me know if that helps ;)
In response to FireBallHatePeace
It means precisely what it says: you can only use a constant expression. 100 * stamina is not constant. Therefore, you cannot use 100 * stamina.
In response to Garthor
you do realize Garthor, that that only solves one of the compileing errors


the actual question was why does it come up with the problems with defined vars


you were right about that tho
In response to Shiny11100
Because the proc was defined improperly. It needs to be a mob/pc proc. And usr shouldn't be used in it at all.
In response to Shiny11100
I looked at and corrected the capitals, but it still says they ar undefined. And how do game programmers add in HP if you cant multiply variables?
In response to FireBallHatePeace
You CAN multiply variables, just not in the definition. At compile time, there's no way to know what stamina is - so you have to multiply at runtime in a proc.
In response to FireBallHatePeace
Whenever you change stamina, you change HP.