Randomly affecting every letter you type?

Posted by Spetz on Wed 16 Feb 2011 12:02 AM — 3 posts, 14,631 views.

#0
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.
Amended on Wed 16 Feb 2011 12:26 AM by Spetz
Australia Forum Administrator #1
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.
#2
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)