ID:266441
 
hmmmmmm i want it where if a mob has a certain var in an over view that u can do sumthing
That made NO sense. Please reply with what you want, and be more specific.

-Rcet
In response to Rcet
lol haha...
Rcet go on aim
P.S haha
- RaeKwon
In response to RaeKwon
ok here we go ill try and explain it a little more detail

I want a Mob to give a verb when another mob comes by it (i know this)

well i want to set up where if a mob in the world has 1 of this one var called haskey in an if statement plz help
In response to Strange Kidd
if(usr.haskey == 1)
usr.verbs+= /mob/verb/Attack
else
return


like that?
- RaeKwon
In response to RaeKwon
RaeKwon wrote:
if(usr.haskey == 1)
usr.verbs+= /mob/verb/Attack
else
return

like that?
- RaeKwon

Gads, I would hope not like that.
If you're using vars that have values of 1 or 0 most of the time, leave out the ==1. If for some reason your truth value were ever different, ==1 would fail. Just putting the variable in if() says: If it is not null, not 0, and not an empty string (""). It's simpler, and it's broader in meaning.

Lummox JR
In response to Lummox JR
My C++ teacher would shoot you for recommending that :p

I agree with you on the issue but he says it's "bad style." He's a Java adict where you can't even use something like:
if(haskey)

Every test statement HAS TO evaluate as boolean. He seems to think this is superior...
In response to English
English wrote:
My C++ teacher would shoot you for recommending that :p

I agree with you on the issue but he says it's "bad style." He's a Java adict where you can't even use something like:
if(haskey)

Every test statement HAS TO evaluate as boolean. He seems to think this is superior...

In Java I can understand the need for a test to be boolean. However, if one were to translate my recommendation to Java, I'd basically be saying he should test if(haskey!=0) instead of if(haskey==1). Basically that's because, as C observes well, if you're testing something against a specific value, 0 is usually the "safest". Also, most CPUs have a "zero" flag, so tests like if(var!=0) can usually be boiled down to a simpler instruction and operate marginally faster than if(var==1).

Lummox JR