Lua Objects

Are you sure you're looking at the actual value, not just the key?

I have no idea, I think so. Most of it looks like a big table of 64-bit datatype/64-bit data structs. The ones with 0x4 for the datatype do all point to a string, so that fits with what lua.h says, but then there's lots that aren't defined there (namely 0xA, which is probably added by Havok). It just looks like it runs over a bunch of tables (0x5 datatype stuff) a billion times, while creating new tables (metatables?) and removing them, and searching for both _instance and _index and going through them. I just dunno what it's doing. How do I tell what's a key and what's a value?
 
I have no idea, I think so. Most of it looks like a big table of 64-bit datatype/64-bit data structs. The ones with 0x4 for the datatype do all point to a string, so that fits with what lua.h says, but then there's lots that aren't defined there (namely 0xA, which is probably added by Havok). It just looks like it runs over a bunch of tables (0x5 datatype stuff) a billion times, while creating new tables (metatables?) and removing them, and searching for both _instance and _index and going through them. I just dunno what it's doing. How do I tell what's a key and what's a value?
How are you actually seeing this? I have Hex Workshop open, how does one get to where you are?
 
Network. object seems important works in game setup
(used for game start, load, save, multiplayer game connection and chat)
but not found in this thread

I've tried restart game by
Network.leave();
Network.HostGame(ServerType.SERVER_TYPE_NONE);
and crashed at black loading screen.
They commented -- "Hide the restart button until functionality is implemented and stable"
sure it can't

and I wonder what role "ContextPtr" doing

and LuaEvents. Events. add callbacks for event handler?
 
Last edited:
So I figured out how to get the next tile the city will expand to.

Use pCityCulture:GetNextPlot() to get the tile index of the next plot the city will expand to. GetNextPlotCultureCost() for its cost. pCityCulture:TurnsUntilExpansion() gives you the turns until you expand, but in my experience that one's been a bit buggy, and I haven't usually expanded on the right turn,, sometimes up to 5 turns too early, or 1 turn too late. I think it's purely based off of the tile cost / current culture a turn. Maybe getting the city's culture income and working it out yourself you might be more accurate I dunno.

I had to put it in the city's name bar cause I don't know how to show it properly with 0 Lua knowledge, but here's an example:

http://i.imgur.com/t4FzYI3.jpg - It's expanding to tile 2052, has a culture cost of 10, and will take 7 turns at 1.4 culture/turn (settled on turn 1, screenshot on turn 2).

http://i.imgur.com/3ifIiec.jpg - 7 turns later we get the plot, now it's going for 2203, cost of 20, which will take 12 turns at 1.7 culture/turn.
 
Last edited:
Using this
Code:
function l(object) print("Attributes:") for k, v in pairs(getmetatable(object).__index) do print(k); end; print("End attributes."); end
What state are you in when using this function? I tried to use it in WorldInput and got nothing. Tried again in Main State and InGame, i always get an "attempt to index a nil value" error, even trying it on objects you have already listed in the first post (like Unit)
I can get the content of tables easily enough, but not the objects.
 
What state are you in when using this function? I tried to use it in WorldInput and got nothing. Tried again in Main State and InGame, i always get an "attempt to index a nil value" error, even trying it on objects you have already listed in the first post (like Unit)
I can get the content of tables easily enough, but not the objects.
you need to select an unit (or player, city...) first, for example using:
u = Players[0]:GetUnits():GetFirstReadyUnit()
c = Players[0]:GetCities():GetCapitalCity()

and print (u) or print(c) to check it's not nil then the function.

note that what we can access depend of the context (UI in game or a script defined in the modinfo), see http://forums.civfanatics.com/threads/current-status-of-lua-modding.603706/
 
This probably isn't very helpful without the actual parameters passed to the events but here is the list of all the events added to Lua from the main .exe.

I just left the class names on for informational purposes--obviously only use the part after the "::" in Lua, like "Events.AnarchyBegins.Add(OnAnarchyBegins)".

For the ones actually used in the existing Lua you can just grep to get an example with the parameters.

