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
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sun Aug 15, 2004 12:21 am   

Executing commands stored in a variable
 
Hi,

I have a variable that contains several commands. The first is a command I want to send to the mud. The second is one I want zMUD to execute without sending to the mud (a predefined function - %maplocked( 1)). I want to just be able to run the variable from a macro, where currently I've got the macro (Macro Key7 defined as @KEY7 and @KEY7 is the variable with the two commands in).

You might ask why I'm using I'm binding a macro to a variable. That's so I can bind other keys to @KEY7 when I'm not using a numeric keyboard.

I can probably achieve the desired affect by using an alias instead of the variable, but is there any way of forcing zMUD to treat execution of a variable as if the lines in the variable were typed in on the command line?

Many thanks.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Aug 15, 2004 1:40 am   
 
Sure is. Use the #EXEC command.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sun Aug 15, 2004 1:50 am   
 
I'm afraid that doesn't work.

Here is what I've got:
Macro key "/" --> Send to MUD --> EXEC @KEY7

Variable KEY7:-
FLEE
#IF (%maplocked = 0) {
#MENU {Mapper|File|Follow Mode}
#ECHO Map switched to Follow Mode!
}

Each line is sent verbatim to the mud, not executed in the normal way. If I create an alias called KEY7 with the same contents as the variable, and then bind the key to the alias, it works fine, but it seems silly to use an alias for this - a variable would be more logical when I'm never going to type in the alias name into the command line.
Reply with quote
SCORNME
Novice


Joined: 25 Jul 2004
Posts: 48
Location: aka Falan

PostPosted: Sun Aug 15, 2004 6:56 am   
 
"it seems silly to use an alias for this - a variable would be more logical when I'm never going to type in the alias name into the command line."

Um, it works with an alias ... it seems logical to use an alias.

Library: "The important difference between aliases and variables is that aliases are only expanded when at the beginning of a command, while variables are expanded anywhere."
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sun Aug 15, 2004 12:21 pm   
 
Quote:
Library: "The important difference between aliases and variables is that aliases are only expanded when at the beginning of a command, while variables are expanded anywhere."


I'm not talking about expansion - I want it expanded - I just don't want the variable, once expanded, sent verbatim to the mud...
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Aug 15, 2004 5:43 pm   
 
So use an Alias And a Variable

ALIAS: Flee
VALUE:
~FLEE
#IF (%maplocked = 0) {
#MENU {Mapper|File|Follow Mode}
#ECHO Map switched to Follow Mode!
}

Then just set the value of @key7 to Flee
Or something along those lines
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sun Aug 15, 2004 6:19 pm   
 
Thanks, I like that. It means I can also alias f to Flee and have the same affect no matter if I press a macro or type "f".
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