LUA Events

Gleb Bazov

Warlord
Joined
Feb 13, 2017
Messages
176
For anyone interested, here are a few LUA events and parameters I've been able to identify:

Code:
function OnNationalParkAdded( iPlayerID, iParkRootX, iParkRootY )
-- main chunk --
Events.NationalParkAdded.Add( OnNationalParkAdded );

-- iParkRootX: coordinate X of the National Park's tower (the lower end of the vertical diamond)
-- iParkRootX: coordinate Y of the National Park's tower (the lower end of the vertical diamond)

--====================================================================================================================

function OnPlotYieldChanged( iPlotX, iPlotY )
-- main chunk --
Events.PlotYieldChanged.Add( OnPlotYieldChanged );

--====================================================================================================================

function OnTreasuryChanged( iPlayerID, iGoldPerTurn, iCurrentTreasury)
-- main chunk --
Events.TreasuryChanged.Add( OnTreasuryChanged );

-- iGoldPerTurn refers to the player's gold income per turn, and not to the change in the player's treasury
-- event fires every time there is a change in the player's treasury, but does not yield the quantum of the change itself

--====================================================================================================================

function OnUnitFormCorps( iPlayerID, iUnitID )
-- main chunk --
Events.UnitFormCorps.Add( OnUnitFormCorps );

--====================================================================================================================

function OnUnitFormArmy( iPlayerID, iUnitID )
-- main chunk --
Events.UnitFormArmy.Add( OnUnitFormArmy );

--====================================================================================================================

function UnitGreatPersonActivated( iUnitOwnerID, iUnitID, iGreatPersonClass, iGreatPersonType)
-- main chunk --
Events.UnitGreatPersonActivated.Add( UnitGreatPersonActivated );

-- iGreatPersonType refers to the index of the GreatPersonIndividuals table
-- iGreatPersonClass refers to the index of the GreatPersonClasses table

--====================================================================================================================

function UnitGreatPersonChanged( iPlayerID, iUnitID)
-- main chunk --
Events.UnitGreatPersonChanged.Add( UnitGreatPersonChanged );

--====================================================================================================================

function UnitMoveComplete( iPlayerID, iUnitID, iTerminusX, iTerminusY)
-- main chunk --
Events.UnitMoveComplete.Add( UnitMoveComplete );

-- fires every time a unit stops moving
-- for a multi-plot movement path, will fire only for the final destination plot on which the unit stops for that turn

--====================================================================================================================

function CityCommandStarted( iPlayerID, iCityID, iIntegerA, iIntegerB, Hash, iIntegerC )
-- main chunk --
Events.CityCommandStarted.Add( CityCommandStarted );

-- in the case of the human player's capital city, iIntegerB = iCityID
-- for other human player cities, iIntegerB differs from iCityID
-- in all fired events, iIntegerA and iIntegerC consistently print as 0
-- Hash appears to refer to the hash of the city command that triggers the event
-- The events does not seem to fire for non-human player cities where the human player has no visibility (or,
-- alternatively, the event does not fire for non-human player cities at all).

--====================================================================================================================

function CityTileOwnershipChanged( iPlayerID, iCityID )
-- main chunk --
Events.CityTileOwnershipChanged.Add( CityTileOwnershipChanged );

function DiplomacyDealEnacted( iFirstPlayerID, iSecondPlayerID )
-- main chunk --
Events.DiplomacyDealEnacted.Add( DiplomacyDealEnacted );

-- it is assumed that iFirstPlayerID refers to the player initiating the deal, while iSecondPlayerID is the player
-- accepting the deal, but insufficient testing done to rule out all possibilities

function DiplomacyDeclareWar( iFirstPlayerID, iSecondPlayerID )
--    iFirstPlayerID = player declaring war
--    iSecondPlayerID = player subject to the declaration of war
Events.DiplomacyDeclareWar.Add( DiplomacyDeclareWar );

