Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
whorn
Wanderer


Joined: 04 May 2002
Posts: 52
Location: USA

PostPosted: Fri Jan 02, 2009 6:20 pm   

Using a variable to reference a dynamic variable
 
So I've been messing with this for awhile and I can't get it to work the way I have envisioned.

Basically I want a variable to be used off the result of a different variable. Here is the trigger I have:



Code:

Pattern:

- ~[($code:&28)~] - somewhere

Trigger:

#IF (%item( @SpidersTable, @SpidersPos) <> "none") {
  #SAY Assigned $code to %item( @SpidersTable, @SpidersPos)
  #ALIAS %item( @SpidersTable, @SpidersPos) {fade $code} {FadeScript|FadeAliases}
  }
#ADD SpidersPos 1
#IF (@SpidersPos > %numitems( @SpidersTable)) {#T- {FadeScript|Spiders}}



Basically I want @SpidersTable to be dynamic. I have another variable called @FadeRank that I want to append onto @SpidersTable when it is used. So it would be like @SpidersTable5 or @SpidersTable-5 if @FadeRank = 5, ect. I hope this makes sense. I tried @{@SpidersTable}FadeRank} and that didn't seem to work how I thought it would.

Any help would be great.

Thanks!
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Fri Jan 02, 2009 6:52 pm   
 
You're missing an @.

@{@SpidersTable@FadeRank}
Reply with quote
whorn
Wanderer


Joined: 04 May 2002
Posts: 52
Location: USA

PostPosted: Fri Jan 02, 2009 7:39 pm   
 
gamma_ray wrote:
You're missing an @.

@{@SpidersTable@FadeRank}


That didn't seem to work either. And after looking at it shouldn't it be something like:

@{LookupTable@FadeRank}

Since the end output I want is @LookupTable5?
Reply with quote
whorn
Wanderer


Joined: 04 May 2002
Posts: 52
Location: USA

PostPosted: Fri Jan 02, 2009 8:29 pm   
 
Aha! @{LookupTable@FadeRank} was what I was looking for. I was having issues other places that was causing me problem. You helped point me in the right direction though. Thanks!
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Jan 03, 2009 1:26 am   
 
If you want to have text AFTER the dynamic part of the variable name, you'll need to use an expression inside the {}s (or just the concat function) to join the two strings together. But what you have will work fine for this example.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
whorn
Wanderer


Joined: 04 May 2002
Posts: 52
Location: USA

PostPosted: Sat Jan 03, 2009 2:14 am   
 
This is what I finally ended up with:

Code:


@{@{FadeLoc}_FadeTable_@FadeRank}



Thanksf or all the help :).
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net