Skip to main content.

Mudlet Triggers and other Goodies

posted by Yasin

Yasin
Posts: 110
Mudlet Triggers and other Goodies 1 of 1
March 16, 2025, 11:23 p.m.

(I'll probably just use this thread for Mudlet things going forward, to keep things organized)

Hullo!

I have here a very quick and dirty v1 of a script that yanks the "TESTING" channel to a tabbed chat window.

Why: Can subscribe to Testing to notice any possible tick issues (e.g. really long ticks!, etc), but its usually quite spammy and it interrupts the flow of normal gameplay. This way, it hangs out on a little floaty window and you can move it around, shrink it, etc.

Example:

How to Install:

This is another Mudlet trigger. However, unlike my previous one this one does have a dependency you have to install using Mudlet.

There are three steps to setting this up.

First, install EMCO by typing the following command from the commandline in Mudlet:

lua installPackage("https://github.com/demonnic/EMCO/releases/latest/download/EMCOChat.mpackage")

Second, you have to go into Mudlet and create a Trigger with two trigger values:

  1. (Testing) configured as a substring (This matches the Testing channel output)
  2. .*(>|-)$ configured as perl regex (This SHOULD match your prompt, no matter what it is)

Third and finally, just copy and paste the following script!

local currentLine = getCurrentLine()
printDebug("currentLine is " .. currentLine)
if string.find(currentLine, "Testing") then
  printDebug("setting startLine to " .. getLineNumber())
  startLineNumber = getLineNumber()
else
  if startLineNumber ~= nill then
    printDebug("setting endLine to " .. getLineNumber())
    endLineNumber = getLineNumber()
  else
    endLineNumber = nil
  end
end

printDebug("startLine is " .. (startLineNumber or "") .. ", endLine is " .. (endLineNumber or ""))

if startLineNumber ~= nil and endLineNumber ~= nil then
  -- Basic setup for EMCO
  -- TODO: Don't run this literally every time?
  -- TODO: Put this somewhere else, so that we can use it for more than testing chat?
  demonnic.chat:enableTimestamp()
  demonnic.chat:setTimestampFormat("h:mm:ss.zzzz")
  demonnic.container:setTitle("Avaria Tabs!")
  local tabList = demonnic.chat.consoles
  if table.contains(tabList, "City") then
    demonnic.chat:removeTab("City")
  end
  if table.contains(tabList, "OOC") then
    demonnic.chat:removeTab("OOC")
  end
  if table.contains(tabList, "Local") then
    demonnic.chat:removeTab("Local")
  end
  if table.contains(tabList, "Tells") then
    demonnic.chat:removeTab("Tells")
  end
  if table.contains(tabList, "Guild") then
    demonnic.chat:removeTab("Guild")
  end
  if table.contains(tabList, "Group") then
    demonnic.chat:removeTab("Group")
  end
  if table.contains(tabList, "Map") then
    demonnic.chat:removeTab("Map")
  end
  if not table.contains(tabList, "Testing") then
    demonnic.chat:addTab("Testing")
  end

  moveCursor(0, startLineNumber)
  -- Grab the current line and append it to the tabbed chat
  selectCurrentLine()
  demonnic.chat:append("Testing")
  deselect()
 
  -- Now just loop and delete!
  -- We loop backwards here to avoid any shenanigans when we delete the lines
  moveCursor(0, endLineNumber)
  for line = endLineNumber, startLineNumber, -1 do
    selectCurrentLine()
    printDebug("Deleting line " .. line)
    deleteLine()
    moveCursor(0, line - 1)
  end
  printDebug("resetting variables")
  startLineNumber = nil
  endLineNumber = nil
end

Remember to activate it! I also recommend restarting Mudlet afterwards for EMCO to do its thing -- it'll show up a generic tabbed chat window, but once the script runs it'll switch over to the window pictured above.

If you want to see what its doing, you can click the "Errors" button in the window to see debug output.

Note: I've only run this for like, a day, so there might be bugs! I have at least tested it with a few small variations of my own prompt as well as when in roundtime (so the prompt end changes to "-" from ">"), but there might be other issues. Aaaaand, since this thing deletes lines from your output, any issues might mean suddenly deleted lines. Feel free to wait a while and ask me how things are going before installing :D

Future Improvements:

  • Combine this with the map so that they're in the same window, just different tabs.
  • Maybe optionally support the GameHelp channel in its own tab? OOCWhispers?
  • I can probably make this a bit faster and more robust, so I'll have a go at that at some point.

 

March 16, 2025, 11:23 p.m.
Quote