PDA

View Full Version : Interface.findWindow() not finding window problems



gnujak
July 1st, 2019, 03:39
Good evening everyone, what I am trying to do is get a window reference to create a control on the character sheet. I have figured out how to make the control work in the script portion of the onInit() of the window class but I want to take it out and put it into it's own script file. I try and pass the windowclass name and database node to a function in my script file but it can't find a window with that name I guess. I tried with the name of the windowclass I am making the control in and also the name of the main class of the character sheet. I have used bot the database node name and no database node but I can't find the window I want to make the control in. Any sugesstions?

Ikael
July 1st, 2019, 09:07
Interface.findWindow can only find it if it's already created. This means that the charsheet should have been opened. You should try using Interface.openWindow instead.

gnujak
July 1st, 2019, 19:03
Thank you for that suggestion. I have figured out that the window hadn't been created yet because I was calling the find window in the onInit() which means the window wasn't created yet so no handle to it right? Where should I be putting the code? onInit() will draw them when the character sheet is first opened but that is all. Is there some other function I should use to check when the character sheet is shown? I tried onUpdate(). So what it is I'm doing is when the inventory is changed for what is equipped the controls on the main character sheet("tab") should be changed/updated.

Trenloe
July 1st, 2019, 19:10
Is there some other function I should use to check when the character sheet is shown? I tried onUpdate(). So what it is I'm doing is when the inventory is changed for what is equipped the controls on the main character sheet("tab") should be changed/updated.
Have a look at the CoreRPG onCarriedChanged function in campaign\scripts\char_invlist.lua