[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Output Redirection

Output Redirection

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


Posted by Zantiln   (9 posts)  [Biography] 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? :)
[Go to top] top

Posted by Nick Gammon   Australia  (22,991 posts)  [Biography] 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
[Go to top] 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.


8,120 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]