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
zperetz
Newbie


Joined: 09 Oct 2009
Posts: 3

PostPosted: Fri Oct 09, 2009 7:25 pm   

Single symbol substitute in #ONINPUT
 
Hi everyone,

could you help me with a little problem. I'm trying to substitute one symbol with another during commands input. But all my aliases and triggers do not give the result.

So the issue is very simple (substitute "e" with "E", for example)- if I'm typing

"The rabbit goes east."

the alias should send to zMud

"ThE rabbit goEs East."

Is it possible to write such kind of thing?

Thanks in advance for help.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Oct 10, 2009 2:51 am   
 
have you tried %replace(%1,"e","E")?
_________________
EDIT: I didn't like my old signature
Reply with quote
zperetz
Newbie


Joined: 09 Oct 2009
Posts: 3

PostPosted: Sat Oct 10, 2009 10:35 am   
 
If it should look like

#ONINPUT {*e*} {%replace(%1,"e","E")}

so no, it's not working. But maybe my understanding of #ONINPUT is not correct. Can anybody help?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Oct 10, 2009 8:58 pm   
 
You are on the right track, except for two things:

1)when you want to do stuff to the matched pattern, you need to surround it (or the relevant sections therein) with parentheses:

#oninput {(*)} {blah blah blah}

Certain commands/functions don't necessarily need this reference (ie, #PSUB, #CW, etc).

2)functions return a value, so using them as in your example will probably result in two very serious issues for you to deal with:

a)an extra bit of text being sent to your game (ie, if you typed "fred" the result will be "fred;frEd")

b)because the result of the function in this case is likely to be identical/similar to the original text, the trigger will fall into an infinite loop. In this case, ZMud should pop up a dialog telling you about this and will probably either disable the trigger or offer you a suspended window of opportunity to deal with the problem.

To fix this, use #CALL or some other command (ie, #SEND or #PSUB, since you want to send the result to the game) when you want to swallow the results of your function.

The final trigger will probably be something like:

#oninput "tCommandInput" {(*)} {#psub %replace("%1","e","E") %x1}

You didn't provide any context for the text you want to do, so I provided the trigger name (tCommandInput) to allow you to control the enabledness. If there are a limited number of possible matches, you could instead change the pattern (the part in bold) to something a lot more specific. This will probably speed up the trigger, depending on what you change it to, though the savings might not be noticeable.
_________________
EDIT: I didn't like my old signature
Reply with quote
zperetz
Newbie


Joined: 09 Oct 2009
Posts: 3

PostPosted: Sat Oct 10, 2009 11:29 pm   
 
Thanks!

After a few tries with your corrections the final trigger looks like

#oninput {(*)} {%replace( "%1", "e", "E")}

It really works! Thanks again and good luck! :)

Actually this trigger helps with different languages (like russian), where zMud has no support.
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