Chat Capture Window Mudlet Script

Let's walk through setting up Mudlet to separate channel output for [chat] in its own window so it won't be lost with combat spam.

Create a Window Script

  1. Connect to the MUD with your existing Mudlet profile
  2. Click the “scripts” button in the toolbar
  3. Click the “add item” button to create a new script.
  4. Enter a name, like “Chat Capture Window”
  5. In “Add User Event Handler:” enter:
    sysConnectionEvnet
  6. Click the “+” button.
  7. Copy in the following source code to the text area.
    function make_chat_window()
      chat_window = Geyser.UserWindow:new({
        name = "chat_window",
        titleText = "CHATS",
        docked = true,
        height = "5c",
        dockPosition = "top",
        autoWrap = true,
      })
      chat_window:setFontSize(getFontSize())
      return 1
    end
    
    make_chat_window()
  8. Your scripts setting pages should now look exactly like this:
  9. Click the “Save Item” button

Create a [chat] Capture Trigger

  1. Click the “triggers” button in the toolbar (or the lefthand menu of the scripts page if you still have that open).
  2. Click the “add item” button.
  3. Give your trigger a name like “Chat Capture”.
  4. In the first pattern, enter a channel name as it appears in game:
    [chat]
  5. Leave everything else empty.
  6. Copy in the following code to the textarea:
      if(chat_window)
      then
        selectCurrentLine()
        copy()
        chat_window:appendBuffer()
      end
  7. Your triggers settings page should now look exactly like this:
  8. Click save item.
  9. You may need to reconnect to the MUD to get the window to appear.

Advanced: Adding Timestamps

To add timestamps to your chat capture window, replace

copy()
chat_window:appendBuffer()

in the previous examples with

echo("chat_window", string.format("%s: %s\n", getTime(true), getSelection()))

Check the Mudlet Lua documentation to see more formatting options for getTime().

Capture Additional Channels

To capture additional channels to the same window simply add more capture patterns to the trigger.

Styling the Capture Window

Here's an example of adding additional styling to the chat capture window.

NOTE: Requires Mudlet 4.10+ and Linux - will not work on older Mudlet or MacOS/Windows

  1. Open the “scripts” page again by clicking the button in the toolbar.
  2. Change your “Chat Capture Window” script (or whatever you named it!) to add a chat_window:setStyleSheet fragment:
      chat_window = Geyser.UserWindow:new({
        name = "chat_window",
        titleText = "CHATS",
        docked = true,
        height = "5c",
        dockPosition = "top",
      })
    
      chat_window:setStyleSheet([[
        background-color: black;
        border-width: 2px;
        border-color: #005c28;
        border-style: groove;
        border-radius: 2;
      ]])
    
      chat_window:setFontSize(getFontSize())
      return 1
    end
    
    make_chat_window()