GameCoreEvent::AnarchyBegins
GameCoreEvent::AnarchyEnds
GameCoreEvent::BeliefAdded
GameCoreEvent::BuildingAddedToMap
GameCoreEvent::BuildingChanged
GameCoreEvent::BuildingRemovedFromMap
GameCoreEvent::CapitalCityChanged
GameCoreEvent::CityAddedToMap
GameCoreEvent::CityCommandStarted
GameCoreEvent::CityDefenseStatusChanged
GameCoreEvent::CityFocusChanged
GameCoreEvent::CityInitialized
GameCoreEvent::CityLiberated
GameCoreEvent::CityMadePurchase
GameCoreEvent::CityPopulationChanged
GameCoreEvent::CityProductionChanged
GameCoreEvent::CityProductionCompleted
GameCoreEvent::CityProductionUpdated
GameCoreEvent::CityProjectCompleted
GameCoreEvent::CityReligionChanged
GameCoreEvent::CityReligionFollowersChanged
GameCoreEvent::CityRemovedFromMap
GameCoreEvent::CitySiegeStatusChanged
GameCoreEvent::CityTileOwnershipChanged
GameCoreEvent::CityUnitsChanged
GameCoreEvent::CityVisibilityChanged
GameCoreEvent::CityWorkerChanged
GameCoreEvent::CivicBoostTriggered
GameCoreEvent::CivicChanged
GameCoreEvent::CivicCompleted
GameCoreEvent::CivicQueueChanged
GameCoreEvent::CivicsUnlocked
GameCoreEvent::Combat
GameCoreEvent::CultureChanged
GameCoreEvent::CultureYieldChanged
GameCoreEvent::DiplomacyDealEnacted
GameCoreEvent::DiplomacyDealExpired
GameCoreEvent::DiplomacyDeclareWar
GameCoreEvent::DiplomacyIncomingDeal
GameCoreEvent::DiplomacyMakePeace
GameCoreEvent::DiplomacyMeet
GameCoreEvent::DiplomacyMeetMajorMinor
GameCoreEvent::DiplomacyMeetMajors
GameCoreEvent::DiplomacyRefusePeace
GameCoreEvent::DiplomacyRelationshipChanged
GameCoreEvent::DiplomacySessionClosed
GameCoreEvent::DiplomacyStatement
GameCoreEvent::DistrictAddedToMap
GameCoreEvent::DistrictBuildProgressChanged
GameCoreEvent::DistrictCombatChanged
GameCoreEvent::DistrictDamageChanged
GameCoreEvent::DistrictPillaged
GameCoreEvent::DistrictRemovedFromMap
GameCoreEvent::DistrictUnitsChanged
GameCoreEvent::DistrictVisibilityChanged
GameCoreEvent::EndTurnBlockingChanged
GameCoreEvent::EndTurnDirty
GameCoreEvent::FaithChanged
GameCoreEvent::FeatureAddedToMap
GameCoreEvent::FeatureChanged
GameCoreEvent::FeatureRemovedFromMap
GameCoreEvent::GoodyHutReward
GameCoreEvent::GovernmentChanged
GameCoreEvent::GovernmentPolicyChanged
GameCoreEvent::GovernmentPolicyObsoleted
GameCoreEvent::GreatPeoplePointsChanged
GameCoreEvent::GreatPeopleTimelineChanged
GameCoreEvent::GreatWorkCreated
GameCoreEvent::GreatWorkMoved
GameCoreEvent::ImprovementActivated
GameCoreEvent::ImprovementAddedToMap
GameCoreEvent::ImprovementChanged
GameCoreEvent::ImprovementOwnershipChanged
GameCoreEvent::ImprovementRemovedFromMap
GameCoreEvent::ImprovementVisibilityChanged
GameCoreEvent::InfluenceChanged
GameCoreEvent::InfluenceGiven
GameCoreEvent::LevyCounterChanged
GameCoreEvent::LocalPlayerChanged
GameCoreEvent::LocalPlayerTurnBegin
GameCoreEvent::LocalPlayerTurnEnd
GameCoreEvent::MapYieldsChanged
GameCoreEvent::NationalParkAdded
GameCoreEvent::NaturalWonderRevealed
GameCoreEvent::NotificationAdded
GameCoreEvent::NotificationDismissed
GameCoreEvent::NotificationRefreshRequested
GameCoreEvent::ObjectPairing
GameCoreEvent::OnAiAdvisorUpdated
GameCoreEvent::PantheonFounded
GameCoreEvent::PhaseBegin
GameCoreEvent::PhaseEnd
GameCoreEvent::PlayerBordersChanged
GameCoreEvent::PlayerDefeat
GameCoreEvent::PlayerDestroyed
GameCoreEvent::PlayerEraChanged
GameCoreEvent::PlayerOperationComplete
GameCoreEvent::PlayerTurnActivated
GameCoreEvent::PlayerTurnDeactivated
GameCoreEvent::PlayerVictory
GameCoreEvent::PlotMarkerChanged
GameCoreEvent::PlotVisibilityChanged
GameCoreEvent::PlotYieldChanged
GameCoreEvent::QuestChanged
GameCoreEvent::ReligionFounded
GameCoreEvent::RemotePlayerTurnBegin
GameCoreEvent::RemotePlayerTurnEnd
GameCoreEvent::ResearchChanged
GameCoreEvent::ResearchCompleted
GameCoreEvent::ResearchQueueChanged
GameCoreEvent::ResearchYieldChanged
GameCoreEvent::ResourceAddedToMap
GameCoreEvent::ResourceChanged
GameCoreEvent::ResourceRemovedFromMap
GameCoreEvent::ResourceVisibilityChanged
GameCoreEvent::RouteAddedToMap
GameCoreEvent::RouteChanged
GameCoreEvent::RouteRemovedFromMap
GameCoreEvent::SpyAdded
GameCoreEvent::SpyMissionUpdated
GameCoreEvent::SpyRemoved
GameCoreEvent::SpyUpdated
GameCoreEvent::StatusMessage
GameCoreEvent::TechBoostTriggered
GameCoreEvent::TerrainTypeChanged
GameCoreEvent::TradeRouteActivityChanged
GameCoreEvent::TradeRouteAddedToMap
GameCoreEvent::TradeRouteCapacityChanged
GameCoreEvent::TradeRouteRangeChanged
GameCoreEvent::TradeRouteRemovedFromMap
GameCoreEvent::TreasuryChanged
GameCoreEvent::TurnBegin
GameCoreEvent::TurnEnd
GameCoreEvent::UnitActivityChanged
GameCoreEvent::UnitAddedToMap
GameCoreEvent::UnitAirlifted
GameCoreEvent::UnitArtifactChanged
GameCoreEvent::UnitCaptured
GameCoreEvent::UnitChargesChanged
GameCoreEvent::UnitCommandStarted
GameCoreEvent::UnitDamageChanged
GameCoreEvent::UnitEmbarkedStateChanged
GameCoreEvent::UnitEnterFormation
GameCoreEvent::UnitExitFormation
GameCoreEvent::UnitFormArmy
GameCoreEvent::UnitFormCorps
GameCoreEvent::UnitFortificationChanged
GameCoreEvent::UnitGreatPersonActivated
GameCoreEvent::UnitGreatPersonChanged
GameCoreEvent::UnitGreatPersonCreated
GameCoreEvent::UnitKilledInCombat
GameCoreEvent::UnitMoveComplete
GameCoreEvent::UnitMoved
GameCoreEvent::UnitMovementPointsChanged
GameCoreEvent::UnitMovementPointsCleared
GameCoreEvent::UnitMovementPointsRestored
GameCoreEvent::UnitOperationAdded
GameCoreEvent::UnitOperationDeactivated
GameCoreEvent::UnitOperationSegmentComplete
GameCoreEvent::UnitOperationStarted
GameCoreEvent::UnitOperationsCleared
GameCoreEvent::UnitPromoted
GameCoreEvent::UnitPromotionAvailable
GameCoreEvent::UnitRemovedFromMap
GameCoreEvent::UnitTeleported
GameCoreEvent::UnitUpgraded
GameCoreEvent::UnitVisibilityChanged
GameCoreEvent::WMDCountChanged
GameCoreEvent::WMDDetonated
GameCoreEvent::WMDFalloutChanged
GameCoreEvent::WMDFalloutVisibilityChanged
GameCoreEvent::WonderCompleted
GameCoreEvent::WorldTextMessage
LocalMachineEvent::ARXOrientationChanged
LocalMachineEvent::ARXTap
LocalMachineEvent::AchievementProgress
LocalMachineEvent::AchievementUnlocked
LocalMachineEvent::Begin2KLoginProcess
LocalMachineEvent::BeginGameView
LocalMachineEvent::BeginMy2KLinkAccountProcess
LocalMachineEvent::BeginWonderReveal
LocalMachineEvent::Camera_Updated
LocalMachineEvent::CloudGameInfoUpdated
LocalMachineEvent::CloudGameJoinResponse
LocalMachineEvent::CloudGameListUpdated
LocalMachineEvent::EndGameView
LocalMachineEvent::EndWonderReveal
LocalMachineEvent::ExitToMainMenu
LocalMachineEvent::FiraxisLiveActivate
LocalMachineEvent::FrontEndPopup
LocalMachineEvent::GameConfigChanged
LocalMachineEvent::HideLeaderScreen
LocalMachineEvent::InputActionTriggered
LocalMachineEvent::InputGestureRecorded
LocalMachineEvent::LeaderAnimationChanged
LocalMachineEvent::LeaderAnimationComplete
LocalMachineEvent::LeaderScreenFinishedLoading
LocalMachineEvent::LeaveGameComplete
LocalMachineEvent::ModStatusUpdated
LocalMachineEvent::MultiplayerChat
LocalMachineEvent::MultiplayerGameAbandoned
LocalMachineEvent::MultiplayerGameLastPlayer
LocalMachineEvent::MultiplayerGameListClear
LocalMachineEvent::MultiplayerGameListComplete
LocalMachineEvent::MultiplayerGameListUpdated
LocalMachineEvent::MultiplayerHostMigrated
LocalMachineEvent::MultiplayerJoinGameComplete
LocalMachineEvent::MultiplayerJoinRoomAttempt
LocalMachineEvent::MultiplayerJoinRoomComplete
LocalMachineEvent::MultiplayerJoinRoomFailed
LocalMachineEvent::MultiplayerPingTimesChanged
LocalMachineEvent::MultiplayerPlayerConnected
LocalMachineEvent::MultiplayerPostPlayerDisconnected
LocalMachineEvent::MultiplayerPrePlayerDisconnected
LocalMachineEvent::MultiplayerSnapshotProcessed
LocalMachineEvent::My2KActivate
LocalMachineEvent::My2KLinkAccountResult
LocalMachineEvent::OptionChangeRequiresAppRestart
LocalMachineEvent::OptionChangeRequiresGameRestart
LocalMachineEvent::OptionChangeRequiresResolutionAck
LocalMachineEvent::OptionChanged
LocalMachineEvent::OptionsReset
LocalMachineEvent::OptionsReverted
LocalMachineEvent::OptionsSaved
LocalMachineEvent::PlayerInfoChanged
LocalMachineEvent::ShowLeaderScreen
LocalMachineEvent::SteamFriendsPresenceUpdated
LocalMachineEvent::SteamFriendsStatusUpdated
LocalMachineEvent::SteamServersConnected
LocalMachineEvent::SteamServersDisconnected
LocalMachineEvent::TurnTimerUpdated
LocalMachineEvent::UpdateGraphicsOptions
LocalMachineEvent::UserAcceptsEULA
LocalMachineEvent::UserAcceptsOutdatedDriver
LocalMachineEvent::UserAcceptsUnknownDevice
LocalMachineEvent::UserConfirmedClose
LocalMachineEvent::UserRequestClose
LocalMachineEvent::WorldRenderViewChanged
SequenceEvent::AppInitComplete
SequenceEvent::GameViewStateDone
SequenceEvent::LoadGameViewStateDone
SequenceEvent::LoadScreenClose
SequenceEvent::LoadScreenContentReady
SequenceEvent::MainMenuStateDone
SerialEvent::AfterGameplayContentChange
SerialEvent::AfterGameplayContentConfigure
SerialEvent::AllCitiesDeselected
SerialEvent::AllDistrictsDeselected
SerialEvent::AllUnitsDeselected
SerialEvent::AutomationTestComplete
SerialEvent::BeforeGameplayContentChange
SerialEvent::BeforeGameplayContentConfigure
SerialEvent::BeforeMultiplayerInviteProcessing
SerialEvent::CitySelectionChanged
SerialEvent::CombatVisBegin
SerialEvent::CombatVisEnd
SerialEvent::CycleUnitSelectionRequest
SerialEvent::DemoExit
SerialEvent::DemoTurnLimitReached
SerialEvent::DistrictSelectionChanged
SerialEvent::FinishedGameplayContentChange
SerialEvent::FinishedGameplayContentConfigure
SerialEvent::GameConfigurationParameterChanged
SerialEvent::GameConfigurationRebuilt
SerialEvent::GameConfigurationResolved
SerialEvent::GameCoreEventPlaybackComplete
SerialEvent::GameCoreEventPublishComplete
SerialEvent::InterfaceModeChanged
SerialEvent::LensFocusHex
SerialEvent::LensLayerOff
SerialEvent::LensLayerOn
SerialEvent::LensUnFocusHex
SerialEvent::LoadCanceled
SerialEvent::LoadComplete
SerialEvent::MapMaxMajorPlayersChanged
SerialEvent::MultiplayerGameInvite
SerialEvent::MultiplayerGameLaunched
SerialEvent::PreTurnBegin
SerialEvent::RequestLoad
SerialEvent::RequestSave
SerialEvent::SaveCanceled
SerialEvent::SaveComplete
SerialEvent::SubscriptionDownloadStatus
SerialEvent::UnitSelectionChanged
SerialEvent::UnitSimPositionChanged
SerialEvent::UserOptionChanged
SerialEvent::VisualStateRestored
UIEvent::DragCamera
UIEvent::SystemUpdateUI
 
