ID:179477
 
i keep getting errors that say missing expression when its not missing. this is the code:
buycheck()
if (usr.wealth >=10) //1
usr.wealth-=10 //2
if(upgrade = " weapon") //3
usr.attack+=1 //4
usr << "upgraded sword for 10 gold, damage is now 1 to [10+usr.attack]" //5
if(upgrade = "armor") //6
usr.defence+=1 //7
usr << "upgraded defence for 10 gold, defence is now [defence]" //8
else //9
usr << "not enough cash" //10
the missing expression errors are for 3 + 6 but the expressions are there. if u could help it would be much appreciated.

But where life is more terrible than death, it is then the truest valor to dare to live.
-Sir Thomas Browne (1663-1704) Religio Medici

Loduwijk (the war famous)
The reason it says you're missing an expression is that you're using the assignment = in an if() statement instead of ==. Unlike C, where this is valid but gives you a warning, BYOND doesn't allow assignment within the if() condition.

(I wonder if a special modification of the error message couldn't be made to handle this case. I think it would help a lot of people.)

Lummox JR
In response to Lummox JR
thx bunches. i dont understand why it makes a difference but it works better now. ill have to look into that so i understand it better.

But where life is more terrible than death, it is then the truest valor to dare to live.
-Sir Thomas Browne (1663-1704) Religio Medici

Loduwijk (the war famous knight)
In response to Loduwijk
Loduwijk wrote:
thx bunches. i dont understand why it makes a difference but it works better now. ill have to look into that so i understand it better.


I'll try to explain it some:

= sets something which cannot be done within a if() proc.

== means equals to which checks against something which can be done within a if() proc.

if() is used to check something not to set something.
In response to Nadrew
thx nadrew, that cleared a lot up. from our confrontations of late i thought u were as hypocritical and irrational as duff. i am sorry for that, u are not such a bad guy after all.

just my opinion.

But where life is more terrible than death, it is then the truest valor to dare to live.
-Sir Thomas Browne (1663-1704) Religio Medici

Loduwijk, the war famous knight