ID:141364
 
Code:
obj/Pokeball
icon='pokeball.dmi'
name="Pokeball x[usr.pokeballs]"
verb
PickUp()
set src in oview(1)
usr.contents3 += src
src.loc = null

mob
pokemon
Stat()
statpanel("Inventory","-----Pokemon-----","")
statpanel("Inventory",contents2)
statpanel("Inventory","-----Items-----","")
statpanel("Inventory",contents3)


Problem description:
Well, it says undefined var for usr.pokeballs and expected a constant expression. Obviously, at first glance, you'd think to just put it after contents3, (which is where I want it obviously).. But if I put
statpanel("Inventory",contents3,"[pokeballs]")
or any variation of that ("[usr.pokeballs]",pokeballs, or usr.pokeballs) it wont display contents3. How do I work this?

Ok...

When you are first setting a variable, you can NOT reference other variables. That's called not being constant, and its not possible. You have to set it to something solid.

You would accomplish what you want like this:
    verb
PickUp()
set src in oview(1)
name="Pokeball x[usr.balls]"


However, from what we can see it doesn't appear that your code stacks the pokeballs, so I don't know what the purpose of that would be...
In response to AJX
ok so statpanel("Inventory",contents3,"[pokeballs]") is undefined?

make a var for contents 3
In response to AJX
@ AJX: Of course you can reference variables to define other variables. You just have make sure the referenced variable is in a higher scope.

@ Poster:
Also, you'd like to use item stacking to do what you're trying to do with the x[amount] of pokeballs and stuff. I have a nice demo handy around here: hub://metamorphman.mitemstacking

Anyway, the reason for it not displaying I can attribute to either contents3 being empty or runtime errors.
In response to Metamorphman
Metamorphman wrote:
@ AJX: Of course you can reference variables to define other variables. You just have make sure the referenced variable is in a higher scope.

I don't know what exactly it is you're talking about...
I think you are paraphrasing and in doing so you aren't grasping what I said.

You can NOT define a variable to be another variable at compile time... It must be a constant. Another variable would be a reference, and that's not possible at compile time. ... ...
In response to AJX
Heheh, April Fools ;P
I'm just pulling your leg.
In response to Metamorphman
That's not original dude, come up with a better excuse. ;P
In response to Kaioken
Dog ate my homework . :(