Hello!
This is perhaps a bit off topic, apologies for that.
But you guys seeme more capable dealing with the .dll files than me.

I am looking for the part of the startup process that reads from the Mod files, specifically the .modinfo and its xml structure.

There is a table in modding.sql that's named SettingComponents, which directly links settings with components.
If we learn how to utilize this, it would perhaps let us force the game to run .lua replacements\code on startup :)
 
I might take a look at that, Moptan. I'm using IDA to disassemble the main .exe and .dll. Of course if they'd just release more info along with the source code for the DLL like they did for Civ 5, that would make all our lives a lot easier--and I'm sure they will eventually.

Right now I'm looking for an event that fires once the configuration settings have been determined, but before the game starts, and that would work with multiplayer. I want to adjust some values in the Districts table in memory, but apparently by the time the NewGameInitialized and LoadGameViewStateDone events fire, each player already has their own copy of the Districts table--when I modify it in those events to, say, increase the cost of holy site districts to 1000, the production cards list 1000 as the base cost but 60 as the adjusted cost. So I either need to find an earlier event, or where the per player copies are stored. The map creation process might be early enough, but since that only fires on the host's box, I'm not sure changes made there would propagate in multiplayer games.
 
There's also
Code:
Units.GetUnitsInPlotLayerID
which is used in two ways in the game's UI files:
Code:
local unitList:table = Units.GetUnitsInPlotLayerID( adjacentPlot:GetX(), adjacentPlot:GetY(), MapLayers.ANY );

