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 function not working

DeleteLines function not working

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


Posted by Rollanz   (26 posts)  Bio
Date Tue 21 May 2019 06:28 PM (UTC)
Message
If I'm understanding the documentation for DeleteLines function correctly, it should work if I have a trigger call a function in my script file which calls the DeleteLines function. But it seems to be failing silently instead.

Steps to replicate:
1) Add a wrapper for DeleteLines to the script file.

GagLines = function()
  --print("deleting a line")
  DeleteLines(1)
end


2) Create a trigger that calls the wrapper (the one below matches calls the wrapper when a prompt is received).

<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^.+$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>local count = GetLineCount()

if count==GetInfo(289) then
  GagLines()
end</send>
  </trigger>
</triggers>


Additional notes:
-I originally encountered the problem on version 5.06. To confirm this was not due to interaction with plugins/other code, I created a blank world in v5.07 pre-release with default settings other than checking the "Convert IAC EOR/GA to new line" option and the code shown above. I was playing Achaea
-Increasing the argument of DeleteLines to 2, 5, and 10 did not make a difference.

Thanks in advance.
Top

Posted by Nick Gammon   Australia  (23,163 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 21 May 2019 08:35 PM (UTC)
Message
You aren't following the instructions in the documentation:

Quote:

Warning - do NOT call DeleteLines from a trigger, alias or timer using send-to-script. For design reasons this will not work. In version 3.76 you will cause the client to crash if you do this. In version 3.77 upwards it will silently fail (ie. do nothing).


You are using send-to-script, right? Just putting the function into a script file doesn't change the fact that you are deleting the lines from a script that starts in send-to-script.

You need to not use send-to-script and put the function name into the "Script" box of the trigger, like this:


<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^.+$"
   regexp="y"
   script="prompt"
   sequence="100"
  >
  </trigger>
</triggers>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


Now the script file should contain:


function prompt (name, line, wildcards, styles)
  local count = GetLineCount()
  
  if count==GetInfo(289) then
      DeleteLines(1)
  end
end -- prompt


The processing of scripts in this way is deferred internally in such a way that you are allowed to delete lines.

The arguments aren't used in this particular case so you could just make it:


function prompt ()
  local count = GetLineCount()
  
  if count==GetInfo(289) then
      DeleteLines(1)
  end
end -- prompt

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,163 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 22 May 2019 12:13 AM (UTC)
Message
I admit the documentation might have been a bit ambiguous in that respect. I have amended the online documentation to make it clearer:

Template:function=DeleteLines DeleteLines

The documentation for the DeleteLines script function is available online. It is also in the MUSHclient help file.


- Nick Gammon

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

Posted by Rollanz   (26 posts)  Bio
Date Reply #3 on Wed 22 May 2019 02:12 AM (UTC)
Message
Nick Gammon said:

You aren't following the instructions in the documentation:

Quote:

Warning - do NOT call DeleteLines from a trigger, alias or timer using send-to-script. For design reasons this will not work. In version 3.76 you will cause the client to crash if you do this. In version 3.77 upwards it will silently fail (ie. do nothing).


You are using send-to-script, right? Just putting the function into a script file doesn't change the fact that you are deleting the lines from a script that starts in send-to-script.

You need to not use send-to-script and put the function name into the "Script" box of the trigger, like this:


<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^.+$"
   regexp="y"
   script="prompt"
   sequence="100"
  >
  </trigger>
</triggers>


(pasting)

Now the script file should contain:


function prompt (name, line, wildcards, styles)
  local count = GetLineCount()
  
  if count==GetInfo(289) then
      DeleteLines(1)
  end
end -- prompt


The processing of scripts in this way is deferred internally in such a way that you are allowed to delete lines.

The arguments aren't used in this particular case so you could just make it:


function prompt ()
  local count = GetLineCount()
  
  if count==GetInfo(289) then
      DeleteLines(1)
  end
end -- prompt



Thanks for the quick reply. I didn't realize a script called in the Script box would run after the send boxes of all triggers matching that line.
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,836 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.