tibia-client/modules/game_chat/chat.lua

35 lines
783 B
Lua
Raw Normal View History

Chat = {}
-- private variables
local chatPanel
2011-11-04 00:34:32 +01:00
local chatBuffer
-- private functions
local function onCreatureSpeak(name, level, msgtype, message)
style = 'ChatLabel'
if name and level > 0 then
message = name .. ' [' .. level .. ']: ' .. message
style = 'YellowChatLabel'
end
local label = createWidget(style)
2011-11-04 00:34:32 +01:00
label:setText(message)
chatBuffer:addChild(label)
end
-- public functions
function Chat.create()
chatPanel = displayUI('chat.otui', { parent = Game.gameBottomPanel } )
2011-11-04 00:34:32 +01:00
chatBuffer = chatPanel:getChildById('chatBuffer')
end
function Chat.destroy()
chatPanel:destroy()
chatPanel = nil
end
-- hooked events
connect(Game, { onLogin = Chat.create,
2011-11-04 00:34:32 +01:00
onLogout = Chat.destroy,
onCreatureSpeak = onCreatureSpeak})