Published: 07 Jul 2020 › Updated: 07 Jul 2020

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:
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
- how to use vtnetcore in a commandline app
- how to access the firebase database emulator from the .net implementation of the realtime database
- tips for deserializing json using newtonsoft.json
- a tip for programming when dealing with databases
- A way to extract strings from the body of a method in c#
- a helpful template for cmake if you are trying to upgrade a project which uses autoconf
- A method of fixing the fps issues in deadly premonition 2
- how the money value is stored in deadly premonition 2
- I implmented gmcp and mdsp support in protomuck
- A short list of gripes I have with lua as a language