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 ➜ Substitutes in Mush/Lua

Substitutes in Mush/Lua

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


Posted by Oligo   (26 posts)  Bio
Date Sat 09 Jun 2012 02:38 PM (UTC)

Amended on Sat 09 Jun 2012 02:41 PM (UTC) by Oligo

Message
I'm trying to port some string subs from Tintin to Mush but I've noticed some pretty significant performance degradation. I suspect it has to be with the way I setup the regex. I have roughly 100 of these spell subs.

In Tintin, the syntax I use is like
#sub {%1 wooden splint} {$1 wooden splint [LOW HEA]}


In Mush, I couldn't figure out an exact 1-to-1 match to the tintin #substitute command so I use a trigger with omit output to mimic #sub behavior. I do the following which seems to have heavy performance penalty. If I add an anchor ^ at the beginning of the pattern will that help performance? Or is there a more robust way or better technique to what I'm doing?
<trigger colour_change_type='1' enabled='y' expand_variables='y' group='spellcomps' 
	match="(.+) wooden splint(.*)" omit_from_output='y' regexp='y' 
	send_to='12' sequence='100' other_text_colour='white'>
  <send>ColourNote("silver","black","%1 wooden splint [LOW HEA]%2")</send>
</trigger>


Ideally if I encounter something like
A wooden splint is here. [2]

I'd like the sub to replace it with
A wooden splint [LOW HEA] is here. [2]

mud.arctic.org : 2700
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 09 Jun 2012 09:13 PM (UTC)
Message
The anchor may help, to save it having to keep retrying a match from position 1, position 2 and so on.

What will probably also help is uncheck "expand variables". Variables are where variable substitution is done, which you are not doing.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


9,973 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.