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
➜ Lua
➜ Omit From Output
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Rene
(46 posts) Bio
|
Date
| Sun 24 Dec 2017 12:42 AM (UTC) |
Message
| 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! | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 24 Dec 2017 01:08 AM (UTC) |
Message
| 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. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rene
(46 posts) Bio
|
Date
| Reply #2 on Sun 24 Dec 2017 01:26 AM (UTC) |
Message
| 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sun 24 Dec 2017 01:42 AM (UTC) |
Message
| "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? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rene
(46 posts) Bio
|
Date
| Reply #4 on Sun 24 Dec 2017 01:58 AM (UTC) |
Message
| 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Sun 24 Dec 2017 02:05 AM (UTC) |
Message
| 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. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #6 on Sun 24 Dec 2017 02:06 AM (UTC) |
Message
| Plus, you want to change:
ColourTell ("red", "", line )
To:
ColourNote ("red", "", line )
That way you get the end-of-line. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #7 on Sun 24 Dec 2017 04:06 AM (UTC) Amended on Sun 24 Dec 2017 04:13 AM (UTC) by Fiendish
|
Message
|
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 |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #8 on Sun 24 Dec 2017 04:39 AM (UTC) |
Message
|
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 |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Rene
(46 posts) Bio
|
Date
| Reply #9 on Sun 24 Dec 2017 06:18 AM (UTC) |
Message
| 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. | Top |
|
Posted by
| Rene
(46 posts) Bio
|
Date
| Reply #10 on Sun 24 Dec 2017 11:40 PM (UTC) |
Message
| 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! | 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,206 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top