local tradeLayerID = 1;
aUnits = Units.GetUnitsInPlotLayerID(plot, tradeLayerID)
The first of these I've used in a game script without trouble.

There is also a "Units.X" method of
Code:
local unitsInPlot = Units.GetUnitsInPlot(unitPlot);
But I have not tried this one in a gameplay script as yet.

All of these give an lua arrray-table of the units where the 'k' of the table is an integer and the 'v' is the unit object.

So for the topmost one, which I am currently using, I can then look to see if there is a Settler or a Builder on a given plot, and not add that plot to a list of plots if one of these units is present:
Code:
local bAddPlot = true
local unitList:table = Units.GetUnitsInPlotLayerID( adjacentPlot:GetX(), adjacentPlot:GetY(), MapLayers.ANY );
if unitList ~= nil then
     print("table unitList for the plot gives a list of units")
     for i, pUnit in ipairs(unitList) do
          if (UnitManager.GetTypeName(pUnit) == "LOC_UNIT_SETTLER_NAME") or (UnitManager.GetTypeName(pUnit) == "LOC_UNIT_BUILDER_NAME") then
               bAddPlot = false
               break
          end
     end
else
     print("table unitList for the plot is nil")
end

Not sure if these should be considered 'plot' methods as they would have been in civ5, or as 'unit' methods.
 
