• 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 OTclient UI helps

sabodden

Member
Joined
Sep 27, 2019
Messages
138
Reaction score
18
I have this UI for OTClient mod:

Code:
MiniWindow
  id: botWindow
  !text: tr('ElfBot OTC 0.1 -- 0 ms - 0 exp/hour')
  width: 625
  height: 160
  icon: /data/imgs/elfbot_icon.png
  @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')
     
    Button
      id: Aimbot
      anchors.top: prev.top
      anchors.left: prev.right
      anchors.right: parent.right
      margin-left: 2
      margin-right: 2
      !text: tr('Aimbot')
      width: 100
      height: 25
      @onClick: print('test')






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

I have a few question i would like to fix:
1) How to render the UI box in the middle of the screen?
2) Why width Button props is not working? and Healing button is taking all of the screen not showing up the Aimbot button?
3) How to remove the minimize button? Let only the close one
4) Why icon ( icon: /data/imgs/elfbot_icon.png) is not working if the image is there?

Please if u can aswer even one of this questions it would help me a lot!
 
Solution
Same thing, no errors, no open
Have you tried to use button to open a window?

Could i use LUA methods to detect window screen so set it in the middle?
Yes.
1. Don't remember, but you could add anchors when loading module. anchors.horizontalCenter/verticalCenter.
2. Wrong anchors, anchors.left: prev.right- should be anchors.left: parent.left
3. Inside lua you need to add callback to hide it, botWindow:recursiveGetChildById('minimizeButton'):hide()
4. Remove .png it is not needed. Probably you have error in Terminal because of that.
 
1. Don't remember, but you could add anchors when loading module. anchors.horizontalCenter/verticalCenter.
2. Wrong anchors, anchors.left: prev.right- should be anchors.left: parent.left
3. Inside lua you need to add callback to hide it, botWindow:recursiveGetChildById('minimizeButton'):hide()
4. Remove .png it is not needed. Probably you have error in Terminal because of that.

1- works TY
2- i changed, but the button still taking all the box width, its not setting width: 100 as i'm trying...
why?
4-
Code:
icon: /data/imgs/elfbot_icon

Code:
ERROR: Unable to load texture '/data/imgs/elfbot_icon': unable to open file '/data/imgs/elfbot_icon.png': No such file or directory
Loaded module 'Elfbot'

but if i do:
Code:
cd mods/elfbot/data/imgs/ && ls

shows:
Code:
elfbot_icon_full.png elfbot_icon.png

3- tried but got errors and mod dont load anymore
i've tried:
Code:
mainWindow = nil
mainButton = nil

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

function init()
    botWindow:recursiveGetChildById('minimizeButton'):hide()
    
    mainWindow = g_ui.displayUI('main.otui')
    mainWindow:hide()

    mainButton = modules.client_topmenu.addRightToggleButton('elfbot_button', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff, true)
end

function terminate()
    mainWindow:hide()
end

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

Code:
/elfbot/elfbot.lua:7: attempt to index global 'botWindow' (a nil value)
stack traceback:
    [C]: ?
    /elfbot/elfbot.lua:7: in function 'init'
    /elfbot/elfbot.otmod:13:[@onLoad]:1: in main chunk
    [C]: in function 'autoLoadModules'
    /init.lua:49: in main chunk
ERROR: failed to create widget from style 'NodeImage': 'NodeImage' is not a defined style
 
2. Remove one of the left/right anchor.
3. Change botWindow to mainWindow - also change inside otui id: botWindow to id: mainWindow.
4. Are you sure that path is correct? Or remove / from the beggining, so it will look inside bot module folder for that image.
 
2. Remove one of the left/right anchor.
3. Change botWindow to mainWindow - also change inside otui id: botWindow to id: mainWindow.
4. Are you sure that path is correct? Or remove / from the beggining, so it will look inside bot module folder for that image.

2- TY
4- TY

3-
like this?
Code:
mainWindow = nil
mainButton = nil

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

function init()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()

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

    mainButton = modules.client_topmenu.addRightToggleButton('elfbot_button', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff, true)
end

function terminate()
    mainWindow:hide()
end

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

