I'm trying to redirect chat to a new window. Following the tutorial, not working

Posted by Horologe on Thu 17 Dec 2015 07:52 PM — 16 posts, 69,722 views.

#0
I followed all of the steps for this tutorial. http://www.gammon.com.au/forum/bbshowpost.php?id=7991&page=1

I named my new world newchat, i changed the line to newchat. I save the plugin and started it with the world i just made still open and it doesn't work. If i close the window, the plugin does not open one as the forum post implies. Help?
Australia Forum Administrator #1
That is an 8-page thread with multiple examples. Please post the exact code you used, inside code tags.

Template:codetag
To make your code more readable please use [code] tags as described here.
Amended on Fri 18 Dec 2015 12:15 AM by Nick Gammon
#2
The server i made is called newchat. I'm using windows10. I think it has to do something with the VirtualStore in windows or how windows saves the worlds.


<?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="^[A-Za-z]+ (says|chats|yells) \'(.*?)\'$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^You (say|chat|yell) \'(.*?)\'$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

</triggers>

<!--  Script  -->


<script>
<![CDATA[
chat_world = "newchat"
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

end -- function redirect 

]]>
</script>


</muclient>
Amended on Sun 20 Dec 2015 01:46 AM by Nick Gammon
Australia Forum Administrator #3
Can you open the "newchat" world and then do this, please?

Template:summary

Please provide a summary of your world configuration:

  • Either use the scripting Immediate window (Ctrl+I) to execute: Debug ("summary")

    or

  • Install the Summary plugin (see "Summary" feature) and type "summary"

Then copy the resulting information from the output window, and paste into a Forum message.

You need version 4.55 onwards of MUSHclient to do this.

#4
debug summary on newclient

Quote:

-------------- MUSHclient summary --------------

MUSHclient version: 4.94
Compiled: Jul 28 2014.
Time now: Friday, December 18, 2015, 5:37 PM
Client running for: 0d 00h 01m 09s
World opened for: 0d 00h 00m 44s
Operating system: Unknown (Platform 2, Major 6, Minor 2)
Libraries: Lua 5.1.4, PCRE 8.35, PNG 1.5.14, SQLite3 3.8.4.3, Zlib 1.2.8
World name: 'chat', ID: 44d3d012bb95f2ca590c8a98
-- Scripting --
Script language: Lua, enabled: yes
Scripting active: yes
Lua sandbox is 127 characters, DLL loading allowed: yes
Scripting prefix: ''. External editor in use: NO.
Scripting for: 0.000040 seconds.
-- Triggers, aliases, timers, variables --
** Triggers: 0 in world file, triggers enabled: yes.
0 enabled, 0 regexp, 0 attempts, 0 matched, 0.000000 seconds.
** Aliases: 0 in world file, aliases enabled: yes.
0 enabled, 0 regexp, 0 attempts, 0 matched, 0.000000 seconds.
** Timers: 0 in world file, timers enabled: yes.
0 enabled, 0 fired.
Timers checked every 0.1 seconds.
** Variables: 0.
-- MCCP --
MCCP not active.
-- Plugins (Processing order) --
** Plugins: 0 loaded, 0 enabled.
-- Comms --
Connect phase: 0 (Closed). NAWS wanted: NO
Received: 0 bytes (0 Kb)
Sent: 0 bytes (0 Kb)
Received 0 packets, sent 0 packets.
Total lines received: 46
This connection: Sent 0 lines, received 46 lines.
Telnet (IAC) received: DO: 0, DONT: 0, WILL: 0, WONT: 0, SB: 0
-- MXP --
MXP active: NO, Pueblo mode: NO, Activated: On command
MXP tags received: 0
MXP entities received: 0
MXP errors: 0
-- Commands --
Commands in command history: 0
Speed walking enabled: NO. Speed walking prefix: #
Command stacking enabled: NO. Command stack character: ';'
Accelerators defined: 0
-- Miniwindows --
** Miniwindows: 0 loaded, 0 shown.
-- Output window --
Output pixels: width 691, height: 789, font width: 8, font height: 15
can show 86 characters, wrapping at column 80, height 52 lines.
Output buffer: 64 of 5000 lines.
-- Miscellaneous --
Logging: NO, tracing: NO
** SQLite3 databases: 0
Sound buffers in use: 0

