• 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 How to create a secondary window in Otclient?

sabodden

Member
Joined
Sep 27, 2019
Messages
138
Reaction score
18
I want to when someone clicks in a button in main window, opens a secondary window...
How to do?

I trying to when user clicks in 'Healing' button open a new secondary window...

The healing button in main window:

The healing window:

I tried this:

But did not work...
What do i doing wrong?
 
Solution
I'm trying to do it, i'm doing something wrong?





Can u test it in your computer, maybe is something here...
Its a mod, just paste in your mods folder pls

Ok, so it took me almost 1 hour to test any possible scenario, but I found the solution to your problem :D

So, then I looked into logs, this came up:

1617427932633.png


That showed me, that this line is returning nil.
Lua:
optionsButton['healing'] = mainWindow:getChildById('healingButton')

So, wrong function used? Perhaps..


So I changed the function getChildById to recursiveGetChildById because as it says it searches also in childs of childs.

Then it worked.

Woila :)

1617428169027.png
its just like from this main:
original.png.8c74317f4cf5b6d1be59880da09b5afd.png


open the secondary healing:
Editada+3.jpg
 
Its easy, you just need create a function to show your secondary window.

In your .OTUI put it into the button:
C++:
@onClick: modules.game_YourModule.YourFunction()

and in your .LUA file create a function to show your window:
Lua:
YourWindow = nil

funtion init()
    YourWindow = g_ui.displayUI('YourFileWindow')
    YourWindow:hide()
end

function terminate()
    YourWindow:destroy()
end

function YourFunction()
    return YourWindow
end
 
Last edited:
Its easy, you just need create a function to show your secondary window.

In your .OTUI put it into the button:
C++:
@onClick: modules.game_YourModule.YourFunction()

and in your .LUA file create a function to show your window:
Lua:
YourWindow = nil

funtion init()
    YourWindow = g_ui.displayUI('YourFileWindow')
    YourWindow:hide()
end

function terminate()
    YourWindow:destroy()
end

function YourFunction()
    return YourWindow
end

If you would look at his code, he already do this.

@sabodden

I also looked at your code, it seems everything is in the right place. I am currently out of ideas why your code does not work.
 
Its easy, you just need create a function to show your secondary window.

In your .OTUI put it into the button:
C++:
@onClick: modules.game_YourModule.YourFunction()

and in your .LUA file create a function to show your window:
Lua:
YourWindow = nil

funtion init()
    YourWindow = g_ui.displayUI('YourFileWindow')
    YourWindow:hide()
end

function terminate()
    YourWindow:destroy()
end

function YourFunction()
    return YourWindow
end

I'm trying to do it, i'm doing something wrong?


If you would look at his code, he already do this.

@sabodden

I also looked at your code, it seems everything is in the right place. I am currently out of ideas why your code does not work.


Can u test it in your computer, maybe is something here...
Its a mod, just paste in your mods folder pls
 
I'm trying to do it, i'm doing something wrong?





Can u test it in your computer, maybe is something here...
Its a mod, just paste in your mods folder pls

Ok, so it took me almost 1 hour to test any possible scenario, but I found the solution to your problem :D

So, then I looked into logs, this came up:

1617427932633.png


That showed me, that this line is returning nil.
Lua:
optionsButton['healing'] = mainWindow:getChildById('healingButton')

So, wrong function used? Perhaps..


So I changed the function getChildById to recursiveGetChildById because as it says it searches also in childs of childs.

Then it worked.

Woila :)

1617428169027.png
 
Solution
Ok, so it took me almost 1 hour to test any possible scenario, but I found the solution to your problem :D

So, then I looked into logs, this came up:

View attachment 57238


That showed me, that this line is returning nil.
Lua:
optionsButton['healing'] = mainWindow:getChildById('healingButton')

So, wrong function used? Perhaps..


So I changed the function getChildById to recursiveGetChildById because as it says it searches also in childs of childs.

Then it worked.

Woila :)

View attachment 57239

I thought no one was going to be able to help
TY <3
 
Back
Top