DeleteLines not working for me

Posted by Hoffer1955 on Thu 23 Jul 2015 10:27 PM — 4 posts, 17,245 views.

#0
I'm having trouble getting the DeleteLines() function to work in my plugin I am writing. Here is my trigger:


  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^(.+) (\d+)\% is tanking (.+)"
   omit_from_output="n"
   regexp="y"
   repeat="n"
   send_to="12"
   sequence="100"
  >
  <send>
    delete_output(2)
	ColourNote("cyan","black","%1 is tanking %3 and is at %2\% health")</send>
  </trigger>


Originally I had the trigger omit the line from the output and replace it with my own, but I want to actually remove more than one line from the output once the trigger activates. I assume DeleteLines() is the best way to do this? The delete_output() is just a script function that calls DeleteLines(2).

Here's what happens when the trigger activates:


You fail to hit the Air Queen with your first attack.
The Air Queen is burned on the head with your flames causing slight damage.
The Air Queen is burned on the head with your flames causing slight damage.
The Air Queen is burned on the wing with your flames causing insignificant damage.
You are impacted on the leg by the Air Queen's whirlwind causing modest damage.
You are impacted on the head by the Air Queen's whirlwind causing middling damage.
You dodge out of the way of the Air Queen's third attack.
The Air Queen is in terrible condition[25-35%].
<1995hp 926sp 3309st> 
Hoffer 51% is tanking the Air Queen
Hoffer is tanking the Air Queen and is at 51% health
The Air Queen is in terrible condition[25-35%].
<1995hp 926sp 3309st> 


What I'm trying to accomplish is delete the 1st line after the prompt (Hoffer 51%...) and the two lines below my ColourNote(). I know the ordering of the lines is kind of messed up, but I can't get the DeleteLines() function to actually delete anything from the ouput, no matter what number I throw into the function. What am I doing wrong?
Australia Forum Administrator #1
Template:function=DeleteLines
DeleteLines

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



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).
#2
It says in the documentation:

Quote:

If you want to call DeleteLines from a trigger you must call a function in your script file (or plugin script), not directly from send-to-script.


That's what I tried to do by having the trigger call a function in the script section. Here's the function in the script section:


function delete_output (lines)
  DeleteLines(lines)
end


Thanks for the help.
Australia Forum Administrator #3
I see. You aren't allowed to use send-to-script to delete lines, so you called a function to do it. Nope. That just moves the problem slightly. You aren't allowed to delete lines from send-to-script, no matter how many function calls you make.

You are allowed to do it if you don't use send-to-script, but put a function name in the "script" box for the trigger, and call it that way. Those functions are called at a different time, when the client allows you to delete lines.

A function like:


function MyTrigger (name, line, wildcards, styles)

-- code here

end -- function MyTrigger


Put that in your script file, and put MyTrigger as the script name in the trigger.