ID:267031
 
How do I get a obj to have vars? for instance;

obj
mushroom
quantity=2
obj
var/IM_A_VAR = "Hi!"
In response to Mrhat99au
Thanks.
In response to Mrhat99au
Argh, damnit.
Another question, how do i make the user activate a proc when he picks it... for instance;

obj
Marijuana
name="Marijuana Plant"
icon='turfs.dmi'
icon_state="mary"
var/quantity=12
verb
Pick()
set category="Pick"
set src in oview(1)
src:QuantityCheck()
src.quantity-=1
usr.mary+=1

but it doesn't work.
To add a bit to the current answer, you can also setup "parent" vars that will be carried over to the "children" datums, example:
obj
fruit//parent
var
hptoadd

apple//child
hptoadd = 10
orange
hptoadd = 5
verb//this verb will effect all the "children"
Eat()
set src in usr
if(usr.hp != usr.maxhp)
usr.hp += src.hptoadd
if(usr.hp > usr.maxhp)
usr.hp = usr.maxhp
In response to Tamaka-san
It really depends on how you have the proc defined, if you don't see it from my other post this should help:
obj
parent
proc
someproc()
//do something
child
verb/Dosomething()
set src in oview()
src.someproc()


That will call the parent's "someproc" for the child's variables and/or settings, depends on how you have it set up.
In response to Nadrew
Not exactly what i was looking for, examine;

mob/proc
QuantityCheck()
if(src.quantity<=0)
src.quantity=0
usr<<"There is no more [src]"
obj
Marijuana
name="Marijuana Plant"
icon='turfs.dmi'
icon_state="mary"
var/quantity=2
verb
Pick()
set category="Pick"
set src in oview(1)
if(src.quantity<=0)
usr<<"There is no more leaves on this plant."
else
src.quantity-=1
usr.mary+=1

I've set up a temporary if statement for the time being, just to see if the proc would run correctly and apparently it should..

i'd rather have a universal proc for objs instead of rewriting the if command over and over.
In response to Tamaka-san
Your best bet would probably be something like:

mob
proc
Check(obj/parent/O)//change this to the object you want to check
if(!O.quantity)
usr << "There's no more [O]!"
return
else
..()

//and call it something like:

usr.Check(src)//within the obj's verb.


OR

obj
proc
Check()
if(!src.quantity)
//rest here


And, call it like you were trying to call it in your previous code.