by using this mod not work...
Code:
/elfbot/elfbot.lua:7: attempt to index global 'mainWindow' (a nil value)
stack traceback:
    [C]: ?
    /elfbot/elfbot.lua:7: in function 'init'
    /elfbot/elfbot.otmod:13:[@onLoad]:1: in main chunk
    [C]: in function 'autoLoadModules'
    /init.lua:49: in main chunk
ERROR: failed to create widget from style 'NodeImage': 'NodeImage' is not a defined style



1- i tried to:
Code:
  anchors.horizontalCenter: parent.horizontalCenter
  anchors.verticalCenter: parent.verticalCenter

Code:
MiniWindow
  id: mainWindow
  !text: tr('ElfBot OTC 0.1 -- 0 ms - 0 exp/hour')
  width: 625
  height: 160
  icon: data/imgs/elfbot_icon
  anchors.horizontalCenter: parent.horizontalCenter
  anchors.verticalCenter: parent.verticalCenter
  @onClose: modules.game_minimap.onMiniWindowClose()

with this params it start right on the middle, perfectlly, but i cant move the window, why?


---


how did u get all this methods?
thank you again!
 
2- TY
4- TY

3-
like this?
Code:
mainWindow = nil
mainButton = nil

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

function init()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()

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

    mainButton = modules.client_topmenu.addRightToggleButton('elfbot_button', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff, true)
end

function terminate()
    mainWindow:hide()
end

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

by using this mod not work...
Code:
/elfbot/elfbot.lua:7: attempt to index global 'mainWindow' (a nil value)
stack traceback:
    [C]: ?
    /elfbot/elfbot.lua:7: in function 'init'
    /elfbot/elfbot.otmod:13:[@onLoad]:1: in main chunk
    [C]: in function 'autoLoadModules'
    /init.lua:49: in main chunk
ERROR: failed to create widget from style 'NodeImage': 'NodeImage' is not a defined style



1- i tried to:
Code:
  anchors.horizontalCenter: parent.horizontalCenter
  anchors.verticalCenter: parent.verticalCenter

Code:
MiniWindow
  id: mainWindow
  !text: tr('ElfBot OTC 0.1 -- 0 ms - 0 exp/hour')
  width: 625
  height: 160
  icon: data/imgs/elfbot_icon
  anchors.horizontalCenter: parent.horizontalCenter
  anchors.verticalCenter: parent.verticalCenter
  @onClose: modules.game_minimap.onMiniWindowClose()

with this params it start right on the middle, perfectlly, but i cant move the window, why?


---


how did u get all this methods?
thank you again!
Code:
MiniWindow
  id: mainWindow
  !text: tr('ElfBot OTC 0.1 -- 0 ms - 0 exp/hour')
  width: 625
  height: 160
  icon: data/imgs/elfbot_icon
  @onClose: modules.game_minimap.onMiniWindowClose()

Now will spot on center, otui fk dont like, extra spaces, tabs and will make thing not working
 
It should be like that.
Code:
mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)

And move mainWindow:recursiveGetChildById('minimizeButton'):hide() under mainWindow:hide().

Also you don't need to add extensions of files - *.otui, *.png.
 
Code:
MiniWindow
  id: mainWindow
  !text: tr('ElfBot OTC 0.1 -- 0 ms - 0 exp/hour')
  width: 625
  height: 160
  icon: data/imgs/elfbot_icon
  @onClose: modules.game_minimap.onMiniWindowClose()

Now will spot on center, otui fk dont like, extra spaces, tabs and will make thing not working

1)
i just wanted to this starts in the center horizontal and vertical, but i would like to move the window, like it can be done on elfbot
I wouldnt like this fixed on the center :(


It should be like that.
Code:
mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)

And move mainWindow:recursiveGetChildById('minimizeButton'):hide() under mainWindow:hide().

Also you don't need to add extensions of files - *.otui, *.png.

3)
like this:
Code:
mainWindow = nil
mainButton = nil

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


function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
   
    mainWindow = g_ui.displayUI('main.otui')
    mainWindow:hide()
end

function terminate()
    mainWindow:hide()
end

function onoff()
    if mainWindow:isVisible() then
        mainWindow:hide()
        mainWindow:recursiveGetChildById('minimizeButton'):hide()
    else
        mainWindow:show()
    end
end

???

Cause its open with no errors on console but the minimize button still there

---

Anyways... @margoh thank you so much i helped me to fix 2,4 problems

