Hi all, I've lurked for a bit on here and I'm stuck on something that I suspect is just confusion on high-level approach. I am creating a mod wherein I'm interested in looking at several characteristics for multiple in-game objects. Cities are a good example here - I have the following rough pseudo-code to approximate what I'm doing here...
-------------------------------------------------------------------
function GenerateCityData(player, civName)
for idx, pCity in player:GetCities():Members() do
***(I Want To Get Gold Here.... Culture yield,bunch of other stuff, Etc)***
end
end
function OnGlobalTurnCompleted(iTurnNumber)
local pAlivePlayers = PlayerManager.GetWasEverAliveIDs()
for i, id in pairs(pAlivePlayers) do
PlayerID = Players[id]
(more *stuff*)
GenerateCityData(pPlayer, shortName)
end
end
Events.OnGameTurnEnded.Add(OnGlobalTurnCompleted)
--------------------------------------------------------------------
(This file is built with "GamePlayScript" in modbuddy)
Now, in ChimpanG's listing of LUA objects and their context, I've noticed he differentiates between IN GAME and IN CONTEXT(UI). I know for a fact that I am adding my above code to the IN GAME portion (essentially just adding an extra functionality at the end of a turn) through the Events.OnGameTurnEnded.Add() functionality, but in LeeS Civ 6 guide to modding, he mentions that data can be shared between these contexts (but doesn't really specify how exactly). It seems that for some data items - City:GetCulture():GetCultureYield() for example - can only be grabbed from this ui context. How can I mix and gather this data from both contexts? Is my approach fundamentally wrong or am I just missing something? Been at it for about 2 or 3 days now but I've been hung up on this part. Thank you in advance!
-------------------------------------------------------------------
function GenerateCityData(player, civName)
for idx, pCity in player:GetCities():Members() do
***(I Want To Get Gold Here.... Culture yield,bunch of other stuff, Etc)***
end
end
function OnGlobalTurnCompleted(iTurnNumber)
local pAlivePlayers = PlayerManager.GetWasEverAliveIDs()
for i, id in pairs(pAlivePlayers) do
PlayerID = Players[id]
(more *stuff*)
GenerateCityData(pPlayer, shortName)
end
end
Events.OnGameTurnEnded.Add(OnGlobalTurnCompleted)
--------------------------------------------------------------------
(This file is built with "GamePlayScript" in modbuddy)
Now, in ChimpanG's listing of LUA objects and their context, I've noticed he differentiates between IN GAME and IN CONTEXT(UI). I know for a fact that I am adding my above code to the IN GAME portion (essentially just adding an extra functionality at the end of a turn) through the Events.OnGameTurnEnded.Add() functionality, but in LeeS Civ 6 guide to modding, he mentions that data can be shared between these contexts (but doesn't really specify how exactly). It seems that for some data items - City:GetCulture():GetCultureYield() for example - can only be grabbed from this ui context. How can I mix and gather this data from both contexts? Is my approach fundamentally wrong or am I just missing something? Been at it for about 2 or 3 days now but I've been hung up on this part. Thank you in advance!