ID:160707
 
mob
proc
Damage(min,dmg)
var/x = text2path("[min].val")
x -= dmg
src << x


Is there anything like text2var(), or how I could do it like that?

My intentions are like this: I got 6 variables that I want to choose from.

So, if I got 6 variables, named "a", "b", "c", "d", "e" and "f".

If I'd call the Damage(min,dmg) proc, I want to do it like this: Damage(a, strength.val * 4) (I use datums by the way (var/type = new(#,#)).

Could anyone please help me, provide me the information or tell me if it even exists? I think I just didn't look good enough.

- Rick
Hmm currently that's not possible. Is <code>min</code> inside the vars list of a certain datum? If min is a datum by itself, then why can't you do min.val?

EDIT: Is the type of <code>min</code> variant?
I don't get what you're trying to do. Look up the 'vars' var of datums.

mob
proc
Damage(datum/min,dmg)
min.vars["val"] -= dmg
src << min.vars["val"]
In response to Jemai1
stat
var{val;maxval}
New(v,mv){val=v;maxval=mv}
proc
String()return "[val]/[maxval]"
Procent()return "([val*100/maxval]%)"
RProcent()return "([round(val*100/maxval)]%)"

mob
var
NPC=0
stat
health=new(50,50)
stamina=new(50,50)
chakra=new(50,50)
nin=new(1,1)
gen=new(1,1)
end=new(1,1)
spd=new(1,1)
str=new(1,1)
ninexp=new(1,1)
genexp=new(1,1)
spdexp=new(1,1)
endexp=new(1,1)
strexp=new(1,1)
level=new(0,0)

That is what I mean by datums. :/
I want to be able to distract from health.val, stamina.val and chakra.val and perhaps others, too.
In response to Sokkiejjj
Something like this?
mob
proc
Damage(min,dmg)
var/stat/s = vars[min]
s.val -= dmg
src << s.val
In response to Jemai1
Suppose it's impossbile because I'm getting a big runtime error. xD
In response to Sokkiejjj
That's because my original post uses vars["min"] instead of vars[min]. I edited it if you didn't notice.
In response to Jemai1
Tried your latest, both runtime errors.
In response to Sokkiejjj
Well.. that's weird.

mob
proc
Damage(min,dmg)
if(!(min in vars))
CRASH("[min] is not a mob variable")
var/stat/s = vars[min]
if(!s)
CRASH("[min] is null")
s.val -= dmg
src << s.val


Usage:
Damage("health",10)
In response to Jemai1
That worked, thank you. ^^
In response to Sokkiejjj
No problem, Rick. ^^
In response to Jemai1
Get on MSN/Yahoo. xD