Now there is only this 1,3 problems to fix, i wasnt expect someone help me this much
 
Not to onoff() function, put it inside init().
Lua:
function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
   
    mainWindow = g_ui.displayUI('main.otui')
    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
end
The problem with moving window could be with wrong loading ui, but cannot be sure. Try to load it to rootPanel.
mainWindow = g_ui.loadUI('main', modules.game_interface.getRootPanel()).
 
Not to onoff() function, put it inside init().
Lua:
function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
  
    mainWindow = g_ui.displayUI('main.otui')
    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
end
The problem with moving window could be with wrong loading ui, but cannot be sure. Try to load it to rootPanel.
mainWindow = g_ui.loadUI('main', modules.game_interface.getRootPanel()).

if i just remove that

anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter

it starts on north west and i can move normal...

like this:
Code:
mainWindow = nil
mainButton = nil

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


function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
       mainWindow = g_ui.loadUI('main', modules.game_interface.getRootPanel())
    mainWindow = g_ui.displayUI('main.otui')
    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
end

function terminate()
    mainWindow:hide()
end

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

???

cause that dont work and also bug the shift+f12
 
mainWindow = g_ui.displayUI('main.otui') - remove that.
g_keyboard.bindKeyDown('Shift+F12', onoff) move to init() and add g_keyboard.bindKeyDown('Shift+F12') to terminate().

To move mainWindow to the center, you can try adding anchors through lua - don't rlly remember if that work, butI think it is. I just remembered there is downside of using MiniWindow, you will be able to move it to left/right panels - so best solution would be using HeadlessWindow and style it to resemble MiniWindow.
 
mainWindow = g_ui.displayUI('main.otui') - remove that.
g_keyboard.bindKeyDown('Shift+F12', onoff) move to init() and add g_keyboard.bindKeyDown('Shift+F12') to terminate().

To move mainWindow to the center, you can try adding anchors through lua - don't rlly remember if that work, butI think it is. I just remembered there is downside of using MiniWindow, you will be able to move it to left/right panels - so best solution would be using HeadlessWindow and style it to resemble MiniWindow.

I tried
Code:
mainWindow = nil
mainButton = nil

function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
    mainWindow = g_ui.loadUI('main', modules.game_interface.getRootPanel())
    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
    g_keyboard.bindKeyDown('Shift+F12', onoff)
end

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

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

The mod cant open anymore, not even pressing the keyshort or clicking on the icon


What are u mean with "To move mainWindow to the center" ?

Everything else was solved by using:
Code:
mainWindow = nil
mainButton = nil

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


function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
    mainWindow = g_ui.displayUI('main.otui')
    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
end

function terminate()
    mainWindow:hide()
end

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

What were u trying to do?
 
I made a mistake. Inside terminate() should be unbind and not bind.

You can add anchors using lua - mainWindow:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter). But you will have to play with it to make it work, as I don't remember if this work in that exact form.
 
I tried
Code:
mainWindow = nil
mainButton = nil

function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
    mainWindow = g_ui.loadUI('main', modules.game_interface.getRootPanel())
    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
    g_keyboard.bindKeyDown('Shift+F12', onoff)
end

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

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

The mod cant open anymore, not even pressing the keyshort or clicking on the icon


What are u mean with "To move mainWindow to the center" ?

Everything else was solved by using:
Code:
mainWindow = nil
mainButton = nil

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


function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
    mainWindow = g_ui.displayUI('main.otui')
    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
end

function terminate()
    mainWindow:hide()
end

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

What were u trying to do?
Can i ask you, you make a mod in "mods" folder?
 
It doesn't matter if you use mods or modules folder. It's just better to put custom modules in mods, for the sake of organization.
Yea, but i mean if they make new module, why forcing to trigger it with basic UI, or they have other files in mod with configuration.
Cuz he trying hide button that are not declared in any files that he paste.
Anyway, delete minimize button lines if you dont want it :D
 
I made a mistake. Inside terminate() should be unbind and not bind.

You can add anchors using lua - mainWindow:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter). But you will have to play with it to make it work, as I don't remember if this work in that exact form.

Like this?
Code:
mainWindow = nil
mainButton = nil

