Register forum user name Search FAQ

Gammon Forum

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 ➜ Randomly affecting every letter you type?

Randomly affecting every letter you type?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Spetz   (8 posts)  Bio
Date Wed 16 Feb 2011 12:02 AM (UTC)

Amended on Wed 16 Feb 2011 12:26 AM (UTC) by Spetz

Message
I was wondering if it was possible to make a trigger that affects every letter I type. My goal is to be able to turn this:

chat Hello!

into something like:

chat |bk|h|br|e|by|l|bp|l|bg|o|bc|!

But I want all the colors (everything inside the divider lines) to be randomly generated, and match anything I enter into chat as long as the trigger is activated. I honestly don't know where to even begin. When it comes to the script I will need. I just know it is possible because I have seen it done.

The colors available are:

BK, B, BB, C, BC, G, BG, R, BR, Y, BY, W, BW, P, BP

I was thinking I would have to use a table and the math.random but I honestly have no idea how to make it work.

Any suggestions? Even if you just start by pointing me in the right direction?

Post Post:
So while I was thinking here is what I have come up with:

<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   keep_evaluating="y"
   match="????????????"
   send_to="12"
   sequence="100"
  >
  <send>local randcolors {
   "|BK|", 
   "|B|",
   "|BB|,
   "|C|",
   "|BC|",
   "|G|",
   "|BG|",
   "|R|",
   "|BR|",
   "|Y|",
   "|BY|",
   "|W|",
   "|BW|",
   "|P|",
   "|BP|",
 }

Send (randcolors  [math.random (1, #randcolors)])</send>
  </trigger>
</triggers>


Obviously I am not actually trying to match ????????????, But I didn't know what else to right for the time being. Maybe this will at least saves you (whoever can help me) a bit of time. All it does is recall a random object from the table "randcolors" and sends it to the mud.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 16 Feb 2011 06:31 AM (UTC)
Message
Do you really want a trigger? Sounds to me like you are trying to colour what you type, which is an alias.

Below is an example of how you might do that, built on what you had:


<aliases>
  <alias
   match="chat *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>local randcolors = {
   "|BK|", 
   "|B|",
   "|BB|",
   "|C|",
   "|BC|",
   "|G|",
   "|BG|",
   "|R|",
   "|BR|",
   "|Y|",
   "|BY|",
   "|W|",
   "|BW|",
   "|P|",
   "|BP|",
 }

local message = "%1"

local s = ""

for i = 1, #message do
  s = s .. randcolors  [math.random (1, #randcolors)] .. message:sub (i, i)
end -- for

Send (s)
</send>
  </alias>
</aliases>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


You type "chat nomnomnom" and it actually sends:


|Y|n|BG|o|BY|m|P|n|BG|o|BP|m|G|n|BC|o|BW|m


So what it has done is picked apart what you wanted to chat, and inserted the random colour between each letter.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Spetz   (8 posts)  Bio
Date Reply #2 on Wed 16 Feb 2011 05:38 PM (UTC)
Message
Yes an alias was exactly what I needed. I appreciate all the help and I am honestly very impressed at the quality of support there is for this client (especially since it is free).

The only thing I had to change was:

send ("chat", s)
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.


13,910 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.