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
➜ General
➜ Output Redirection
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Zantiln
(9 posts) Bio
|
Date
| Sat 08 Nov 2008 10:31 PM (UTC) |
Message
| Ok, so I've been mucking around with plugins and scripting in LUA and been getting a little better at it. Not by too much, but a little :)
Anywho, I was looking at the Aardwolf_Chats script to see how Mr. Gammon does his output redirection and I am a little confused.
I see in the trigger match, there is the line:
Quote: match="^{chan ch=(?<channel>\w+)}(?<msg>.*)"
This line is a regex, so the text inside any ()'s should be stored to some variable(s). Which variables are they stored to? And in the function chat_redirect(below), which line of code actually displays the chat message in the separate chat window (or World)??
Quote:
-- chat redirector
function chat_redirect (name, line, wildcards, styles)
local w = get_a_world (chat_world, folder)
if w == nil then
colourNote("red","","Chat world file not available.")
return
end
table.remove (styles, 1) -- get rid of tag
-- send to other world
send_to_world (chat_world, styles)
-- this stuff to echo in this world as well
if echo then
for _, v in ipairs (styles) do
ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
v.text)
end -- for each style run
Note ("") -- wrap up line
end -- echo wanted
end -- function chat_redirect
If I were to make a simple plugin to redirect, for example, only messages on the ftalk channel, to an already created "Dummy" world, seems to me like it would be one trigger with a regex match, and then one funtion that would redirect the whole message, minus the tags, to the other world. Is this correct? Or is it more complicated than that? With all these OnPlugin*** functions and TelnetOption*** commands that are confusing me? :) | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 09 Nov 2008 05:02 AM (UTC) |
Message
| In this case the named wildcards are part of the wildcards table. In other words, wildcards.channel would be the channel name (or, wildcards ["channel"]).
The line that displays in the other world is this:
send_to_world (chat_world, styles)
That is implemented in a Lua module (getworld.lua).
To redirect something like ftalk, you would want something like:
if wildcards.channel == "ftalk" then
send_to_world (chat_world, styles)
end -- if
|
- 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.
9,190 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top