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 ➜ Lua ➜ Colour setting.

Colour setting.

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


Posted by Neoshain   (38 posts)  Bio
Date Tue 13 Aug 2013 03:43 AM (UTC)

Amended on Tue 13 Aug 2013 03:45 AM (UTC) by Neoshain

Message
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.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 13 Aug 2013 07:11 AM (UTC)
Message
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.

- Nick Gammon

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

Posted by Neoshain   (38 posts)  Bio
Date Reply #2 on Tue 13 Aug 2013 01:59 PM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Tue 13 Aug 2013 02:15 PM (UTC)
Message
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>


- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Tue 13 Aug 2013 02:17 PM (UTC)
Message
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>


- Nick Gammon

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

Posted by Neoshain   (38 posts)  Bio
Date Reply #5 on Tue 13 Aug 2013 02:38 PM (UTC)
Message
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.
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.


23,399 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.