This has been rewritten. New one can be found here: CLICK
So, I was working with someone in #mudlet-help today who wanted chat tabs, top-right corner, and blinking tabs when new things were sent to the miniconsoles. Now, I've not begun using Geyser yet, so this doesn't make use of that. And the majority of the code is something Oneymus from the IRC channel came up with, I've just modified it a bit to make it blinky. Anyhow, the code (which you can just copypaste into a script object) for those interested:
ChatStuff = ChatStuff or {}
ChatStuff.fontSize = ChatStuff.fontSize or 9
ChatStuff.fontWidth, ChatStuff.fontHeight = calcFontSize(ChatStuff.fontSize)
mainWidth, mainHeight = getMainWindowSize()
ChatStuff.width = 400
ChatStuff.height = ChatStuff.fontHeight * 35
ChatStuff.wordwrap = (ChatStuff.width / ChatStuff.fontWidth) - 1
ChatStuff.blinkyTimers = ChatStuff.blinkyTimers or {}
ChatStuff.blinkyColor = ChatStuff.blinkyColor or {}
function ChatStuff.posY()
return 25 --because the tabs are 25 high
end
function ChatStuff.posX()
return mainWidth - ChatStuff.width - 15 --the -15 is to keep it from covering the scroll bar
end
function ChatStuff.append(chat)
appendBuffer(string.format("chat%s", chat))
local tab = string.format("tab%s", chat)
if ChatStuff.blinkyTimers[chat] or ChatStuff.currentTab == chat or chat == "All" then
return true
else
ChatStuff.blinkyTimers[chat] = tempTimer(0.5, string.format([[ChatStuff.blink("%s")]], chat))
setBackgroundColor(tab, 100, 100, 100, 125)
ChatStuff.blinkyColor[chat] = 1
end
return true
end
function ChatStuff.blink(chat)
local tab = string.format("tab%s", chat)
if ChatStuff.blinkyColor[chat] == 1 then
setBackgroundColor(tab, 0, 0, 0, 0)
ChatStuff.blinkyColor[chat] = 0
else
setBackgroundColor(tab, 100, 100, 100, 125)
ChatStuff.blinkyColor[chat] = 1
end
ChatStuff.blinkyTimers[chat] = tempTimer(0.5, string.format([[ChatStuff.blink("%s")]], chat))
end
chatTable = {
"All",
"City",
"Guild",
"Tells",
"Battle",
"Market",
"Misc",
}
ChatStuff.tabWidth, ChatStuff.tabHeight = math.floor( ChatStuff.width / #chatTable ), 25
ChatStuff.tabPosX, ChatStuff.tabPosY = ChatStuff.posX(), ChatStuff.posY() - 25
-- Functions
function ChatStuffCreate()
local startX = ChatStuff.tabPosX
for _,v in ipairs( chatTable ) do
local tab = "tab" .. v
createLabel( tab, startX, ChatStuff.tabPosY, ChatStuff.tabWidth, ChatStuff.tabHeight, 0 )
resizeWindow( tab, ChatStuff.tabWidth, ChatStuff.tabHeight )
setLabelClickCallback( tab, "switchchat", v )
echo( tab, [[<center><font color="white">]] .. v .. [[</font></center></b></p>]] )
moveWindow( tab, startX, ChatStuff.tabPosY )
startX = startX + ChatStuff.tabWidth
local chat = "chat" .. v
createMiniConsole( chat, ChatStuff.posX(), ChatStuff.posY(), ChatStuff.width, ChatStuff.height )
resizeWindow( chat, ChatStuff.width, ChatStuff.height )
setWindowWrap( chat, ChatStuff.wordwrap )
setMiniConsoleFontSize( chat, ChatStuff.fontSize )
setBackgroundColor( chat, 0, 0, 0, 0 )
moveWindow( chat, ChatStuff.posX(), ChatStuff.posY() )
hideWindow( chat )
end
ChatStuff.currentTab = "none"
switchchat( "All" )
end
function switchchat ( chat )
local o_c = "chat" .. ChatStuff.currentTab
local o_t = "tab" .. ChatStuff.currentTab
local n_c = "chat" .. chat
local n_t = "tab" .. chat
if ChatStuff.currentTab ~= chat then
if ChatStuff.blinkyTimers[chat] then
killTimer(ChatStuff.blinkyTimers[chat])
ChatStuff.blinkyTimers[chat] = nil
ChatStuff.blinkyColor[chat] = nil
end
hideWindow( o_c )
showWindow( n_c )
ChatStuff.currentTab = chat
setBackgroundColor( o_t, 0, 0, 0, 0 )
setBackgroundColor( n_t, 100, 100, 100, 125 )
end
end
function ChatStuffResize()
ChatStuff.fontWidth, ChatStuff.fontHeight = calcFontSize(ChatStuff.fontSize)
mainWidth, mainHeight = getMainWindowSize()
ChatStuff.height = ChatStuff.fontHeight * 35
ChatStuff.wordwrap = (ChatStuff.width / ChatStuff.fontWidth) - 1
ChatStuff.tabWidth, ChatStuff.tabHeight = math.floor( ChatStuff.width / #chatTable), 25
ChatStuff.tabPosX, ChatStuff.tabPosY = ChatStuff.posX(), ChatStuff.posY() - 25
ChatStuffCreate()
end
if not ChatStuff.initialized then
ChatStuffCreate()
ChatStuff.initialized = true
end
To use it, you create a trigger for the chat line, and in the script put the following:
selectString(line,1)
copy()
ChatStuff.append("All")
ChatStuff.append("Guild")
deselect()
Where "Guild" can be any one of the tabs you have setup. Now, you can setup differing numbers of tabs, and change their names, by editing the chatTable declaration starting on line 44. Remove the ones you don't want, add the ones you do. If you do it after it's created them, you may need to restart Mudlet to keep it from looking funky.
If you want to change where it's positioned, edit the return value of the functions ChatStuff.posX() and ChatStuff.posY() . If you want to change the height, it's specified on line 6 and currently is set for 35 lines tall. Line 5 has the width, currently hardcoded to 400.
If you want to delete the line from the main window, throw a deleteLine() at the end of the trigger's script.
That should cover all of it. Enjoy
edited: I missed 1 line in the trigger code which was kind of important.