Gammon Forum
Entire forum
MUSHclient
Bug reports
DeleteLines()
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Indoum
Sweden (17 posts) bio
|
Date
| Sat 29 Jul 2006 05:25 PM (UTC) |
Message
| I was anxious to remake my entire visual-system with the DeleteLines() function. I made a simple trigger and tried it out. But MUSHclient crashed. Restarted MC and tried again, then it worked. After that I've tried maybe five times, everytime crashing the client without any discernable pattern.
The trigger I'm using is this:
<trigger>
<trigger enabled="y" keep_evaluating="y" match="^Using your daegger, you open a vein in your wrist\, and let the blood drip to \noutline a pentagram\, floating waist-high\.$" regexp="y" multi_line="y" lines_to_match="2" send_to="12">
<send>DeleteLines(2)
Note("Pentagram")</send>
</trigger>
</triggers>
| top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #1 on Sat 29 Jul 2006 10:10 PM (UTC) |
Message
| Hmmm, I see the problem here, this reminds me of why I wasn't in a big hurry to allow deleting in the first place.
During trigger processing MUSHclient has identified the last paragraph in the output buffer (set of lines terminated by a newline), and is applying trigger processing on that paragraph, followed by optional logging, etc.
However by doing DeleteLines in a send-to-script trigger you have yanked those lines away from it in mid-stream. Internally (in trigger/logging processing) it doesn't realize they are not there and crashes with bad pointers.
There would be a similar problem if you did DeleteLines in a trigger that went on to omit from output. It would try to omit the lines twice.
I think the solution in your case will be to call a script function (not send-to-script).
I am going to have to place a restriction on DeleteLines that it cannot be called from send-to-script, there are just too many problems if you do that. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #2 on Sat 29 Jul 2006 10:38 PM (UTC) |
Message
| Version 3.77 will now not allow you to call DeleteLines from send-to-script or a plugin callback.
I have amended the documentation on this site to mention this problem. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Indoum
Sweden (17 posts) bio
|
Date
| Reply #3 on Sun 30 Jul 2006 07:18 AM (UTC) |
Message
| Ahh, didn't realize that's your intended use for it.
Now, is there any way for my script functions to detect the number of lines that the trigger fired on? Search for \n in the line-parameter? I could ofcourse define that number, along with the text to replace the output, in the send-to script. Just wondering if there's any other way. | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #4 on Sun 30 Jul 2006 07:46 AM (UTC) |
Message
| No, searching for the \n will not work. See:
http://www.gammon.com.au/scripts/doc.php?function=GetLineInfo
You need to look for selector 3 (true if newline), however what you really want is to find the 2nd last line with a newline, + 1.
eg.
100: You feel rested. <--- newline
101: Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
102: sed diam nonummy nibh euismod tincidunt ut laoreet dolore
103: magna aliquam erat volutpat. Ut wisi enim ad minim veniam,
104: quis nostrud exerci tation ullamcorper suscipit lobortis nisl
105: ut aliquip ex ea commodo consequat. <--- newline
Now line 105 has a newline, however you would expect that. Line 100 is the last line from a previous batch, so line 101 is the start of the current paragraph.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #5 on Sun 30 Jul 2006 07:55 AM (UTC) |
Message
| However my remarks really only apply to a single-line trigger. For a multi-line one you might need to reapply the regexp from the multi-line trigger, on lines, working backwards from the end, until you find a match, to reliably find which line started the batch. |
- 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.
15,076 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.