Jump to content
Sign in to follow this  
dupa1

Artillery Computer Question

Recommended Posts

I'm trying to set up a ctrlAddEventHandler ["Draw", {..}]; to draw icons on the arty computer map. To find the map idc, I use the following code:

waitUntil {sleep 1; shownArtilleryComputer};
_ctrl = controlNull;
{
  if (!isNull (_x displayCtrl 500)) then
  {
    _ctrl = _x displayCtrl 500;
  };
} forEach (uiNamespace getVariable "igui_displays") + allDisplays;

 

Next I set up the event handler and it works fine. When arty computer is closed, _ctrl becomes controlNull (just as it was before the arty computer was opened). The next time the arty computer is opened, the event handler no longer works and the process needs to be repeated. 

 

My question: Does this mean that the display is completely destroyed when closing the artillery computer? If I add event handlers every time the artillery computer is opened, do they stack up or are they destroyed together with the display? Should I consider using ctrlSetEventHandler instead?

Share this post


Link to post
Share on other sites

It's been awhile since I worked with displays so maybe double check in your testing but as far as I can remember:

 

On 2/27/2024 at 1:51 AM, dupa1 said:

Does this mean that the display is completely destroyed when closing the artillery computer?

Yes, closing the display = destroying it.

 

On 2/27/2024 at 1:51 AM, dupa1 said:

If I add event handlers every time the artillery computer is opened, do they stack up or are they destroyed together with the display?

All event handlers are destroyed also.

 

On 2/27/2024 at 1:51 AM, dupa1 said:

Should I consider using ctrlSetEventHandler instead?

Using Set is not recommended, it's a leftover from the old days of UI scripting. See the Biki page for more info.

It definitely has nothing to do with the lifetime of the event handlers though.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×