Skip to content

Commit

Permalink
Move to using an event to enable gmcp chat (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
demonnic committed Apr 3, 2021
1 parent d9ea4c3 commit 8dc7e44
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/scripts/LusterniaChatTabs/ChatTabs.lua
@@ -1,13 +1,7 @@
local EMCO = require("LusterniaChatTabs.emco")
LusterniaChatTabs = LusterniaChatTabs or {}
LusterniaChatTabs.emcoContainer = LusterniaChatTabs.emcoContainer or Adjustable.Container:new({
name = "LusterniaChatTabsContainer",
x = "-25%",
y = "-60%",
width = "25%",
height = "60%",
attached = "right",
})
local default_constraints = {name = "LusterniaChatTabsContainer", x = "-25%", y = "-60%", width = "25%", height = "60%", attached = "right"}
LusterniaChatTabs.emcoContainer = LusterniaChatTabs.emcoContainer or Adjustable.Container:new(default_constraints)
LusterniaChatTabs.chatEMCO = LusterniaChatTabs.chatEMCO or EMCO:new({
name = "LusterniaChat",
x = 0,
Expand Down Expand Up @@ -89,16 +83,17 @@ local function chatCapture()
end
chatEMCO:decho(channel, txt)
end

if LusterniaChatTabs.chatCaptureEventID then
killAnonymousEventHandler(LusterniaChatTabs.chatCaptureEventID)
end
LusterniaChatTabs.chatCaptureEventID = registerAnonymousEventHandler("gmcp.Comm.Channel.Text", chatCapture)

local function startGMCPChat()
cecho("<green>LusterniaChatTabs:<reset> Turning on GMCP comm channels\n")
sendGMCP([[Core.Supports.Add ["Comm.Channel 1"] ]])
send("\n")
cecho("<green>LusterniaChatTabs:<reset> GMCP comm channels should now be enabled\n")
end
if not LusterniaChatTabs.loginTrig then
LusterniaChatTabs.loginTrig = tempExactMatchTrigger("Password correct. Welcome to Lusternia.", startGMCPChat, 1)

if not LusterniaChatTabs.loginHandler then
LusterniaChatTabs.loginHandler = registerAnonymousEventHandler("gmcp.Char.Name", startGMCPChat)
end

0 comments on commit 8dc7e44

Please sign in to comment.