Omit From Output

Posted by Rene on Sun 24 Dec 2017 12:42 AM — 11 posts, 41,712 views.

#0
I have a trigger omit lines from output to recolour them as I want. However it matches lines I do not want as well, is there a way to replace them with the original colour the MUD gave them? (I.E ColourNote("white", "", line) is not ideal as it will force the line to be white.)

Also, it seems once the trigger omitted it, the line it puts back to the world with ColourNote is not picked up by other triggers, is there a way to change that?

Thanks!
Australia Forum Administrator #1
There is a standard way of showing the line in its original colours, and that is to echo back each style, like this:

In a script file:


function showLine (name, line, wildcards, styles)

  if someCondition then
    -- do whatever
    return
  end -- if
  
  -- show original line
  for _, v in ipairs (styles) do
    ColourTell (RGBColourToName (v.textcolour), RGBColourToName (v.backcolour), v.text)
  end -- for
  
  Note ()  -- finish line off

end -- showLine





In a trigger with "send to script (after omit)":


  if someCondition then
    -- do whatever
    return
  end -- if
  
  -- show original line
  for _, v in ipairs (TriggerStyleRuns) do
    ColourTell (RGBColourToName (v.textcolour), RGBColourToName (v.backcolour), v.text)
  end -- for
  
  Note ()  -- finish line off






Example trigger


<triggers>
  <trigger
   enabled="y"
   match="foo"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>
  if someCondition then
    -- do whatever
    return
  end -- if
  
  -- show original line
  for _, v in ipairs (TriggerStyleRuns) do
    ColourTell (RGBColourToName (v.textcolour), RGBColourToName (v.backcolour), v.text)
  end -- for
  
  Note ()  -- finish line off
</send>
  </trigger>
</triggers>






Quote:

Also, it seems once the trigger omitted it, the line it puts back to the world with ColourNote is not picked up by other triggers, is there a way to change that?


Well not really directly, because a noted line is not checked for triggers. Can't you make the other triggers match on the original, unaltered, line?

I think Fiendish had some sort of fancy plugin that lets you do that and it puts the lines back in such a way that triggers matched it.
#2
Thanks, firstly it (the script version) is not working and for some reason making the colour #004080 which I assume is default, not sure where it is going wrong.
Australia Forum Administrator #3
"Not working" is not very explicit. Please post the exact function you are calling, and explain in what way it isn't working. Is there an error message? If so, what is it?
#4
Sorry, it is a long function, will try.

function colour_arena (name, line, wildcards, styles)
	IsName, IsLoc, IsLevel = CheckName(wildcards.name)

	--This means it matched one of the names tables
	if IsLevel ~= nil then
	   ColourTell ("red", "", line )
           return
	end
	
  --Show Original Line
  for _, v in ipairs (styles) do
    ColourTell (RGBColourToName (v.textcolour), RGBColourToName (v.backcolour), v.text)
  end -- for
  Note("")
end


It is matching to: [(?P<name>(?:\S+ )+)enters the Arena]
CheckName matches to a table of names I want to colour in red, if it matches the line is red, however if it is not a name in the table I get the line in a dark blue.

Thanks.
Australia Forum Administrator #5
Strange. What colour would the line be normally? Try printing the styles.

Before the line "--Show Original Line" add this:


require "tprint"
tprint (styles)


Post the output from that.
Australia Forum Administrator #6
Plus, you want to change:


	   ColourTell ("red", "", line )


To:


	   ColourNote ("red", "", line )


That way you get the end-of-line.
USA Global Moderator #7
Quote:
Also, it seems once the trigger omitted it, the line it puts back to the world with ColourNote is not picked up by other triggers, is there a way to change that?


The only solution to that particular problem is to use Simulate[0] with something that converts styles to ANSI sequences[1]. Simulate("your_message".."\r\n") is basically AnsiNote("your_message") but it also pretends to be from the server, so triggers will work on your new output. Just remember to add that "\r\n" to the end of any Simulated lines, because it doesn't add them for you.

[0] = https://mushclient.com/scripts/doc.php?function=Simulate
[1] - Like my StylesToAnsi function, which could be extracted from https://raw.githubusercontent.com/fiendish/aardwolfclientpackage/MUSHclient/MUSHclient/worlds/plugins/aardwolf_colors.lua
Amended on Sun 24 Dec 2017 04:13 AM by Fiendish
Australia Forum Administrator #8
Quote:

Also, it seems once the trigger omitted it, the line it puts back to the world with ColourNote is not picked up by other triggers, is there a way to change that?


I still think the easiest way of handling this it to make the other triggers fire on the unmodified line.

Another possibility would be to use the OnPluginScreendraw plugin callback to detect note lines. Then you could run them by some regular expressions to take further action. You could conceivably automate taking the existing triggers (a list of which can be obtained) and then applying them to the note line. See, for example:

http://www.gammon.com.au/scripts/doc.php?general=lua_rex
#9
1:
"textcolour"=8404992
"backcolour"=0
"length"=1
"style"=0
"text"="["
2:
"textcolour"=8404992
"backcolour"=0
"length"=28
"style"=0
"text"="Charger enters the Arena"
3:
"textcolour"=8404992
"backcolour"=0
"length"=1
"style"=0
"text"="]"
[Charger enters the Arena]

Original is white for the "[" and "]" and green for the text.
#10
Embarrassingly enough I figured it out, I had accidentally set the trigger to change the colour of the line. Now it is working fine, thanks!