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
astrotaz
Beginner


Joined: 09 Aug 2011
Posts: 12

PostPosted: Fri Oct 07, 2011 9:39 pm   

quick question on variable and text
 
Hi --

I have a set of aliases which I'm using to move a path

eg:

alias chk1 e

alias chk2 s

alias chk3 s


I use another alias "walk" to initiate the aliases above as follows

chk@stepnum
#ad stepnum 1



the var stepnum is set as an integer

my problem is

the output is

chk 0
chk 1
chk 2

and not

chk0
chk1
chk2


I must be missing something simple but the extra space after the text and before the var is breaking things.

Thanks in advance.

Astro
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Oct 07, 2011 11:38 pm   
 
Change it to #EXEC %concat("chk",@stepnum) and you'll be fine.
Reply with quote
astrotaz
Beginner


Joined: 09 Aug 2011
Posts: 12

PostPosted: Fri Oct 07, 2011 11:47 pm   
 
Beautiful works ! Interesting that you need to concatenate specifically. I just upgraded from zmud and that allowed chk@stepnum to work as is.

Thanks for helping me out.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sun Oct 09, 2011 12:49 am   
 
It would be a lot easier to just create a single variable (a stringlist) containing all of the path steps. Then you use %pop() to get the next step to take, e.g.:
Code:

#VAR mysteps {e|s|s}

#WHILE (@mysteps) {
  #SEND %pop(@mysteps)
}

This has many advantages. First, it can handle an arbitrarily long list of directions. Second, you only need a single variable. Third, you don't need to use #EXEC. #EXEC should be avoided when possible, in part because it prevents the script from being precompiled, which makes the script much slower.
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