Hers my code Can some on help me please on the Line were it the usr.wealth += amount is i get a Error Saying 16:usr.wealth:undefined var
obj
gold
icon = 'gold.dmi'
var
amount
verb
get()
set src in view(1)
usr << "You pick up [amount] gold."
usr.wealth += amount
del(src)
Wait theres more LOOK!!
and my Mob is this
mob
icon = 'player.dmi'
var
HP = 30 //define a new variable called HP, with a value of 30
Wealth
And thank you for taking the time to read this ans for your help
ID:176696
Dec 19 2002, 9:25 am
|
|
Dec 19 2002, 9:32 am
|
|
First, wealth should be set to 0, otherwise it's null, which could cause problems when you add to it. Second, it's case sensitive.
|
The problem is actually simpler than you might think; it's an easy one to overlook. BYOND is case-sensitive, which means Wealth and wealth are treated as two different variable names. You defined the wealth var as Wealth, so the attempt to access usr.wealth is failing.
I'd change the uppercase Wealth to lowercase wealth, for consistency's sake. Usually vars like this are named in lowercase. Lummox JR |
In response to Garthor
|
|
Garthor wrote:
First, wealth should be set to 0, otherwise it's null, which could cause problems when you add to it. Second, it's case sensitive. Actually I think null+num is an operation supported in BYOND. One thing I know for sure is that ++ and -- work on null (changing the var to 1 or -1, respectively). However as a rule any time I'm working with numerical values I always set 0 as the default. Lummox JR |
In response to Lummox JR
|
|
thank you very much
|