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 ➜ Bug reports ➜ DeleteLines() doesn't always actually delete the lines

DeleteLines() doesn't always actually delete the lines

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


Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Mon 16 Mar 2009 07:41 PM (UTC)

Amended on Mon 16 Mar 2009 08:10 PM (UTC) by Nick Gammon

Message
I recently returned to using MUSHclient (version 4.37) and am now fiddling around to see how I can refit my system to take full advantage of all the goodies you stuffed it full of these last years. One problem I am having is with my visuals and text substitution. The test code I have set up is as follows.

<script><![CDATA[

function substitute(name, line, wildcards, styles)
	_, count = wildcards[0]:gsub('\n', '')
	DeleteLines(count + 1)
	if message then
		Note(message)
		message = nil
	end
end

]]></script>

<triggers>
  <trigger
   enabled="y"
   lines_to_match="2"
   keep_evaluating="y"
   match="^You are ranked (\d+)st in Imperian\.\nYou are ranked (\d+)st in Questing\.$"
   multi_line="y"
   regexp="y"
   script="substitute"
   send_to="12"
  >
  <send>message = 'Overall and Questing rank replaced'</send>
  </trigger>
</triggers>


It works like a charm! Except for the fact that every now and then, the DeleteLines() function leaves an empty line. It most often happens with the single line trigger (about seven out of ten times) but also sometimes with the multiline one (about two out of ten times).

Am I doing something wrong here or is there a bug with DeleteLines?

Simplicity is Divine | http://nogfx.org/
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 16 Mar 2009 08:18 PM (UTC)
Message
Well in that example it would appear you always need to delete 2 lines. Are there other examples with variable lines to delete?

I would try changing the trailing $ to \z (end of subject).

Also try changing the ^ to \A (start of subject).


- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Mon 16 Mar 2009 08:21 PM (UTC)
Message
Quote:

It most often happens with the single line trigger (about seven out of ten times) ...


Can you paste the single-line trigger then?

- Nick Gammon

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

Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Reply #3 on Mon 16 Mar 2009 09:22 PM (UTC)
Message
I added it above but I suspect you might accidently edited it away. :) It follows below.

<trigger
 enabled="y"
 keep_evaluating="y"
 match="^You are the \d+th ranked arena combatant with \d+ wins\.$"
 regexp="y"
 send_to="12"
 script="substitute"
>

<send></send>

</trigger>


It has the same callback, which counts the number of newlines (N) in the matching text and deletes lines accordingly (N+1 amount).

I tried changing the patterns to use \z and \A instead but it still leaves occasional blank lines.

Simplicity is Divine | http://nogfx.org/
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Tue 17 Mar 2009 01:20 AM (UTC)
Message
Oops, sorry. I fixed the formatting by pasting into MUSHclient and copying back but didn't notice the 2nd one.

I can reproduce your problem, not sure why. If you remove the message the extra line goes away. The blank line is marked as a note rather than MUD input.

What seemed to work for me was change Note to Tell. Then you see the message, and the blank line disappears. This is a bit of a kludge, but I think somehow after the omit there is a problem with transitioning back from a Note (which you put there) and the next line of output.

- Nick Gammon

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

Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Reply #5 on Tue 17 Mar 2009 06:59 AM (UTC)
Message
Thanks for looking into it so rapidly!

I tried removing the message bit all together, like how it's not used in the single line trigger. But that still leaves the blank line for me. So in my case, the Note/Tell doesn't affect whether an empty line is left after the omit.

Any other suggestion as to what could be wrong? Do you need any other information from me to debug it perhaps?

I am running MUSHclient under Wine with pretty much the default configuration, except for checking "convert IAC/GA to newline" and "match on empty lines". These two are my only triggers and I have placed them, along with the script, inside a plugin.

Simplicity is Divine | http://nogfx.org/
Top

Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Reply #6 on Wed 18 Mar 2009 08:13 PM (UTC)
Message
Can anyone else please give some suggestion(s) as to how I could proceed with this? Or is it perhaps a bug in MUSHclient that I will just have to try and live with for now?

Simplicity is Divine | http://nogfx.org/
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #7 on Wed 18 Mar 2009 10:13 PM (UTC)
Message
Since most of your problems (seven out of ten times) occur with a single-line trigger, simply make that trigger omit from output.

However upon investigating this problem I see things are worse than I thought.

For example, if I make a trigger to match on "blah" and use your trigger function to omit one line, and then send this:



aaaa
blah
blah
bbbb



What I see in the output window is:


aaaa
b
bbb


So there seems to be some serious issues with DeleteLines, and I will investigate that.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #8 on Thu 26 Mar 2009 03:15 AM (UTC)
Message
There appeared to be a subtle bug in DeleteLines. After deleting the line, it added a new blank one (as there has to be a line always for the next lot of input). However after processing the triggers, at the end of a line, it also adds a new line. It appeared that the bug hinged upon whether or not the memory allocator happened to give the same memory address to the new line, as the deleted one had. I think it is fixed now in version 4.41, however you may want to report on whether it works better now.

- Nick Gammon

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

Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Reply #9 on Thu 26 Mar 2009 07:02 PM (UTC)
Message
You, my good sir, kick some serious ass!

I take it you haven't released 4.41 yet? Or maybe I'm just looking at the wrong place.

Simplicity is Divine | http://nogfx.org/
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #10 on Thu 26 Mar 2009 08:06 PM (UTC)
Message
Correct, not released yet.

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


29,379 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.