É fora, não dentro de funções.
taskWindow = nil
ProtocolGame.registerExtendedOpcode(80, function(protocol, opcode, buffer)
local param = buffer:split('@')
print(param[1])
print(param[2])
taskWindow:getChildById('labelPoke'):setText(param[1])
taskWindow:getChildById('labelQuant'):setText(param[2])
end)
function init()
connect(g_game, { onGameEnd = onGameEnd })
taskWindow = g_ui.displayUI('tasks')
taskWindow:hide()
shopTabBar = taskWindow:getChildById('shopTabBar')
shopTabBar:setContentWidget(taskWindow:getChildById('shopTabContent'))
marketPanel = g_ui.loadUI('market')
shopTabBar:addTab('Market', marketPanel, '/images/game/shop/market')
taskButton = modules.client_topmenu.addRightGameButton('taskButton', tr('Tasks'), '/images/topbuttons/emerald_shop', toggle)
taskButton:setWidth(36)
end
function terminate()
disconnect(g_game, { onGameEnd = onGameEnd })
taskWindow:destroy()
taskButton:destroy()
end
function onGameEnd()
if taskWindow:isVisible() then
taskWindow:hide()
end
end
function show()
taskWindow:show()
taskWindow:raise()
taskWindow:focus()
addEvent(function() g_effects.fadeIn(taskWindow, 250) end)
end
function hide()
addEvent(function() g_effects.fadeOut(taskWindow, 250) end)
scheduleEvent(function() taskWindow:hide() end, 250)
end
function toggle()
if taskWindow:isVisible() then
hide()
else
show()
end
end