Thanks, there are:

Units.AreUnitsInPlot
Units.AreUnitsInPlotLayerID
Units.GetLayerCount
Units.GetPlayerUnitsInPlot
Units.GetPlayerUnitsInPlotLayerID
Units.GetUnitByIndexInPlot
Units.GetUnitCountInPlot
Units.GetUnitCountInPlotLayerID
Units.GetUnitCountInPlotLayerIndex
Units.GetUnitsInPlot
Units.GetUnitsInPlotLayerID
Units.GetUnitsInPlotLayerIndex

and

Cities.GetCityInPlot
Cities.GetPlotPurchaseCity
Cities.GetPlotWorkingCity

and a lot more (well, everything...) in _G, but dumping it without filtering gives more than 200000 lines...

I'm also working on something for all events listed by PlotinusRedux
 
Here are zipped the panel file (.ltp) and the code (.lua) I'm using in the firetuner to listen to all events that have been posted here. (Edit : you don't need the lua file to use the panel, it's attached because it's too long to fit in a post in the code tag)

An example of the result in the lua.log:

Code:
InGame:  Event :    DistrictBuildProgressChanged       
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 11
InGame: 7    524295    196610    82    54    1    1400916610    -507217249    44    2    0
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    CityReligionChanged                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 3
InGame: 7    196610    -1
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    CityPopulationChanged               
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 3
InGame: 7    196610    3
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    CityFocusChanged                   
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 2
InGame: 7    131073
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    ResourceRemovedFromMap             
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 2
InGame: 80    67
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    DistrictAddedToMap                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 11
InGame: 7    589832    65536    80    67    6    1400916610    -507217249    7    -1    0
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    DistrictBuildProgressChanged       
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 11
InGame: 8    393221    131073    26    79    2    1400916610    -1806906687    59    4    0
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    ResearchQueueChanged               
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 1
InGame: 8
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    UnitEnterFormation                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 8    2097168    8    1966083
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    CityFocusChanged                   
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 2
InGame: 10    196610
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    ImprovementActivated               
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 8
InGame: 19    53    10    196608    9    -1    0    0
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    ImprovementRemovedFromMap           
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 3
InGame: 19    53    -1
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    GoodyHutReward                     
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 10    196608    1623514478    -945185595
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    RouteAddedToMap                     
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 2
InGame: 35    24
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    CityPopulationChanged               
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 3
InGame: 12    196610    5
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    InfluenceGiven                     
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 2
InGame: 18    0
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    UnitEnterFormation                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 12    1572878    12    131073
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    Combat                             
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 1
InGame: table: 00000001D8DD1EA0
InGame: --------------- table: 00000001D8DD1EA0 ---------------
InGame:     954462304    false
InGame:     865706498    false
InGame:     432821635    false
InGame:     1431908133    table: 00000001D8DD1F40
InGame:             126272016    0
InGame:             -746205821    200
InGame:             853003252    1
InGame:             -958805242    0
InGame:             1930175143    0
InGame:             -1263136305    50
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DD2800
InGame:                     type    3
InGame:                     player    13
InGame:                     id    65536
InGame:             -1351684353    0
InGame:             -1779249298    table: 00000001D8DD1900
InGame:                     x    48
InGame:                     y    52
InGame:             -1306278355    15
InGame:             1838009406    0
InGame:             1116922831    0
InGame:     -1480090105    -1
InGame:     -1632097141    table: 00000001D8DD1FE0
InGame:             126272016    0
InGame:             -746205821    100
InGame:             853003252    1
InGame:             -958805242    59
InGame:             1930175143    20
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DD1D10
InGame:                     type    1
InGame:                     player    14
InGame:                     id    458755
InGame:             -1351684353    0
InGame:             -1779249298    table: 00000001D8DD23F0
InGame:                     x    49
InGame:                     y    54
InGame:             -1306278355    30
InGame:             1838009406    0
InGame:             1116922831    -1
InGame:     -278393875    false
InGame:     -1779249298    table: 00000001D8DD2850
InGame:             x    49
InGame:             y    54
InGame:     469286896    0
InGame:     433239030    0
InGame:     598597112    false
InGame:     493520281    table: 00000001D8DD1F90
InGame:             126272016    0
InGame:             -746205821    0
InGame:             853003252    -1
InGame:             -958805242    0
InGame:             1930175143    0
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DD1E50
InGame:                     type    0
InGame:                     player    -1
InGame:                     id    -1
InGame:             -1351684353    0
InGame:             -1779249298    table: 00000001D8DD28A0
InGame:                     x    -9999
InGame:                     y    -9999
InGame:             -1306278355    0
InGame:             1838009406    0
InGame:             1116922831    0
InGame:     -5828522    false
InGame:     -77002069    table: 00000001D8DD1A40
InGame:             x    -9999
InGame:             y    -9999
InGame:     -2102924904    784649805
InGame:     -247326915    -1
InGame:     705738904    0
InGame:     787125023    table: 00000001D8DD1B80
InGame:             126272016    0
InGame:             -746205821    0
InGame:             853003252    -1
InGame:             -958805242    0
InGame:             1930175143    0
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DD1CC0
InGame:                     type    0
InGame:                     player    -1
InGame:                     id    -1
InGame:             -1351684353    0
InGame:             -1779249298    table: 00000001D8DD2760
InGame:                     x    -9999
InGame:                     y    -9999
InGame:             -1306278355    0
InGame:             1838009406    0
InGame:             1116922831    0
InGame:
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    DistrictCombatChanged               
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 3
InGame: 0    13    65536
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    UnitDamageChanged                   
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 14    458755    59    39
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    Combat                             
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 1
InGame: table: 00000001D8DDB720
InGame: --------------- table: 00000001D8DDB720 ---------------
InGame:     954462304    false
InGame:     865706498    false
InGame:     432821635    false
InGame:     1431908133    table: 00000001D8DDBD60
InGame:             126272016    0
InGame:             -746205821    100
InGame:             853003252    -1
InGame:             -958805242    0
InGame:             1930175143    0
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DDBAE0
InGame:                     type    1
InGame:                     player    14
InGame:                     id    393218
InGame:             -1351684353    5
InGame:             -1779249298    table: 00000001D8DDCAD0
InGame:                     x    51
InGame:                     y    68
InGame:             -1306278355    15
InGame:             1838009406    0
InGame:             1116922831    0
InGame:     -1480090105    -1
InGame:     -1632097141    table: 00000001D8DDCE90
InGame:             126272016    0
InGame:             -746205821    100
InGame:             853003252    -1
InGame:             -958805242    86
InGame:             1930175143    26
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DDCEE0
InGame:                     type    1
InGame:                     player    13
InGame:                     id    1048587
InGame:             -1351684353    3
InGame:             -1779249298    table: 00000001D8DDC940
InGame:                     x    50
InGame:                     y    68
InGame:             -1306278355    20
InGame:             1838009406    0
InGame:             1116922831    -6
InGame:     -278393875    false
InGame:     -1779249298    table: 00000001D8DDCD00
InGame:             x    50
InGame:             y    68
InGame:     469286896    0
InGame:     433239030    0
InGame:     598597112    false
InGame:     493520281    table: 00000001D8DDBD10
InGame:             126272016    0
InGame:             -746205821    0
InGame:             853003252    -1
InGame:             -958805242    0
InGame:             1930175143    0
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DDB770
InGame:                     type    0
InGame:                     player    -1
InGame:                     id    -1
InGame:             -1351684353    0
InGame:             -1779249298    table: 00000001D8DDB7C0
InGame:                     x    -9999
InGame:                     y    -9999
InGame:             -1306278355    0
InGame:             1838009406    0
InGame:             1116922831    0
InGame:     -5828522    false
InGame:     -77002069    table: 00000001D8DDCF30
InGame:             x    -9999
InGame:             y    -9999
InGame:     -2102924904    784649805
InGame:     -247326915    -1
InGame:     705738904    0
InGame:     787125023    table: 00000001D8DDB810
InGame:             126272016    0
InGame:             -746205821    0
InGame:             853003252    -1
InGame:             -958805242    0
InGame:             1930175143    0
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DDB9F0
InGame:                     type    0
InGame:                     player    -1
InGame:                     id    -1
InGame:             -1351684353    0
InGame:             -1779249298    table: 00000001D8DDBA40
InGame:                     x    -9999
InGame:                     y    -9999
InGame:             -1306278355    0
InGame:             1838009406    0
InGame:             1116922831    0
InGame:
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    Combat                             
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 1
InGame: table: 00000001D8DBCAA0
InGame: --------------- table: 00000001D8DBCAA0 ---------------
InGame:     954462304    false
InGame:     865706498    true
InGame:     432821635    false
InGame:     1431908133    table: 00000001D8DBCF50
InGame:             126272016    0
InGame:             -746205821    100
InGame:             853003252    -1
InGame:             -958805242    75
InGame:             1930175143    16
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DBCFF0
InGame:                     type    1
InGame:                     player    14
InGame:                     id    458755
InGame:             -1351684353    0
InGame:             -1779249298    table: 00000001D8DBD310
InGame:                     x    47
InGame:                     y    55
InGame:             -1306278355    30
InGame:             1838009406    0
InGame:             1116922831    -6
InGame:     -1480090105    -1
InGame:     -1632097141    table: 00000001D8DBCA50
InGame:             126272016    0
InGame:             -746205821    100
InGame:             853003252    -1
InGame:             -958805242    122
InGame:             1930175143    46
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DBC870
InGame:                     type    1
InGame:                     player    13
InGame:                     id    131073
InGame:             -1351684353    6
InGame:             -1779249298    table: 00000001D8DBD270
InGame:                     x    47
InGame:                     y    54
InGame:             -1306278355    20
InGame:             1838009406    0
InGame:             1116922831    -8
InGame:     -278393875    false
InGame:     -1779249298    table: 00000001D8DBD0E0
InGame:             x    47
InGame:             y    54
InGame:     469286896    0
InGame:     433239030    0
InGame:     598597112    true
InGame:     493520281    table: 00000001D8DBC5F0
InGame:             126272016    0
InGame:             -746205821    0
InGame:             853003252    -1
InGame:             -958805242    0
InGame:             1930175143    0
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DBC460
InGame:                     type    0
InGame:                     player    -1
InGame:                     id    -1
InGame:             -1351684353    0
InGame:             -1779249298    table: 00000001D8DBCAF0
InGame:                     x    -9999
InGame:                     y    -9999
InGame:             -1306278355    0
InGame:             1838009406    0
InGame:             1116922831    0
InGame:     -5828522    false
InGame:     -77002069    table: 00000001D8DBCB40
InGame:             x    -9999
InGame:             y    -9999
InGame:     -2102924904    748940753
InGame:     -247326915    -1
InGame:     705738904    0
InGame:     787125023    table: 00000001D8DBCC30
InGame:             126272016    0
InGame:             -746205821    0
InGame:             853003252    -1
InGame:             -958805242    0
InGame:             1930175143    0
InGame:             -1263136305    0
InGame:             236175385    -1
InGame:             1472654640    table: 00000001D8DBD450
InGame:                     type    0
InGame:                     player    -1
InGame:                     id    -1
InGame:             -1351684353    0
InGame:             -1779249298    table: 00000001D8DBC1E0
InGame:                     x    -9999
InGame:                     y    -9999
InGame:             -1306278355    0
InGame:             1838009406    0
InGame:             1116922831    0
InGame:
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    UnitDamageChanged                   
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 13    1048587    86    60
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    UnitDamageChanged                   
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 13    131073    100    76
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    UnitKilledInCombat                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 13    131073    14    458755
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    UnitKilledInCombat                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 13    1048587    14    524292
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    TradeRouteAddedToMap               
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 3
InGame: 15    10    71
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    TradeRouteActivityChanged           
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 5
InGame: 15    15    65536    15    131073
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    TechBoostTriggered                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 15    19    0    0
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    UnitKilledInCombat                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 63    7340143    15    1376258
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    CivicCompleted                     
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 3
InGame: 16    7    false
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    CivicCompleted                     
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 3
InGame: 17    7    false
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    CultureYieldChanged                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 1
InGame: 18
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    CivicCompleted                     
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 3
InGame: 19    7    false
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    TechBoostTriggered                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 4
InGame: 20    17    0    0
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    BuildingAddedToMap                 
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 6
InGame: 55    73    6    20    0    0
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    ResearchQueueChanged               
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 1
InGame: 27
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    GovernmentChanged                   
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 2
InGame: 28    1
InGame: ------------------------------------------------------------------------------------ End >
InGame:
InGame:  Event :    CityFocusChanged                   
InGame: ---------------------------------------------------------------------------------- Start <
InGame: num arguments = 2
InGame: 28    65536
Some arguments are obvious, some others will require trial/error, and I'm pretty sure the SDK will be out before we know each of them...

