ID:140726
 
Code:
var/Level=round((src.Mtai+src.Mnin+src.Mgen)/100)


Ok! i figured out the order of operations. But if i use a code such as

if(usr.rank=="Genin"&&usr.Level >= 250)

and compile it errors with "var Level is not defined"
If i add a separate var for Level the first code does doesn't effect the second.
Sorry for my newb issues I'm just learning ^.^
thanks for anyone who could shed light on this issue.

Irisofdreams4 wrote:
Code:
var/Level=round((src.Mtai+src.Mnin+src.Mgen)/100)

Ok! i figured out the order of operations. But if i use a code such as

if(usr.rank=="Genin"&&usr.Level >= 250)

and compile it errors with "var Level is not defined"
If i add a separate var for Level the first code does doesn't effect the second.
Sorry for my newb issues I'm just learning ^.^
thanks for anyone who could shed light on this issue.

var/Level is local to that script while usr.Level is local to the user.
usr.Level is not Level.


In other words add a var named Level to mob


mob/var/Level=1

Then change this

var/Level=round((src.Mtai+src.Mnin+src.Mgen)/100)

To this

usr.Level=round((src.Mtai+src.Mnin+src.Mgen)/100)

You should generally avoid usr and instead use src.
In response to Chowder
Chowder wrote:
Irisofdreams4 wrote:
Code:
var/Level=round((src.Mtai+src.Mnin+src.Mgen)/100)

Ok! i figured out the order of operations. But if i use a code such as

if(usr.rank=="Genin"&&usr.Level >= 250)

and compile it errors with "var Level is not defined"
If i add a separate var for Level the first code does doesn't effect the second.
Sorry for my newb issues I'm just learning ^.^
thanks for anyone who could shed light on this issue.

var/Level is local to that script while usr.Level is local to the user.
usr.Level is not Level.


In other words add a var named Level to mob


mob/var/Level=1

Then change this

var/Level=round((src.Mtai+src.Mnin+src.Mgen)/100)

To this

usr.Level=round((src.Mtai+src.Mnin+src.Mgen)/100)

You should generally avoid usr and instead use src.

Wow i feel stupid for not realizing this earlier.
Thanks a ton.
And as a curious new coder why should you generally avoid usr?
In response to Irisofdreams4
It's not so much that you should avoid it as that it's only valid in certain places. The usr unfriendly article discusses it - basically, any code that is only ever triggered directly by a player character is usr-legal, any other code is not.