I have this script:
I swear I wanted to understand why when logging out my script doesn’t close, it doesn’t make any sense, based on other modules I don’t understand why it doesn’t close when logging out ...
if any charitable soul can help me, I’m trying for days
in a test I put:
and in code in .lua:
and everything goes well, it works when I press enter it closes the window.
and why when I try to:
and
doesn’t work ?, this above makes when I enter or leave to perform such function, and because it doesn’t go man it doesn’t make sense wtf
Lua:
WindowButton = nil
MainWindow = nil
function init()
connect(g_game, { onGameEnd = offline })
connect(LocalPlayer, { onHealthChange = onHealthChange,
onManaChange = onManaChange})
ProtocolGame.registerExtendedOpcode(90, SendATT)
WindowButton = modules.client_topmenu.addLeftGameButton('WindowButton', tr('Points Panel'), '/game_points/images/icon', closing)
WindowButton:setIconOffsetY(3)
WindowButton:setOn(false)
MainWindow = g_ui.displayUI('game_points')
MainWindow:hide()
allTabs = MainWindow:recursiveGetChildById('allTabs')
allTabs:setContentWidget(MainWindow:getChildById('optionsTabContent'))
HealthInfoText = MainWindow:recursiveGetChildById('HealthGet')
InfoPointsText = MainWindow:recursiveGetChildById('InfoPoints')
if g_game.isOnline() then
local localPlayer = g_game.getLocalPlayer()
onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
onManaChange(localPlayer, localPlayer:getMana(), localPlayer:getMaxMana())
end
refresh()
end
function terminate()
disconnect(g_game, { onGameEnd = offline })
disconnect(LocalPlayer, { onHealthChange = onHealthChange,
onManaChange = onManaChange})
ProtocolGame.unregisterExtendedOpcode(90)
WindowButton:destroy()
MainWindow:destroy()
end
function onHealthChange(localPlayer, health, maxHealth)
local player = g_game.getLocalPlayer()
HealthInfoText:setText ("[" .. player:getMaxHealth() .. "]")
end
function onManaChange(localPlayer, mana, maxMana)
end
function offline()
onMainWindowClose()
MainWindow:hide()
MainWindow:setVisible(false)
MainWindow:destroy()
end
function refresh()
local player = g_game.getLocalPlayer()
if not player then return end
end
function closing()
local protocolGame = g_game.getProtocolGame()
if WindowButton:isOn() then
MainWindow:setVisible(false)
WindowButton:setOn(false)
else
MainWindow:setVisible(true)
WindowButton:setOn(true)
if protocolGame then
protocolGame:sendExtendedOpcode(14, 2)
end
end
end
function SendATT(protocol, opcode, buffer, localPlayer)
local player = g_game.getLocalPlayer()
Numb = tonumber(buffer)
HealthInfoText:setText ("[" .. player:getMaxHealth() .. "]")
InfoPointsText:setText ("Your Points: [" .. Numb .. "]")
end
function HealthPoints()
local protocolGame = g_game.getProtocolGame()
if WindowButton:isOn() then
if protocolGame then
protocolGame:sendExtendedOpcode(14, 1)
end
else
MainWindow:setVisible(true)
WindowButton:setOn(true)
end
end
function onMainWindowClose()
WindowButton:setOn(false)
MainWindow:hide()
MainWindow:setVisible(false)
MainWindow:destroy()
end
I swear I wanted to understand why when logging out my script doesn’t close, it doesn’t make any sense, based on other modules I don’t understand why it doesn’t close when logging out ...
if any charitable soul can help me, I’m trying for days
Post automatically merged:
in a test I put:
Lua:
@onEnter: modules.game_points.onMiniWindowClose()
and in code in .lua:
Code:
function onMiniWindowClose()
MainWindow:setVisible(false)
WindowButton:setOn(false)
end
and everything goes well, it works when I press enter it closes the window.
and why when I try to:
Code:
connect(g_game, {onGameEnd = onMiniWindowClose})
Code:
disconnect(g_game, { onGameEnd = onMiniWindowClose})
doesn’t work ?, this above makes when I enter or leave to perform such function, and because it doesn’t go man it doesn’t make sense wtf
Last edited: