If I did this
"[a]e"-=1
where a="a.food"
would that output a.foode-=1?
because that's what I'm trying to do :P
ID:266779
![]() Jun 24 2002, 8:38 am
|
|
Jon Snow wrote:
If I did this Almost. It would have to be in this form: "[a]e-=1" It's still just a text string, though. If you were trying to do math calculations on it, you need a different approach. |
the reason I was trying to do this is because...
I have htis mob/proc/at(var/mob/a as mob) if(b==1) spawn() src.frontat(a.food,a.defense,a.wave) else spawn() src.frontat(a.dod,a.elite,a.quit) mob/proc/frontat(var/a,var/b,var/c) now fo rthe frontat I'm trying to make it easier on me so that if I changed any of the things in at() I wouldn't have to make alot of extra useless coding... so I want b-=1 in frontat... get what I'm saying? so no matter what i change in at() I don't have to make extra code in frontat... but I get what you're saying and I'm probably going to have to do it that way... I was just hoping for a shortcut but that method is very innefficient because I have over a 100 vars that are like this--- mob/var food foode foodd foodc dod dode dodd dodc etc... and so on I was trynig to make an easy system so I could just go something like "[a]e"-=1 hehe sorta clever but not quite... Since it's a text string (I just now found out, I must have missed this when you explained it earlier Lummox) |
Jon Snow wrote:
so I want b-=1 in frontat... get what I'm saying? Yes, I think so. You want basically a reference to the var rather than the var itself. One way to do this is to change your proc to take the item and the var names, like this: proc/frontat(a,b,c,d) A better way, since you seem to have pairs of vars like food and foode, is to make a special datum to hold the pair. mydatum Or, you could set a datum for the group of values (which probably makes more sense): mydatum Then frontat() only needs to have a reference to this datum, and it can change any of the values within. Lummox JR |
Gads no. Didn't we cover all this in another thread where you were trying to do something similar?
"[a]e" is just a string. It evaluates to "a.foode". You can't subtract from it because it's not a var; it's just a string. Not only does "a.foode"-1 make no sense, but "a.foode"="a.foode"-1 makes less, because you can't assign a value to a string.
What you're looking for, I believe, is a.vars["foode"]. This is a reference to the var. It's basically the same as a.foode-=1. Notice, however, that while "food" is part of the var name, the "a." has to go outside. That part you can't evaluate from a string.
Lummox JR