Skip a GenericPopup

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
In GenericPopup.lua, how can I skip displaying a specific type of popup? I tried variations of this:

PHP:
if initialize then
  local activePlayer = Players[Game.GetActivePlayer()]
  if (popupInfo.Type == ButtonPopupTypes.BUTTONPOPUP_CITY_CAPTURED
    and popupInfo.Data3 == -1
    and not activePlayer:CanRaze(city)
    ) then
    -- No option but puppeting
    Network.SendDoTask(popupInfo.Data1, TaskTypes.TASK_CREATE_PUPPET, -1, -1, false, false, false, false);
  else
    ClearButtons();
    initialize(popupInfo);
    ShowWindow();
    mostRecentPopup = popupInfo.Type;
    g_isOpen = true;  
  end
end

It works the first time the popup should display, correctly preventing the popup. When it should display a second time however, the OnDisplay function never runs at all! I checked this with a print("OnDisplay") at the top of the function. What did I do wrong?
 
I've been playing around with popups the last couple of days and the only thing I learned is that Events.SerialEventGameMessagePopup doesn't always fire depending on how the popup was opened. You can make it fire if you add that to the function that opens the popup, I believe. I also started relying on Events.SerialEventGameMessagePopupShown ( popupInfo ) as that sometimes fires when SerialEventGameMessagePopup doesn't. The hiccup here is that both can fire trigging off the function twice. For my mod that is fine. I just had a check that ensure the code only ran once but not sure what you are exactly doing. Lots still over my head. Some popups seem flakey as they fire off one or the other, both, or none of the MessagePopup events.
 
I attempted to do some testing with this. I edited in your commented out code in GenericPopup.lua (v108) and then ate two city states in a row without the annex popup appearing. Probably needs further testing to find the situation where it fails.
 
Two different programmers might have done this part of the game... I've encountered more obvious situations of that, but it could explain why it's so disorganized.
 
Back
Top Bottom