Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Changing input to other words
Changing input to other words
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Lucindrielle
(10 posts) Bio
|
Date
| Thu 17 Jan 2008 06:38 PM (UTC) Amended on Thu 17 Jan 2008 06:47 PM (UTC) by Lucindrielle
|
Message
| I have a character that uses the Imperal We, instead of "I". Problem is, sometimes I forget and use I anyway.
Is there a way to make a trigger or an alias to replace "I" if it's alone and sent the rest of the line to the world?
For example:
[say I don't know.] would send to the world as [say We don't know.]
I think it's tricky because "I" can be anywhere in the sentence and I'm not sure how to get it to leave the other commands (channels and whispers and such) and words before it and words after it alone.
Plus, there's the whole "I am" "We are" issue....
Wow, can of worms?
| Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 17 Jan 2008 07:32 PM (UTC) |
Message
| This is an interesting challenge. :)
I presume you want to convert the I in "I see you" but not the I in "wine" or "pie"?
My first approach is a simple alias like this:
<aliases>
<alias
match="^(.+)\b(I)\b(.+)$"
enabled="y"
regexp="y"
sequence="100"
>
<send>%1We%3</send>
</alias>
</aliases>
This uses \b as the "world boundary" assertion, which isolates "I" to be a word on its own. I use a wildcard before and after the I (this is %1 and %3 in the send area) so I can echo back that part.
This converts:
say I see you
to:
say We see you
You can also handle changing "I am" to "We are" like this:
<aliases>
<alias
match="^(.+)\b(I am)\b(.+)$"
enabled="y"
regexp="y"
sequence="90"
>
<send>%1We are%3</send>
</alias>
</aliases>
I would make this a lower sequence (I used 90) so it gets detected first, before "I" on its own.
However I can see two problems with this simple approach:
- It doesn't handle multiple "I" in one sentence, eg.
say I wonder if I should eat yet
- The word "I" is always capitalized but "we" is not necessarily, eg.
say I see you --> say We see you
say This is something I wonder --> say this is something we wonder
For the second problem you can probably leave "we" in lower case as people probably don't bother capitalizing the start of a sentence when typing in MUDs much.
This alias below tries to solve this with a bit of scripting.
<aliases>
<alias
match="^.+\bI\b.+$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
phrase = "%0"
phrase = (string.gsub (phrase, " I am ", " we are " ))
phrase = (string.gsub (phrase, "%a+", { ["I"] = "we" } ))
Send (phrase)
</send>
</alias>
</aliases>
First the alias simply matches on a line with "I" in it somewhere. Then the Lua script first does a string.gsub (global substitution) to replace any instance of " I am " (note the spaces) with " we are ". By using spaces we make sure that the "I" is a full word.
Next for "I" on its own I simply used a search for one or more letters (and Lua makes a "greedy" search so you are guaranteed of a word) and then looks up the result in a small table. This table replaces "I" with "we". |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #2 on Thu 17 Jan 2008 07:45 PM (UTC) Amended on Thu 17 Jan 2008 07:47 PM (UTC) by Nick Gammon
|
Message
| To be fussier about it, this version handles making "We" into capitals at the start of a line. To do this we need to know where what you type really starts (that is, the word "say" is not the start of the line), so we need to change the alias to match on all the ways you can talk (see below). It uses the | character as an "or" operator (ie. say or yell or chat). You can expand that to do other talking operators. Note the space after each word, as you wouldn't type "sayhello". I have also allowed for talking with the quote symbol, eg.
"hi there
In this case I assume no space.
Now what we do is the same as before, except at the end we change "we" at the start of the line (ie. "^we") to "We".
Also we have to put back the "action" word (say, chat etc.)
<aliases>
<alias
match="^(say |yell |chat |")(.*\bI\b.*)$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
phrase = "%2"
phrase = (string.gsub (phrase, "^I am ", "We are " ))
phrase = (string.gsub (phrase, " I am ", " we are " ))
phrase = (string.gsub (phrase, "%a+", { ["I"] = "we" } ))
phrase = (string.gsub (phrase, "^we ", "We " ))
Send ("%1" .. phrase)
</send>
</alias>
</aliases>
Example:
say are you thinking what I am thinking? - I hope not
--> becomes:
say are you thinking what we are thinking? - we hope not
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Lucindrielle
(10 posts) Bio
|
Date
| Reply #3 on Thu 17 Jan 2008 08:11 PM (UTC) |
Message
| Awesome, it works great! Thank you so much for your effort! | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #4 on Thu 17 Jan 2008 09:30 PM (UTC) |
Message
| Would it really matter if the "We" was supposed to be lowercase normally? I have no idea how much of a stickler you are for punctuation, but I thought that the royal pronoun for the self was always capitalized, being a proper noun. Granted, I may be totally off, since I never really payed all that much attention to the rules for nosism. |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #5 on Thu 17 Jan 2008 09:56 PM (UTC) |
Message
| Ok, after a bit of research, it appears I am wrong. Royal people are apparently less full of themselves than common people. They use lowercase when appropriate, whereas the common people insist they are worthy of capitals all the time. Did I ever mention I hate English? |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
18,715 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top