The panel is simple, 2 buttons, one to add the listener ("Listen all Events"), one to remove them ("Remove Listen"), and there is a simple function and check to limit the number of time the events arguments are printed to the log (like for civ5, some are called a lot):

Code:
function maxCall()
    return 5
end

Change "5" to whatever you need, you can reset the counter by using the remove button and then the add button.

And here is a small example of what's I've noted from the table returned by Events.Combat:
https://docs.google.com/spreadsheets/d/1P0f4ZninrDyzm981oEIBsnDyOHc93rYofRfXU1wAGHA/edit?usp=sharing
 

Attachments

  • Events InGame.zip
    13.9 KB · Views: 455
  • ListenToEvents.zip
    12.4 KB · Views: 196
Last edited:
Some arguments are obvious, some others will require trial/error, and I'm pretty sure the SDK will be out before we know each of them...
Optimism is cool :cooool:

I really hope you are right about this
 
Two questions:

I need to access the current progress and cost of the current Tech and Civic in a <Gameplayscripts> context for my first Lua mod. The tech part of my script works fine, using GetResearchProgress() and GetResearchCost(). But the civic part doesn't work, because apparently GetCulturalProgress() doesn't exist in the <Gameplayscripts> context. I can use GetTurnsLeftOnCurrentCivic() along with GetCultureYield() and GetCultureCost(), but this is only approximately correct. Is there some other kind of workaround I can use to grab the exact amount of civics progress?

