You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
805 B
36 lines
805 B
13 years ago
|
Chat = {}
|
||
|
|
||
|
-- private variables
|
||
|
local chatPanel
|
||
13 years ago
|
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 = UILabel.create()
|
||
|
label:setStyle(style)
|
||
|
label:setText(message)
|
||
|
chatBuffer:addChild(label)
|
||
|
end
|
||
13 years ago
|
|
||
|
-- public functions
|
||
|
function Chat.create()
|
||
13 years ago
|
chatPanel = UI.display('chat.otui', { parent = Game.gameBottomPanel } )
|
||
13 years ago
|
chatBuffer = chatPanel:getChildById('chatBuffer')
|
||
13 years ago
|
end
|
||
|
|
||
|
function Chat.destroy()
|
||
|
chatPanel:destroy()
|
||
|
chatPanel = nil
|
||
|
end
|
||
|
|
||
|
-- hooked events
|
||
|
|
||
|
connect(Game, { onLogin = Chat.create,
|
||
13 years ago
|
onLogout = Chat.destroy,
|
||
|
onCreatureSpeak = onCreatureSpeak})
|