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
asm
Wanderer


Joined: 19 Jul 2004
Posts: 68

PostPosted: Sun Dec 12, 2004 6:53 am   

Parsing user input before transmission.
 
I am writing a script that parses input typed by the user before it is transmitted to the MUD. Although I have completed the parser, the problem is actually capturing the input. Basically, what I want it to do is, if at the start of a line the user types word1 followed by string1, where string1 can be any number of words, I'd like string1 to be passed through the parser, processed, and then sent to the mud in it's processed form.

Let me make sure one itemis completely understood:
The actual parser and script itself is complete, except for the detail of obtaining the input.

#ALIAS, unfortunately, cannot be used for this reason:
Quote:
Aliases can also contain Parameters. Parameters are the text following the shortcut. For example, if you enter fs foo bar, fs is the alias shortcut, foo is the first parameter, bar is the second parameter. Parameters are assigned to specific numeric variables %1 through %99. In the previous case, %1 would contain foo, and %2 would contain bar. You can use these parameters in the alias itself.

source: #ALIAS help file

^ The problem here is that it splits every word into a seperate variable...%1, %2, %3, and so on, which is unacceptable, and due to the limitations of this scripting language, the only person who can change this is Zugg himself.

When information is being past through a trigger, it can be done through the "*" character, and, therefor, %1 could contain one word, or several, but the entirety of the captured text would be in %1.

The reason this is not accomplishable with #ALIAS is that it treats each parameter analogously to %w. Triggers, AFAIK, can only be used to capture text from the MUD itself.

Now, I'm hoping I'm either wrong about something or someone knows an alternate method of capturing input before it is transmitted. Anyone know of a solution?

Regards,
--asm
Reply with quote
digits
Beginner


Joined: 17 Jul 2004
Posts: 15

PostPosted: Sun Dec 12, 2004 10:07 am   
 
%-1 captures everything

Code:
#alias foo {
    #sa %-1
}
Reply with quote
Falan
Wanderer


Joined: 17 Aug 2004
Posts: 98
Location: OK, USA

PostPosted: Sun Dec 12, 2004 12:00 pm   
 
This one is easily missed in the Help files since it's not under "Intro. to Aliases". I think it's only located under #ALIAS.
Quote:
Text following the aliasname in the command line is stored in parameters. These parameters %1 through %99 can be used in the string definition of the alias. Special parameters %-1 through %-99 are also defined which represent the parameter plus all text following it. Thus, %-1 contains all text following the alias. %-2 contains everything past the first parameter, and so on. Thus, in the example alias foo bar, alias is the aliasname, foo is assign to %1, bar is assigned to %2, foo bar is assigned to %-1, and bar is assigned to %-2. Any text following the aliasname that is not used as a parameter is appended to the results of the alias expansion.


emphasis added
_________________
zMUD 7.05a
Reply with quote
asm
Wanderer


Joined: 19 Jul 2004
Posts: 68

PostPosted: Sun Dec 12, 2004 3:38 pm   
 
I see. Thank you very much.

Regards,
--asm
_________________
My collections of scripts.
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