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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
fossie
Beginner


Joined: 09 Aug 2002
Posts: 12
Location: Norway

PostPosted: Fri Oct 25, 2002 5:30 pm   

alias trouble - unwanted infinite loops
 
Hi

Is there any way of sending a command to the mud when the command is also an alias in zmud?

E.g:
#alias w w

When I hit w I want it to send w to the mud, not start looping the alias. I tried using ['s (#alias w [w]) hoping it would expand somehow, but then the alias w becomes only [ and nothing more.

Hope you can help!

Thanks
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Fri Oct 25, 2002 5:48 pm   
 
Try #alias w ~w

Rorso
Currently using zMUD 6.36b
Reply with quote
fossie
Beginner


Joined: 09 Aug 2002
Posts: 12
Location: Norway

PostPosted: Fri Oct 25, 2002 7:56 pm   
 
Thanks, that works :)
Unfortunately my problems are not entirely over.
I'm trying to make a set of walking-aliases. On my mud one can walk in different ways, so I need to be able to issue different commands according to which way I'm walking: run east, walk east, sneak east. Now I want my aliases to work so that I can walk in different modes by changing a variable. I've set it up like this:

#alias w @dirwest;
#math dirwest @movetype+@space+@dirw;
#var dirw w;

Now I can change what type of movement I use by simply changing doing #var movetype sneak, and #var space " ". (Ok, the @space looks odd, but Z-mud wouldn't accept #var movetype "sneak " - it would remove the space in the end, making the variable @dirwest sneakwest.)

Now this of course triggers an infinite loop. I tried using #math dirwest @movetype+@space+~@dirw, but that didn't work. I also tried #var dirw ~w, but that didn't work either. (They result in 'sneak ~@dirw' and 'sneak ~w' respectively.)

Is there any way of fixing this?

Thanks again! :)
Reply with quote
Lalaynya
Wanderer


Joined: 23 Aug 2002
Posts: 96

PostPosted: Fri Oct 25, 2002 8:29 pm   
 
Hmm... how about

#AL {w} {@movetype ~w}

Why so complicated? *boggle*
Reply with quote
fossie
Beginner


Joined: 09 Aug 2002
Posts: 12
Location: Norway

PostPosted: Fri Oct 25, 2002 8:56 pm   
 
I'd like to be able to change both walking mode and which direction I'm walking. In other words I don't don't always want to walk westward even though I activate the w-alias... So I need the direction to be variable too.

E.g: I get confused in a maze and all the exits are switched 90 degrees. Now if I can switch all the directions I'm walking I won't get lost as easily. (change w to n, n to e, e to s, and s to w)

Sorry it seems complicated, but it's the best solution I could think of :P
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Oct 26, 2002 1:35 am   
 
In that case you will have to use the #SEND command.

#ALIAS w {#SEND {@movetype @dirw}}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Oct 26, 2002 4:35 am   
 
A simple means to avoid this kind of loop is to use the long version of the command for the alias, and the short version for the command, or vice-versa.
#AL w west
or
#AL west w

LightBulb
Senior Member
Reply with quote
fossie
Beginner


Joined: 09 Aug 2002
Posts: 12
Location: Norway

PostPosted: Mon Oct 28, 2002 11:38 am   
 
Thanks for your help :)
I'm afraid I couldn't get the #send command to work though. As far as I can understand it merely sends whatever text is in a file to the mud. I tried using it with variables as suggested, but it didn't seem to do anything. (Probably because it was looking for a file with the name of the variables?) I also tried creating a file containing only the variable names and sending the file (#send test.txt), but then it simply sends the variable-names ('@movetype @dirwest') to the mud :( Am I doing something wrong?

As for Lightbulb's idea, I already tried that, but not all exits have long and short versions :/ (in, out, enter etc)

Thanks again for your efforts :)
Reply with quote
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Mon Oct 28, 2002 4:28 pm   
 
i don't think the #send command is necessary. i tried this alias on my version (6.36b) and it worked fine :)
#var type sneak
#var dirw w
#alias w {@type @dirw}

it shouldn't loop on this even though the name of an alias is being sent, since its sent as the second word on a line.
for your maze problem, i would write 5 more of these alias' (n,e,s,u,and d) or more depending on the # of exits your mud uses, and a trigger
#TR {You get confused by the maze.} {
#var dirw n
...
#var diru d}

but ofcourse put the real pattern instead of "You get confused..."
Reply with quote
fossie
Beginner


Joined: 09 Aug 2002
Posts: 12
Location: Norway

PostPosted: Mon Oct 28, 2002 6:30 pm   
 
Ok, now the circle is soon complete :)
This works fine, only problem is that I sometimes don't want to give a specific movetype and rather have the output be only 'west'.
Using #alias w {@type @dirw} the text sent to the mud would be ' west' (with a space in front of the 'west'), which the mud won't understand. :(
This is why I came up with the whole #math thing all the way back in the first post, but then again I get circular references :P

Any quick fixes? :)
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Oct 28, 2002 7:35 pm   
 
quote:
As for Lightbulb's idea, I already tried that, but not all exits have long and short versions :/ (in, out, enter etc)

Since you name the aliases, you can easily give any direction any name of your choice. It doesn't matter whether the MUD would recognize it or not. You'll be surprised how fast you learn to make the substitution yourself.
#AL i in;#AL o out
#AL inn in;#AL ou out
#AL here in;#AL there out
quote:
Using #alias w {@type @dirw} the text sent to the mud would be ' west' (with a space in front of the 'west'), which the mud won't understand.

Use the %trim function. Or the %if function. Or the #IF command. There's lots of possibilities.
#AL w (#IF (@type) {@type @dirw} {@dirw}}

LightBulb
Senior Member
Reply with quote
fossie
Beginner


Joined: 09 Aug 2002
Posts: 12
Location: Norway

PostPosted: Tue Oct 29, 2002 2:45 pm   
 
Ah, of course...
Thanks, you're a peach! (or any other fruit you find it pleasant to compare yourself with)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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