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


Joined: 06 Feb 2012
Posts: 11
Location: Phoenix

PostPosted: Mon Feb 06, 2012 5:57 am   

alias problem
 
Hi, I'm having a problem with passing an argument to an alias. I have an alias called runpath that accepts a string list as the first argument so for example, normally when I want to run my path I type the following

runpath @deathlyhallows

That will initiate the path into my variable and it will do it's thing. Recently I've wanted to create a circuit that will run many paths one after another in a loop. The rest of my script is sound and seems to be working, but when I get to the part where I want to run my path it does't work. I'm trying to call a path from a stringlist. the string list contains variable names such as @blah and @whatever.

I have an alias called death for testing, which contains the following

runpath %item(circuit1,1)

It is supposed to pull item number 1 from the stringlist circuit1 which is a variable. instead it initiates the alias runpath without an argument and then sends the item from the stringlist as a command to the mud. Is this a bug or is there another way to perform this? Any help would be appreciate. Thanks!
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Feb 06, 2012 12:47 pm   
 
That should be:
Code:
runpath %item(@circuit1,1)

but I suspect that was just a typo in your message; it sounds like you have it correct in your code.

If the item being pulled from @circuit1 is a variable name rather than an explicit stringlist, then the problem is clear. Cmud will parse the commandline and expand variables within it, but it won't automatically parse variable names which are the result of a function.

The most straightforward way of fixing this is to explicitly expand the result of the function:
Code:
runpath %expand(%item(@circuit1,1))


There are several other ways to do what you are thinking of. For instance, is there a reason you aren't using Cmud paths for this instead of your own implementation?
Reply with quote
kiyakerz
Beginner


Joined: 06 Feb 2012
Posts: 11
Location: Phoenix

PostPosted: Mon Feb 06, 2012 7:18 pm   
 
Rahab, amazing! I think that did the trick. I had a similar idea last night about why that was happening but it was getting late and my alternate solution would have been much less elegant. Thank you so much for your 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