Register forum user name Search FAQ

Gammon Forum

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 ➜ help with tweaked chats to new world plugin

help with tweaked chats to new world plugin

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


Posted by Silencher   (55 posts)  Bio
Date Sat 19 Oct 2013 12:52 AM (UTC)
Message
To start: I'm trying to make it so I'll have a trigger active to send this to another window and omit it from my main screen, basically if it's being spammy but I might want to review what was said on the channel later.

I got the base plugin code from here:

http://mushclient.com/forum/bbshowpost.php?id=7991&page=1

The output from the channel is like this:

Your comms say, in a squeaky voice, 'I like bread'

Unfortunately I get this error whenever the trigger launches:

Trigger function "redirect" not found or had a previous error.


I did all the initial steps and made modifications to the trigger and the chat world name, so my current plugin file is as follows:



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, June 30, 2007, 10:48 -->
<!-- MuClient version 4.13 -->

<!-- Plugin "Chat_Redirector" generated by Plugin Wizard -->

<!--
Edit plugin and change "chat_world" variable to be the name of the
world you want chats to go to.
-->

<muclient>
<plugin
name="Chat_Redirector"
author="Nick Gammon"
id="cb84a526b476f69f403517da"
language="Lua"
purpose="Redirects chat messages to another world"
date_written="2007-06-30 10:45:35"
requires="4.08"
version="1.0"
>
<description trim="y">
<![CDATA[
Redirects chats to the specified world.

Add or modify "chat" triggers to capture different sorts of message.

Change the variable "chat_world" to be the name of the world chats are to go to.
]]>
</description>

</plugin>

<!-- Triggers -->

<triggers>

<trigger
enabled="y"
match="Your comms say.+"
omit_from_output="y"
regexp="y"
script="redirect"
sequence="100"
>
</trigger>

<trigger
enabled="n"
match="*"
script="redirect"
name="multi_line_chat"
sequence="10"
>
</trigger>


</triggers>

<!-- Script -->


<script>
<![CDATA[
chat_world = "comms"
local first_time = true

function redirect (name, line, wildcards, styles)

-- try to find "chat" world
local w = GetWorld (chat_world) -- get "chat" world

-- if not found, try to open it
if first_time and not w then
local filename = GetInfo (67) .. chat_world .. ".mcl"
Open (filename)
w = GetWorld (chat_world) -- try again
if not w then
ColourNote ("white", "red", "Can't open chat world file: " .. filename)
first_time = false -- don't repeatedly show failure message
end -- can't find world
end -- can't find world first time around

if w then -- if present
for _, v in ipairs (styles) do
w:ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
v.text)
end -- for each style run
w:Note ("") -- wrap up line

end -- world found

-- if ends with quote, end of multi-line chat
if line:sub (-1) == '"' then
EnableTrigger ("multi_line_chat", false) -- no more lines to go
else
EnableTrigger ("multi_line_chat", true) -- capture subsequent lines
end -- if

end -- function redirect

]]>
</script>
</muclient>



How can I fix this?
Top

Posted by Fiendish   USA  (2,536 posts)  Bio   Global Moderator
Date Reply #1 on Sat 19 Oct 2013 01:37 AM (UTC)
Message
You should put code in code tags in the forum.

Quote:
Unfortunately I get this error whenever the trigger launches:
Trigger function "redirect" not found or had a previous error.


Probably only after the first time. What does it say the first time?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Silencher   (55 posts)  Bio
Date Reply #2 on Sat 19 Oct 2013 01:50 AM (UTC)
Message
Hm. Okay. Now something really bizarre is happening.

I realized I had a regular trigger with the same capture as the trigger in the plugin. I deleted it, now it works and sends it to that world file, but it sends /everything/ Not just the comms message. How would I make it stop after the first comms message (preferably allowing for multilines)?
Top

Posted by Fiendish   USA  (2,536 posts)  Bio   Global Moderator
Date Reply #3 on Sat 19 Oct 2013 05:28 PM (UTC)

Amended on Sat 19 Oct 2013 05:30 PM (UTC) by Fiendish

Message
That particular script expects any chat to end in a quotation mark. See the part that goes:

-- if ends with quote, end of multi-line chat
if line:sub (-1) == '"' then
EnableTrigger ("multi_line_chat", false) -- no more lines to go


That is a pretty fragile expectation. Does your game server wrap chat lines at the server level or do all chats come through as single, very long lines that can then be wrapped by your client? If they come through as long single lines, you can get rid of the multi_line_chat trigger stuff. Otherwise I would check instead for a blank line or some other reliable indication of the end of a message, whatever that happens to be in your game.

https://github.com/fiendish/aardwolfclientpackage
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.


15,889 views.

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

Go to topic:           Search the forum


[Go to top] top

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