debug summary on active world
Quote:


-------------- MUSHclient summary --------------

MUSHclient version: 4.94
Compiled: Jul 28 2014.
Time now: Friday, December 18, 2015, 5:38 PM
Client running for: 0d 00h 02m 42s
World opened for: 0d 00h 02m 36s
World connected for: 0d 00h 02m 36s
Operating system: Unknown (Platform 2, Major 6, Minor 2)
Libraries: Lua 5.1.4, PCRE 8.35, PNG 1.5.14, SQLite3 3.8.4.3, Zlib 1.2.8
World name: 'Exile-Horologe', ID: dca6213a59b1da57a878d028
-- Scripting --
Script language: Lua, enabled: yes
Scripting active: yes
Lua sandbox is 127 characters, DLL loading allowed: yes
Scripting prefix: ''. External editor in use: NO.
Scripting for: 0.000285 seconds.
-- Triggers, aliases, timers, variables --
** Triggers: 9 in world file, triggers enabled: NO. [Triggers]
6 enabled, 0 regexp, 0 attempts, 0 matched, 0.000000 seconds.
** Aliases: 5 in world file, aliases enabled: yes. [Aliases]
5 enabled, 0 regexp, 20 attempts, 0 matched, 0.000112 seconds.
** Timers: 0 in world file, timers enabled: yes.
0 enabled, 0 fired.
Timers checked every 0.1 seconds.
** Variables: 16. [Variables]
-- MCCP --
MCCP not active.
-- Plugins (Processing order) --
ID: cb84a526b476f69f403517da, 'Chat_Redirector', (Lua, 0.000 s) Enabled [Tr]
** Plugins: 1 loaded, 1 enabled.
-- Comms --
Connect phase: 8 (Open). NAWS wanted: NO
Received: 11942 bytes (11 Kb)
Sent: 1352 bytes (1 Kb)
Received 40 packets, sent 24 packets.
Total lines received: 173
This connection: Sent 7 lines, received 153 lines.
Telnet (IAC) received: DO: 5, DONT: 0, WILL: 4, WONT: 1, SB: 6 [Telnet]
-- MXP --
MXP active: yes, Pueblo mode: NO, Activated: Yes - always
MXP tags received: 79
MXP entities received: 0
MXP errors: 0
-- Commands --
Commands in command history: 3
Speed walking enabled: NO. Speed walking prefix: #
Command stacking enabled: NO. Command stack character: ';'
Accelerators defined: 0
-- Miniwindows --
** Miniwindows: 0 loaded, 0 shown.
-- Output window --
Output pixels: width 656, height: 781, font width: 8, font height: 15
can show 82 characters, wrapping at column 80, height 52 lines.
Output buffer: 191 of 5000 lines.
-- Miscellaneous --
Logging: yes, tracing: NO
** SQLite3 databases: 0
Sound buffers in use: 0

---------------------- End summary ----------------------
Australia Forum Administrator #5
OK, please post some example chat lines (copy and paste) that you expect to be redirected.
#6
HTML version