function DiplomacySessionClosed( iPlayerID )
-- iPlayerID = player that responds to the diplomatic interaction
-- event fires on conclusion of a diplomatic exchange (refusal/acceptance of a deal, acknowledgement of war declaration)
Events.DiplomacySessionClosed.Add( DiplomacySessionClosed );

--DISTRICTS

function DistrictUnitsChanged( iPlayerID, iDistrictID )
-- iDistrictID refers to the district's object ID in the game
Events.DistrictUnitsChanged.Add( DistrictUnitsChanged );

function DistrictAddedToMap( iPlayerID, iDistrictID, iCityID, iDistrictX, iDistrictY, iDistrictType, HashA, HashB, iPercentComplete, iAppealRating, iIntegerB )
-- iCityID = 65536 is the same for the capital city ID of every player (major and minor)
-- iCityID = iDistrictID for any City Center District
-- iDistrictType refers to the index of the Districts table
-- iPercentComplete is always 100 for City Centers and DISTRICT_WONDERs, and 0 for all other newly-placed districts
-- HashA is always the same: 440626330 for the human player and -1851407529 for non-human players
-- HashB remain the same and constant for any district of a given player
-- iAppealRating is the appeal of the district's tile
-- iIntegerB always prints as 0 in all (limited) tests
Events.DistrictAddedToMap.Add( DistrictAddedToMap );

function DistrictBuildProgressChanged( iPlayerID, iDistrictID, iCityID, iDistrictX, iDistrictY, iDistrictType, HashA, HashB, iPercentComplete, iAppealRating, iIntegerB )
-- iCityID = 65536 is the same for the capital city ID of every player (major and minor)
-- iCityID = iDistrictID for any City Center District
-- iDistrictType refers to the index of the Districts table
-- iPercentComplete changes as district build progress advances
-- HashA is always the same: 440626330 for the human player and -1851407529 for non-human players
-- HashB remain the same and constant for any district of a given player
-- iAppealRating is the appeal of the district's tile
-- iIntegerB always prints as 0 in all (limited) tests
Events.DistrictBuildProgressChanged.Add( DistrictBuildProgressChanged );

--POLICIES

function GovernmentPolicyChanged( iPlayerID, iPolicyID )
-- iPolicyID refers to the index of the Policies table
-- fires when changes are made to a player's policies and accepted
-- fires on acceptance of policy changes for the old (removed) and the new (adopted) policies
Events.GovernmentPolicyChanged.Add( GovernmentPolicyChanged );

function GovernmentChanged( iPlayerID, iGovernmentID )
-- iGovernmentID refers to the index of the Governments table
Events.GovernmentChanged.Add( GovernmentChanged );

-- GPs

function GreatPeopleTimelineChanged()
-- no parameters --
Events.GreatPeopleTimelineChanged.Add( GreatPeopleTimelineChanged );

function GreatWorkCreated( iPlayerID, iGreatWorkID, iLocationX, iLocationY, iMuseumID, iIndexOfGreatWorkInGame )
-- iLocationX and iLocationY refer to the location cooredinates of the Great Work
-- iIndexOfGreatWorkInGame refers to great work's order of appearance in the game
-- iMuseumID identifies the museum where the great work is placed
Events.GreatWorkCreated.Add( GreatWorkCreated );

function GreatWorkMoved( iOldPlayerID, iOldCityID, iNewPlayerID, iNewCityID, iMuseumID, iIndexOfGreatWorkInGame )
-- iMuseumID identifies the museum where the great work is placed
-- iIndexOfGreatWorkInGame refers to great work's order of appearance in the game
Events.GreatWorkMoved.Add( GreatWorkMoved );

--====================================================================================================================
--====================================================================================================================

-- GAME EVENTS --

function OnGreatPersonActivated( iUnitOwnerID, iUnitID, iGreatPersonType, iGreatPersonClass )
-- main chunk --
GameEvents.OnGreatPersonActivated.Add( OnGreatPersonActivated );

-- iGreatPersonType refers to the index of the GreatPersonIndividuals table
-- iGreatPersonClass refers to the index of the GreatPersonClasses table
 
Last edited:
Back
Top Bottom