• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient Close button by window OTClient

sabodden

Member
Joined
Sep 27, 2019
Messages
138
Reaction score
18
How to when player press X button
Make the window hide calling the function OnOff just as the hotkey...

Code:
function init()
    mainWindow = nil
    mainButton = nil

    g_keyboard.bindKeyDown('Shift+F12', onoff)

    mainWindow = g_ui.displayUI('main.otui')

    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
end

function terminate()
    g_keyboard.unbindKeyDown('Shift+F12')
    mainWindow:hide()
end

function onoff()
    if mainWindow:isVisible() then
        mainWindow:hide()
    else
        mainWindow:breakAnchors()
        mainWindow:show()
    end
end
 
How to when player press X button
Make the window hide calling the function OnOff just as the hotkey...

Code:
function init()
    mainWindow = nil
    mainButton = nil

    g_keyboard.bindKeyDown('Shift+F12', onoff)

    mainWindow = g_ui.displayUI('main.otui')

    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
end

function terminate()
    g_keyboard.unbindKeyDown('Shift+F12')
    mainWindow:hide()
end

function onoff()
    if mainWindow:isVisible() then
        mainWindow:hide()
    else
        mainWindow:breakAnchors()
        mainWindow:show()
    end
end

Lua:
function onoff()
  g_keyboard.bindKeyDown('Ctrl+B', FILENAME.onoff)
    if mainWindow:isVisible() then
        mainWindow:hide()
    else
        mainWindow:breakAnchors()
        mainWindow:show()
    end
end
 
what are u mean with this?

i just want to when players click on the X

it call that function onoff()
"calling the function OnOff just as the hotkey"

OTUI
MiniWindow

@onClose: modules.SCRIPTNAME.onMiniWindowClose()

If you have edited "Main/MiniWindow" if i got remember u make mess with it :D then
Lua:
function onoff()
  if SCRIPTNAMEButton:isOn() then
    SCRIPTNAMEWindow:close()
    SCRIPTNAMEButton:setOn(false)
  else
    SCRIPTNAMEWindow:open()
    SCRIPTNAMEButton:setOn(true)
  end
end

Is pretty hard to do anything with part of code...
 
"calling the function OnOff just as the hotkey"

OTUI
MiniWindow

@onClose: modules.SCRIPTNAME.onMiniWindowClose()

If you have edited "Main/MiniWindow" if i got remember u make mess with it :D then
Lua:
function onoff()
  if SCRIPTNAMEButton:isOn() then
    SCRIPTNAMEWindow:close()
    SCRIPTNAMEButton:setOn(false)
  else
    SCRIPTNAMEWindow:open()
    SCRIPTNAMEButton:setOn(true)
  end
end

Is pretty hard to do anything with part of code...

what should be this SCRIPTNAME
 
Oh sorry, i didn't post the .otui file:
Code:
MiniWindow
  id: botWindow
  !text: tr('ElfBot')
  width: 625
  height: 160
  @onClose: modules.game_minimap.onMiniWindowClose()

  MiniWindowContents  
    Button
      id: Healing
      anchors.top: parent.top
      anchors.left: parent.left
      anchors.right: parent.right
      margin-top: 2
      margin-left: 2
      margin-right: 2
      !text: tr('Healing')
      width: 100
      height: 25
      @onClick: print('test')

this is not a normal button its auto generated by MiniWindow
 
Change @onClose: modules.game_minimap.onMiniWindowClose() to @onClose: onoff().
Possible that you will have to use modules.your_module_name.onoff().
 
@onClose: onoff()
not work

modules.your_module_name.onoff()
how can i know my your_module_name ?
.otmod file, name.
Example
Code:
Module
  name: game_store
  description: In-game store
  author: Oen
  website: None
  sandboxed: true
  autoload: false
  scripts: [ store ]
  @onLoad: init()
  @onUnload: terminate()
So in my case it would be modules.game_store.onoff().
 
.otmod file, name.
Example
Code:
Module
  name: game_store
  description: In-game store
  author: Oen
  website: None
  sandboxed: true
  autoload: false
  scripts: [ store ]
  @onLoad: init()
  @onUnload: terminate()
So in my case it would be modules.game_store.onoff().

ty, its main :D

---



i tried also: @onClose: modules.main.onoff()
Code:
MiniWindow
  id: botWindow
  !text: tr('ElfBot')
  width: 625
  height: 160
  @onClose: modules.main.onoff()

and didn't work :(
 
Post updated otui and lua files.

lua
Code:
function init()
    mainWindow = nil
    mainButton = nil

    g_keyboard.bindKeyDown('Shift+F12', onoff)

    mainWindow = g_ui.displayUI('main.otui')

    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
end

function terminate()
    g_keyboard.unbindKeyDown('Shift+F12')
    mainWindow:hide()
end

function onoff()
    if mainWindow:isVisible() then
        mainWindow:hide()
    else
        mainWindow:breakAnchors()
        mainWindow:show()
    end
end

otui
Code:
MiniWindow
  id: botWindow
  !text: tr('ElfBot')
  width: 625
  height: 160
  @onClose: print('onoff')

  MiniWindowContents  
    Button
      id: Healing
      anchors.top: parent.top
      anchors.left: parent.left
      anchors.right: parent.right
      margin-top: 2
      margin-left: 2
      margin-right: 2
      !text: tr('Healing')
      width: 100
      height: 25
      @onClick: print('test')

the print test on healing is working
but the print onoff not
 
Back
Top