|
mimique6 Newbie
Joined: 09 Jan 2003 Posts: 9 Location: USA
|
Posted: Thu Jan 09, 2003 9:29 pm
Dynamic code to render variables -- Need Assistanc |
I tried looking back several pages for a simular question, after that failed I figured I'd toss it out here.
I'm working on a 'vial' project, like many muds the one I play (Aetolia) lets you refill your healing vials. vials, usually, end up all looking the same only being distinguishable by vnums. (vial####)
To keep these sorted, I created two variables for each vial type. one @ehealth, @fhealth, etc (f=full, e=empty)
Now I'm creating a VIALS alias which will basically go through all the vials and echo the full/empty counts. Here is a snippet.
#if (@fhealth="") {full=0} {full=%numitems( @fhealth)}
#if (@ehealth="") {empty=0} {empty=%numitems( @ehealth)}
#ec Health - @full, @empty Empty.
The problem is that I'd have to have this for each vial-type, which would be very cluttered code. I have all the vial types (in this example, 'health' in a string-list called @viallist)
I was wondering if anyone could show me a way to render the above text using the %i from #forall. I've tried strange combinations of @f{%i}, etc, but they all seem to err.
Any help would be greatly appreciated.
Is it bad when Zmud plays more than you do? |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Jan 09, 2003 10:49 pm |
Don't overcomplicate things. Just put both variable names in your list for each type of vial and use fhealth and ehealth (you know what they mean) instead of Health - #,# - Empty. You don't need the #IF, %numitems for a null variable is 0.
#VAR VialList {fhealth|ehealth}
#AL VIALS {#FORALL @VialList {#ECHO {%i ~= %numitems( @{%i})}}}
Untested.
LightBulb
Senior Member |
|
|
|
mimique6 Newbie
Joined: 09 Jan 2003 Posts: 9 Location: USA
|
Posted: Fri Jan 10, 2003 6:07 am |
Ahh, Thanks! With your help I've got it working now. =)
~Mimique
Is it bad when Zmud plays more than you do? |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|