ID:1330777
 
(See the best response by DarkCampainger.)
Code:
Stat
var/value
var/XP
var/maxxp
var/max

proc/check()
while(XP >= maxxp)
XP = XP - maxxp
value ++

New(v,x,m,n)
value = v
XP = x
maxxp = m
max = n


Problem description:
I want to get the value of the datum in an expression, that way, I can do something like:

dmg = src.attack.value + var


However, it won't let me do this. Can anyone offer some help, please?
Show where you declare src.attack

Edit: Also, the object never exists because you aren't calling the parent proc, ..(), when over riding.
mob/var/Stat/attack = new(1, 1, 1, 1)
Here's an example:
Vitals
var
Name = ""
Cur = 0
Max = 0

New(a,b,c)
Name = a
Cur = b
Max = c
mob
var
Vitals/Health
Login()
new Health("hp",20,20)
world << src.Health.Cur
In response to Kitsueki
Best response
Kitsueki wrote:
Edit: Also, the object never exists because you aren't calling the parent proc, ..(), when over riding.

The datum has already been created (and if it's an atom, placed at a loc) by the time New() is called. By default, New() does nothing, so calling the parent proc with ..() won't have any effect unless you defined it in a parent type.
In response to DarkCampainger
Yeah I thought I was crazy at 1st when I read it. So I didn't pay much attention to it. But yeah he's very wrong.
In response to DarkCampainger
Ah, you're right. I stand corrected :)

Assuming Wissam is answering me, nothing is ever getting assigned to Health.
In response to Kitsueki
My bad, my bad.
Health = new("text",100,100)

idk how i missed that XD
In response to Wissam
Did that fix the issues you were having? 8)
I finally defined all of these datums, but now it's telling me these datums are undefined.

mob
var/stat/HP
var/stat/MP
var/stat/ATK
var/stat/INT
var/stat/DEX
var/stat/DES

Login()
..()
HP = new(100,0,25,100000)
MP = new(100,0,25,100000)
ATK = new(20,0,20,1000)
INT = new(20,0,20,1000)
DEX = new(20,0,20,1000)
DES = new(20,0,20,1000)


Edit: It turns out the problem was I didn't capitalize the others "stat"'s. Thanks guys!
In response to GamerMania
In your OP stat was capitalized, try Stat/HP, etc..
From looking through this thread, it doesn't look like OP's question was ever actually answered?

To get the value you just need to make a proc that returns the value, so for example

Stat
var/value = 0
proc/get()
return value


Then, as you asked, you can simply do
dmg = attack.get() + 9001