Noah the Goodra avatar

a script for mudlet to setup channel specific chat modes

jfmherokiller

Published: 07 Jul 2020 › Updated: 07 Jul 2020a script for mudlet to setup channel specific chat modes

a script for mudlet to setup channel specific chat modes

This script allows you to change where your command text is sent based on defined channels (it works really well with a tabbed chat window)

local Chats = {
  "New",
  "Pub",
  "OOC",
  "Auction",
  "Update"
}
SelectedMode = "None"
changeCMDInput = false
--capture chat line and prepend channel to beginning
function controlInput(_, command)
    if changeCMDInput and SelectedMode ~= "None" then
        changeCMDInput = false --set this if check to false to it doesn't occur every input
        --Also set the bool check BEFORE any send() functions within a sysDataSendRequest function
        send(SelectedMode .. " " .. command, false) --Duplicate and unknown command
        denyCurrentSend() --Deny the original command, not the commands sent with sendAll.
        changeCMDInput = true
    end
end
--remove the chat redirection
function UnregisterChatHandler()
    killAnonymousEventHandler(myevent)
end
--enable speaking only in selected channel mode
function SetChatMode(ModeToSet)
    if (table.contains(Chats, ModeToSet)) then
        SelectedMode = ModeToSet
    else
        SelectedMode = "None"
    end
    changeCMDInput = true
end
--setup the chat
function SetupChatMode()
    --generate aliases for all enabled chats
    for k, v in pairs(Chats) do
        local realCode = 'SetChatMode("' .. v .. '")'
        local StringToCheck = "^" .. "SetChatModeTo" .. v .. "$"
        tempAlias(StringToCheck, realCode)
    end
    --setup the disable and removal aliases
    tempAlias("^setChatModeToNone$", [[SetChatMode("None")]])
    tempAlias("^RemoveChatMode$", [[UnregisterChatHandler()]])
    --register the chat redirection event
    myevent = myevent or registerAnonymousEventHandler("sysDataSendRequest", "controlInput")
end

Leave a script for mudlet to setup channel specific chat modes to:

Written by

nerdy gooey coder that posts furry content sometimes

Read more #programming posts


Best Posts From Noah the Goodra

We have not curated any of jfmherokiller's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Noah the Goodra