Creating chat window

Share your scripts and packages with other Mudlet users.
Post Reply
keevitaja
Posts: 21
Joined: Mon Aug 31, 2015 12:29 am

Creating chat window

Post by keevitaja »

Hello,

How can i create a window for chat messages?
Code: [show] | [select all] lua
chat = Geyser.MiniConsole:new({
  name="chat",
  x=0, y=0,
  width="1000", height=100
})

function printChat()
    selectCurrentLine()
    copy()
    appendBuffer("chat")

    return true
end

if test then killTrigger(test) end
test = tempRegexTrigger("^{say}(.*)$", [[ printChat() ]])
This creates a miniwindow and appends lines which begin with {say}

The problems i have are following:

1. There is no wordwrap, end just gets cut off
2. Window splits when scrolling. How to enable scrollbar and disable split?
3. How to remove {say} tag from the miniwindow and mainwindow

"{say}You say 'how to remove {say}'}"

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Creating chat window

Post by Belgarath »

Hello Keevitaja,

I'd recommend taking a look at demonnic's tabbed chat package. It's pretty awesome, and can do most of the things you've listed (bar disabling split). You can get rid of the {say} tag with:
Code: [show] | [select all] lua
selectString("{say}", 1)
replace("")

keevitaja
Posts: 21
Joined: Mon Aug 31, 2015 12:29 am

Re: Creating chat window

Post by keevitaja »

Thank you! I think i got it.

As Aardwolf is bit different, i would need to fork most packages and make them usable. And most of the times from scratch might be faster. I i only knew in the beginning how to write things!
Code: [show] | [select all] lua
setBorderTop(100)

commWindow = Geyser.MiniConsole:new({
    name="commWindow",
    x=0, y=0,
    width=900, height=98
})

setWindowWrap("commWindow", 130)
commWindow:setColor(0, 0, 0)

commBorder = Geyser.Label:new({
    name = "commBorder",
    x=0, y=98,
    width = "100%", height = 2,
    color = "gray"
})

function appendToComm()
    if string.sub(matches[2], 1, 1) == "{" then
        selectString(matches[2], 1)
        replace("")
    end

    selectCurrentLine()
    copy()
    appendBuffer("commWindow")

    return true
end

if appendToCommTrigger then killTrigger(appendToCommTrigger) end

appendToCommTrigger = tempRegexTrigger("^({chan ch=[a-z]+}|{say}|{tell}|INFO:)(.*)$", "appendToComm()")
Can i disable split window and use scrollbar?
Can i use closure with tempRegexTrigger? I tried but it didn't work.

Post Reply