function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
    mainWindow = g_ui.loadUI('main', modules.game_interface.getRootPanel())
    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
    g_keyboard.bindKeyDown('Shift+F12', onoff)
end

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

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

It broke the code again, no errors, just not openning






---


if i use:
Code:
mainWindow = nil
mainButton = nil

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


function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
    mainWindow = g_ui.displayUI('main.otui')
    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
    mainWindow:addAnchor(AnchorHorizontalCenter, 'parent', AnchorHorizontalCenter)
    
end

function terminate()
    mainWindow:hide()
end

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

The window spawns in the middle, but i cant move to the right or left...

And if i also add: mainWindow:addAnchor(AnchorVerticalCenter, 'parent', AnchorVerticalCenter)
The window spawns on center but i cant move to nowhere

There is any other method to set the window position instead of anchor?



Can i ask you, you make a mod in "mods" folder?

Because i want to make a mod

It doesn't matter if you use mods or modules folder. It's just better to put custom modules in mods, for the sake of organization.

;)


Yea, but i mean if they make new module, why forcing to trigger it with basic UI, or they have other files in mod with configuration.
Cuz he trying hide button that are not declared in any files that he paste.
Anyway, delete minimize button lines if you dont want it :D

everything was fixed with @margoh helps
that minimize problem is already done man

the only thing left was:
1) How to render the UI box in the middle of the screen?
 
Yea, but i mean if they make new module, why forcing to trigger it with basic UI, or they have other files in mod with configuration.
Cuz he trying hide button that are not declared in any files that he paste.
Anyway, delete minimize button lines if you dont want it :D
Actually it is declared inside styles, so if you are using MiniWindow as a base of your module, you can access all it's contents (those that are declared inside styles) with lua.


Try this:
Lua:
mainWindow = nil
mainButton = nil

function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
    mainButton:setOn(false)
    mainWindow = g_ui.loadUI('main', modules.game_interface.getRootPanel())
    mainWindow:recursiveGetChildById('minimizeButton'):hide()

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

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

function onoff()
    if mainWindow:isVisible() then
        mainWindow:close()
        mainButton:setOn(false)
    else
        mainWindow:open()
        mainButton:setOn(true)
    end
end

function onMiniWindowClose()
    mainButton:setOn(false)
end

If setting anchors blocks ability to move window, you can try to calculate where it should appear and use top: x and left: x.
 
Last edited:
Actually it is declared inside styles, so if you are using MiniWindow as a base of your module, you can access all it's contents (those that are declared inside styles) with lua.


Try this:
Lua:
mainWindow = nil
mainButton = nil

function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
    mainButton:setOn(false)
    mainWindow = g_ui.loadUI('main', modules.game_interface.getRootPanel())
    mainWindow:recursiveGetChildById('minimizeButton'):hide()

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

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

function onoff()
    if mainWindow:isVisible() then
        mainWindow:close()
        mainButton:setOn(false)
    else
        mainWindow:open()
        mainButton:setOn(true)
    end
end

function onMiniWindowClose()
    mainButton:setOn(false)
end

If setting anchors blocks ability to move window, you can try to calculate where it should appear and use top: x and left: x.

Same thing, no errors, no open
I'm not understanding what are u trying to do in this

On this way is working:
Code:
mainWindow = nil
mainButton = nil

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


function init()
    mainButton = modules.client_topmenu.addRightToggleButton('mainButton', tr('Elfbot OTC'), 'data/imgs/elfbot_icon.png', onoff)
    mainWindow = g_ui.displayUI('main.otui')
    mainWindow:hide()
    mainWindow:recursiveGetChildById('minimizeButton'):hide()
end

function terminate()
    mainWindow:hide()
end

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

What are u want?


About that centering problem, i tried:
Code:
MiniWindow
  id: mainWindow
  !text: tr('ElfBot Otclient 0.1 -- 0 ms - 0 exp/hour')
  width: 625
  height: 160
  icon: data/imgs/elfbot_icon
  top: 100
  bottom: 100
  left: 100
  right: 100
  @onClose: modules.game_minimap.onMiniWindowClose()

But nothing change, why?
Could i use LUA methods to detect window screen so set it in the middle?
 
Same thing, no errors, no open
Have you tried to use button to open a window?

Could i use LUA methods to detect window screen so set it in the middle?
Yes.
 
Solution
Back
Top