<!-- Produced by MUSHclient v 4.94 - www.mushclient.com -->
<table border=0 cellpadding=5 bgcolor="#000000">
<tr><td>
<pre><code><font size=2 face="FixedSys, Lucida Console, Courier New, Courier"><font color="#0">
</font><font color="#FFFFFF">&lt;</font><font color="#FF0000">1238</font><font color="#800000">/</font><font color="#FF0000">1238</font><font color="#800000">hp </font><font color="#00FF00">1737</font><font color="#008000">/</font><font color="#00FF00">1767</font><font color="#008000">m </font><font color="#00FFFF">731</font><font color="#008080">/</font><font color="#00FFFF">731</font><font color="#008080">mv </font><font color="#FF00FF">93</font><font color="#800080">e</font><font color="#FFFFFF">&gt;[</font><font color="#FFFF00">None</font><font color="#808000">xp</font><font color="#FFFFFF">] 
</font><font color="#FF0000">Mithrandir tells you, 'go for it'
</font><font color="#FFFFFF">&lt;</font><font color="#FF0000">1238</font><font color="#800000">/</font><font color="#FF0000">1238</font><font color="#800000">hp </font><font color="#00FF00">1737</font><font color="#008000">/</font><font color="#00FF00">1767</font><font color="#008000">m </font><font color="#00FFFF">731</font><font color="#008080">/</font><font color="#00FFFF">731</font><font color="#008080">mv </font><font color="#FF00FF">93</font><font color="#800080">e</font><font color="#FFFFFF">&gt;[</font><font color="#FFFF00">None</font><font color="#808000">xp</font><font color="#FFFFFF">] 
</font><font color="#C0C0C0">say can you just use say
</font><font color="#00FFFF">You say, 'can you just use say'
</font><font color="#FFFFFF">&lt;</font><font color="#FF0000">1238</font><font color="#800000">/</font><font color="#FF0000">1238</font><font color="#800000">hp </font><font color="#00FF00">1767</font><font color="#008000">/</font><font color="#00FF00">1767</font><font color="#008000">m </font><font color="#00FFFF">731</font><font color="#008080">/</font><font color="#00FFFF">731</font><font color="#008080">mv </font><font color="#FF00FF">93</font><font color="#800080">e</font><font color="#FFFFFF">&gt;[</font><font color="#FFFF00">None</font><font color="#808000">xp</font><font color="#FFFFFF">] 
</font><font color="#C0C0C0">say and talk to me
</font><font color="#00FFFF">You say, 'and talk to me'
</font><font color="#FFFFFF">&lt;</font><font color="#FF0000">1238</font><font color="#800000">/</font><font color="#FF0000">1238</font><font color="#800000">hp </font><font color="#00FF00">1767</font><font color="#008000">/</font><font color="#00FF00">1767</font><font color="#008000">m </font><font color="#00FFFF">731</font><font color="#008080">/</font><font color="#00FFFF">731</font><font color="#008080">mv </font><font color="#FF00FF">93</font><font color="#800080">e</font><font color="#FFFFFF">&gt;[</font><font color="#FFFF00">None</font><font color="#808000">xp</font><font color="#FFFFFF">] 
</font><font color="#C0C0C0">say literally anything
</font><font color="#00FFFF">You say, 'literally anything'
</font><font color="#FFFFFF">&lt;</font><font color="#FF0000">1238</font><font color="#800000">/</font><font color="#FF0000">1238</font><font color="#800000">hp </font><font color="#00FF00">1767</font><font color="#008000">/</font><font color="#00FF00">1767</font><font color="#008000">m </font><font color="#00FFFF">731</font><font color="#008080">/</font><font color="#00FFFF">731</font><font color="#008080">mv </font><font color="#FF00FF">93</font><font color="#800080">e</font><font color="#FFFFFF">&gt;[</font><font color="#FFFF00">None</font><font color="#808000">xp</font><font color="#FFFFFF">] 
</font><font color="#00FFFF">Mithrandir says, 'k'
</font><font color="#FFFFFF">&lt;</font><font color="#FF0000">1238</font><font color="#800000">/</font><font color="#FF0000">1238</font><font color="#800000">hp </font><font color="#00FF00">1767</font><font color="#008000">/</font><font color="#00FF00">1767</font><font color="#008000">m </font><font color="#00FFFF">731</font><font color="#008080">/</font><font color="#00FFFF">731</font><font color="#008080">mv </font><font color="#FF00FF">93</font><font color="#800080">e</font><font color="#FFFFFF">&gt;[</font><font color="#FFFF00">None</font><font color="#808000">xp</font><font color="#FFFFFF">] 
</font><font color="#C0C0C0">say thanks!
</font><font color="#00FFFF">You exclaim, 'thanks!'
</font><font color="#FFFFFF">&lt;</font><font color="#FF0000">1238</font><font color="#800000">/</font><font color="#FF0000">1238</font><font color="#800000">hp </font><font color="#00FF00">1767</font><font color="#008000">/</font><font color="#00FF00">1767</font><font color="#008000">m </font><font color="#00FFFF">731</font><font color="#008080">/</font><font color="#00FFFF">731</font><font color="#008080">mv </font><font color="#FF00FF">92</font><font color="#800080">e</font><font color="#FFFFFF">&gt;[</font><font color="#FFFF00">None</font><font color="#808000">xp</font><font color="#FFFFFF">] 
</font><font color="#C0C0C0">Asclepius stares at you and utters the words, 'abrazak'.
A faint outline of magical armor surrounds you
</font></font></code></pre>
</td></tr></table>