I want my script to trigger at the start of the player turn, but after the default start-of-turn events in the game. The TurnBegin and LocalPlayerTurnBegin events seem to trigger before the in-game events. Using PlayerTurnActivated seems to work for me, but it triggers 10-15 times each turn during the first few turns of a game. I proceed with my script when the argument to PlayerTurnActivated is zero, that seems to indicate the start of the turn. But I'm worried that I'm adding a listener to an event that may trigger a zillion times per turn during the late game. Is there a more appropriate event I can listen to that only triggers once per turn?
 
Last edited:
Code:
--===========================================================================
--	Finish the progress on the current Civic the Player is 'Researching'
--===========================================================================

function FinishCurrentCivicProgress(pPlayer, iPlayer)
	local pCulture = pPlayer:GetCulture()
	if pCulture ~= nil then
		local iCurrentCivicID = pCulture:GetProgressingCivic();
		if (iCurrentCivicID ~= nil) and (iCurrentCivicID >= 0) then
			local iCivicCost = pCulture:GetCultureCost(iCurrentCivicID)
			local iCurrentProgress = pCulture:GetCulturalProgress(iCurrentCivicID)
			pCulture:ChangeCurrentCulturalProgress(iCivicCost - iCurrentProgress + 1)
			return true
		else
			PrintToLog("FinishCurrentCivicProgress: cannot access the current civic research item, returning nil")
			return nil
		end
	else
		PrintToLog("FinishCurrentCivicProgress: invalid player culture table for player # " .. iPlayer .. ", returning nil")
		return nil
	end
