As promised I'm going to post what happens to GS's LuaEvent between UI and Gameplay.
So long story short, LuaEvent doesn't work between to 2 types of scripts any more. It still works among scripts of same context (UI or Gameplay only).
Instead, Firaxis introduced a new method:
Code:
local kParameters:table = {};
kParameters.iPlayerID = iPlayerID;
kParameters.pEnvoyTokens = pEnvoyTokens;
kParameters.iAnnexCost = iAnnexCost;
-- Send this GameEvent when processing the operation
kParameters.OnStart = "HT_LocalPlayerAnnexCityState";
UI.RequestPlayerOperation(localPlayerID, PlayerOperations.EXECUTE_SCRIPT, kParameters);
This is my updated code to Tully's annex city-state script, on UI end. Basically this will trigger a GameEvent, and the Gameplay script will use this GameEvent to execute functions.
Code:
GameEvents.HT_LocalPlayerAnnexCityState.Add(OnLocalPlayerAnnexCityState);
Register the event in OnLoadScreenClose event, or wherever you feel comfortable in Gameplay end script.
Code:
function OnLocalPlayerAnnexCityState(localPlayerID, params : table)
local citStateID = params.iPlayerID;
local envoyTokens = params.pEnvoyTokens;
local iAnnexCost = params.iAnnexCost;
--Your actual functions
end
So by doing so the function is called when UI.RequestPlayerOperation method is activated on UI end. Parameters are packaged in a table so you want to unpack the data before using it.
And limitation is, the packaged table as parameter to pass into the function does not take tables in tables. When I packaged nested data, on calling the function the game crashed directly.
Hope this is useful information.