normal text

<1238/1238hp 1737/1767m 731/731mv 93e>[Nonexp] 
Mithrandir tells you, 'go for it'
<1238/1238hp 1737/1767m 731/731mv 93e>[Nonexp] 
say can you just use say
You say, 'can you just use say'
<1238/1238hp 1767/1767m 731/731mv 93e>[Nonexp] 
say and talk to me
You say, 'and talk to me'
<1238/1238hp 1767/1767m 731/731mv 93e>[Nonexp] 
say literally anything
You say, 'literally anything'
<1238/1238hp 1767/1767m 731/731mv 93e>[Nonexp] 
Mithrandir says, 'k'
<1238/1238hp 1767/1767m 731/731mv 93e>[Nonexp] 
say thanks!
You exclaim, 'thanks!'
<1238/1238hp 1767/1767m 731/731mv 92e>[Nonexp] 
Asclepius stares at you and utters the words, 'abrazak'.
A faint outline of magical armor surrounds you
Australia Forum Administrator #7
This is what you are trying to match on:


Mithrandir tells you, 'go for it'
You say, 'can you just use say'
You say, 'and talk to me'
You say, 'literally anything'
Mithrandir says, 'k'
You exclaim, 'thanks!'


But your triggers are:


   match="^[A-Za-z]+ (says|chats|yells) \'(.*?)\'$"
...
   match="^You (say|chat|yell) \'(.*?)\'$"


It isn't going to match. There is nothing matching "tells you" or "says,". Triggers have to match exactly.

If you change the triggers part of the plugin to the following, it works better:


<!--  Triggers  -->

<triggers>

  <trigger
   enabled="y"
   match="^[A-Za-z]+ (says|chats|yells), \'(.*?)\'$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^[A-Za-z]+ tells you, \'(.*?)\'$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^You (say|chat|yell), \'(.*?)\'$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

</triggers>


I added the comma after says/chats/yells and also added a trigger for "tells you". You can tweak the triggers or add to them if other things are not matching.
#8
thanks, I'll update my plugin accordingly. I don't get error messages about the world not opening but it doesn't automatically open.
Australia Forum Administrator #9
The plugin opens the world if the trigger matches. If the trigger doesn't match the world won't open.
#10
getting this error

SQL error on statement:
"COMMIT"
disk I/O error


here is my plugin now

<?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="^[A-Za-z]+ (says|sings|auctions|dreams|prays|shouts), \'(.*?)\'$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^[A-Za-z]+ tells you, \'(.*?)\'$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^(.*?)(tells|tell) the form(.*?)$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^(.*?) (gossip|gossips)(.*?)$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>


  <trigger
   enabled="y"
   match="^You (say|shout), \'(.*?)\'$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

<trigger
   enabled="y"
   match="^You tell (.*?)$"
   regexp="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

</triggers>

<!--  Script  -->


<script>
<![CDATA[
chat_world = "chat"
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

end -- function redirect 

]]>
</script>


</muclient>


Any idea why?
Australia Forum Administrator #11
There is no "commit" in that plugin.
#12
I'm confused. I thought that was a sql db thing? That plugin is the only one I have installed. I haven't received this error before using this plugin.
USA #13
What's you MC install directory? Sounds like you might be trying to write to a protected memory space (most notably Program Files since Win 7 released).
#14
It is in the program files directory. How do I fix this problem?
USA Global Moderator #15
Horologe said:

It is in the program files directory. How do I fix this problem?

Windows UAC prevents writing to files in Program Files, even if they are inside the MUSHclient folder. Try moving the MUSHclient folder somewhere else like My Documents.