end
I am "calling" the function in this portion of a gameplay script:
Code:
--=============================
--	Game Loading Actions
--=============================

if Game.GetCurrentGameTurn() <= 1 then
	local iPlayer = 0
	local pPlayer = Players[iPlayer]
	if tStartingExtraYields["YIELD_CULTURE"] then
		if tStartingExtraYields["YIELD_CULTURE"] >= 100 then
			FinishCurrentCivicProgress(pPlayer, iPlayer)
		elseif tStartingExtraYields["YIELD_CULTURE"] > 0 then
			ChangeCurrentCivicProgress(tStartingExtraYields["YIELD_CULTURE"], pPlayer, iPlayer)
		end
	end
end
So far as I know the method "GetCulturalProgress" still works in a gameplay script.

Note that the PrintToLog statements control whether to print to the lua.log the specified message when I have a debugging flag set to true at the top of the script:
Code:
local bDebugPrint = true
-- ==========================
--  Debug printing routine
-- ==========================

function PrintToLog(sMessage)
	if bDebugPrint then
		print(sMessage)
	end
end
 
I want my script to trigger at the start of the player turn, but after the default start-of-turn events in the game. The TurnBegin and LocalPlayerTurnBegin events seem to trigger before the in-game events. Using PlayerTurnActivated seems to work for me, but it triggers 10-15 times each turn during the first few turns of a game. I proceed with my script when the argument to PlayerTurnActivated is zero, that seems to indicate the start of the turn. But I'm worried that I'm adding a listener to an event that may trigger a zillion times per turn during the late game. Is there a more appropriate event I can listen to that only triggers once per turn?
The event fires at the "beginning" of the turn for each player in succession. It will fire for every player in the game in sequence, and is normal behavior for this game event. Argument #1 being passed to any function subscribed to the PlayerTurnActivated event will be the player ID# of the player who is currently taking their turn, Human, AI, CS, Barbs. "0" is by Firaxis convention the ID# of the human player in a single-player game.

PlayerTurnActivated also appears to fire for the human (Player # 0) the instant the human player hits the little globe thingie on the Dawn Of Man screen.

Multiplayer and simultaneous turns I have no experience by experimentation as to how the game engine handles firing order of the event for the different players.
 
Top Bottom