Colour setting.

Posted by Neoshain on Tue 13 Aug 2013 03:43 AM — 6 posts, 24,495 views.

#0
Ok, so I have this script, and it does its job wonderfully:



<aliases>
  <alias
   match="^chat (.?)(.*)"
   echo_alias="y"
   group="Neo"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>if Speaking == nil then
    Speaking ="basic"
end --if

if Speaking == "basic" then
Send("chat &R(&CIn a Neutral Corellian accent&R): &Y%1&O%2")

elseif Speaking == "clan" then
Send("chat &R(&CIn clan, in a Neutral Corellian accent&R): &Y%1&O%2")

else
Send("chat &R(&Cheavily accented&R): &Y%1&O%2")

end</send>
  </alias>
</aliases>



Obviously, the &C and &R and the like are my mud's colour coding. What I have done to help with roleplaying a bit, is for each of my characters, I've set up a colour scheme and a accent function on all IC channels. The accent function works fine, adjusting for each character depending on the language they are currently speaking. It's awesome and I get lots of Roleplaying cudos.

What happens is, whenever I speak, the first letter of the message is Bright Yellow, and the rest comes as Brown. It's a cool affect that I like a lot. Now, here's what I want to do:

I want to make it so not just the first letter of the whole message, but rather the first letter of each sentence is the bright yellow. (Or red for another character, or green for another character)

I've tried combining this alias with another that matches all single periods and takes the first letter after \s+ and then does that, using "keep evaluating" in each of the aliases, the one above, and the one with the periods. It doesn't seem to work, it crashes the client, actually.

Is there a way I can do this? I've tried all sorts of things and even have a few more ideas. But I've run out of time tonight and wanted to go ahead and ask you guys.
Amended on Tue 13 Aug 2013 03:45 AM by Neoshain
Australia Forum Administrator #1
How about this?


<aliases>
  <alias
   match="chat *"
   enabled="y"
   echo_alias="y"
   group="Neo"
   send_to="12"
   omit_from_output="y"
   ignore_case="y"
   sequence="100"
  >
  <send>

if Speaking == nil then
    Speaking ="basic"
end --if

message = string.gsub ("%1", "(%%a)(%%a*)", "&amp;Y%%1&amp;O%%2")

if Speaking == "basic" then
  SendNoEcho ("chat &amp;R(&amp;CIn a Neutral Corellian accent&amp;R): " .. message)
elseif Speaking == "clan" then
  SendNoEcho ("chat &amp;R(&amp;CIn clan, in a Neutral Corellian accent&amp;R): " .. message)
else
  SendNoEcho ("chat &amp;R(&amp;Cheavily accented&amp;R): " .. message)
end


</send>
  </alias>
</aliases>



Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
#2
That gives me every single word beginning with the bright colour. Which is cool, but a bit distracting for what I want. I just want the bright coloured letter to be after a . ! ? ; :

I'm going to keep working on it of course. But any help would, as always be appreciated.
Australia Forum Administrator #3
Well, tweak the regular expression a bit. This is closer although you might spot a couple of problems, I'm sure you can fix them with this as a guide.


<aliases>
  <alias
   match="chat *"
   enabled="y"
   echo_alias="y"
   group="Neo"
   send_to="12"
   omit_from_output="y"
   ignore_case="y"
   sequence="100"
  >
  <send>
if Speaking == nil then
    Speaking ="basic"
end --if

message = string.gsub ("%1", "(%%a)([^%p]*)", "&amp;Y%%1&amp;O%%2")

if Speaking == "basic" then
  SendNoEcho ("chat &amp;R(&amp;CIn a Neutral Corellian accent&amp;R): " .. message)
elseif Speaking == "clan" then
  SendNoEcho ("chat &amp;R(&amp;CIn clan, in a Neutral Corellian accent&amp;R): " .. message)
else
  SendNoEcho ("chat &amp;R(&amp;Cheavily accented&amp;R): " .. message)
end


</send>
  </alias>
</aliases>

Australia Forum Administrator #4
This is probably pretty close:


<aliases>
  <alias
   match="chat *"
   enabled="y"
   echo_alias="y"
   group="Neo"
   send_to="12"
   omit_from_output="y"
   ignore_case="y"
   sequence="100"
  >
  <send>

if Speaking == nil then
    Speaking ="basic"
end --if

message = string.gsub ("%1", "(%%a)([^!?.]*)", "&amp;Y%%1&amp;O%%2")

if Speaking == "basic" then
  SendNoEcho ("chat &amp;R(&amp;CIn a Neutral Corellian accent&amp;R): " .. message)
elseif Speaking == "clan" then
  SendNoEcho ("chat &amp;R(&amp;CIn clan, in a Neutral Corellian accent&amp;R): " .. message)
else
  SendNoEcho ("chat &amp;R(&amp;Cheavily accented&amp;R): " .. message)
end


</send>
  </alias>
</aliases>

#5
Sweet! That works. I know what I was doing wrong! I was trying to make it look for the punctuation first, to trigger the next sentence, but rather than that, done your way looks for the sentence as a whole and just separates the sentences! Thank you!

I've found the "string.find" page, that is also clearing a lot up for me! Thank you for the help! Everytime I think I've learned a ton about all this, I find out there's SOOOOO much more to learn. That's what makes this so exciting to me.