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 Problem Again. (I solved it! Nevermind!)

Colour Problem Again. (I solved it! Nevermind!)

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


Posted by Neoshain   (38 posts)  Bio
Date Thu 03 Oct 2013 11:51 PM (UTC)
Message
Ok, so I have this alias:


<aliases>
  <alias
   match="rpose*"
   enabled="y"
   send_to="12"
   omit_from_output="y"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>

message = string.gsub ("%1", "'(%a*%d*%s*%p*)'", "'@c%%1@y'")

Send("rpose @y" ..message.."@n")




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



What I'm trying to get is when I rpose something, anything within single quotes, (I'll also set it to do double quotes, but I'm just trying to get this working first) is in Dark Cyan. ("@c" is the colour code.)

Right now, the way it's working, any SINGLE word withing single quotes is changed. Punctuation and numbers are coloured too.

If I have any spaces there, it fails.

For instance, the following colours the "Hello!" but not the "Does this work" part.

Quote:

rpose Checking to see if this will work, 'Hello!' I hope it works. 'Does this work?'


I've tried lots of things, can't figure this out. :-( If I change the "Hello!" to "Hello there!" it fails.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 04 Oct 2013 05:01 AM (UTC)
Message
You want a set, rather than what you did.

However this seems to work:


<aliases>
  <alias
   match="rpose*"
   enabled="y"
   send_to="12"
   omit_from_output="y"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>

message = string.gsub ("%1", "'(^'-)'", "'@c%%1@y'")

Send("rpose @y" ..message.."@n")

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



That searches for a quote, followed by anything which is not a quote, followed by a quote.

The "set" looks like this:


<aliases>
  <alias
   match="rpose*"
   enabled="y"
   send_to="12"
   omit_from_output="y"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>

message = string.gsub ("%1", "'([%a%d%s%p]*)'", "'@c%%1@y'")

Send("rpose @y" ..message.."@n")

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


- Nick Gammon

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

Posted by Neoshain   (38 posts)  Bio
Date Reply #2 on Fri 04 Oct 2013 01:02 PM (UTC)
Message
Hmm, this still comes with a problem, It is colouring everything from "Hello" to "Work?" because I believe it is trying to match three "quoted" blocks.

Quote:

'Hello?'

Quote:

' I hope it works. '

Quote:

'Does this work?'


So what I'm trying to get it to do is only match when the quote has no spaces after the first single quote and no space before the last single quote.
Top

Posted by Neoshain   (38 posts)  Bio
Date Reply #3 on Fri 04 Oct 2013 01:13 PM (UTC)

Amended on Fri 04 Oct 2013 01:15 PM (UTC) by Neoshain

Message
Nope, I looked closer, and it's reading the quote as being from the very first single quotation mark -

Quote:

'Hel....


To the very last one.

Quote:

...work?'


I can't get it to stop matching after the first set of quotation marks. It DOES stop matching after the last one, because when I added text after it, without any more quotation marks

Quote:

Checking to see if this will work, 'Hello!' I hope it works. 'Does this work?' Well? Did it?


It coloured only the following, which is still too much:

Quote:

'Hello!' I hope it works. 'Does this work?'

Top

Posted by Neoshain   (38 posts)  Bio
Date Reply #4 on Fri 04 Oct 2013 01:21 PM (UTC)
Message
I GOT IT!

<aliases>
<alias
match="rpose*"
enabled="y"
send_to="12"
omit_from_output="y"
ignore_case="y"
keep_evaluating="y"
sequence="100"
>
<send>

message = string.gsub ("%1", "'([%a%d][%a%d%s.:;!?]*)'", "'@c%%1@y'")
Note(message)
Send("rpose @y" ..message.."@n")

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


The problem was tt was matching ' as part of the %p set, thus it just kept going over it. Thanks for your help!
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,125 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.