Events.SerialEventImprovementCreated (Civ5 API)

From Civilization Modding Wiki
Revision as of 18:48, 19 September 2012 by DonQuich (talk | contribs) (Bot update)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This page is a part of the Lua and UI Reference (Civ5).


Function.png This function is a member of Events.

This is a static method, invoke it with a dot.


This event is triggered whenever an improvement appears on a player's map — not when an improvement is created on the general game map. This will be the result of an improvement being created on a tile already been discovered by the active player, or a tile being discovered that already hosts an improvement. Barbarian camps and ancient ruins count as improvements, as indexed in the Improvements table. In the course of building an improvement in the standard game, this event will fire twice, once when the game places the graphic for the improvement in progress of being built, and then again when the improvement is built and the graphic changes to indicate that. The GetImprovementType method on a Plot object, however, will only return improvements that are complete.


Usage

void Events.SerialEventImprovementCreated(float hexX, int hexY, ArtStyleType continent1, ArtStyleType continent2, PlayerID player, int createImprovementType, ImprovementType createImprovementRRType, int createImprovementEra, int createImprovementState, unknown ImprovementEra = nil)


Event Type

Regular event: you can subscribe to it through Events.SerialEventImprovementCreated.Add(<function handler>) or invoke it directly through Events.SerialEventImprovementCreated(<arguments list>).

Parameters

hexX: No description available.
hexY: Hex y-coordinate of the tile the road was built on which can be converted to map grid coordinates with the ToGridFromHex function (see example)
continent1: These values appear to always be the same and also seem to refer to the continent on which the improvement was built. Different land masses will have different numbers corresponding to their graphic set, and oceans will be marked as 0.
continent2: No description available.
player: No description available.
createImprovementType: No description available.
createImprovementRRType: No description available.
createImprovementEra: No description available.
createImprovementState: No description available.
ImprovementEra: No description available.


Examples

function onImprovementCreated(iHexX, iHexY, iContinent1, iContinent2)
local pPlot = Map.GetPlot(ToGridFromHex(iHexX, iHexY))
local sImprovement = Map.GetImprovementType() > -1 and GameInfo.Improvements{Map.GetImprovementType()}().Type or "Improvement in progress"
local plotOwner = pPlot:GetOwner() > -1 and Players[pPlot:GetOwner()]:GetName() or "nobody"
print(string.format("%s built on tile %d, %d by player %d. Plot owned by %s", sImprovement, pPlot:GetX(), pPlot:GetY(), iPlayerID, plotOwner))
end
Events.SerialEventImprovementCreated.Add(onImprovementCreated)


Source code samples

Redundant occurences have been removed.

DebugMode.lua

UI/InGame/DebugMode.lua
0452
Events.SerialEventImprovementCreated( iHexX, iHexY, continent,   continent,     playerID,   g_iCreateImprovementType, g_iCreateImprovementRRType, g_iCreateImprovementEra, g_iCreateImprovementState );


TutorialChecks.lua

Tutorial/TutorialChecks.lua
2714
Events.SerialEventImprovementCreated.Add( OnImprovementCreated );



The initial version of this page was created by the Civ5 API Bot, see the Civ5 API Reference FAQ. Some of the texts come from the 2kgames' wiki and most of code samples are copyrighted to Firaxis.
Functions' signatures were either copied from the 2kgames' wiki, or infered from the Lua source files and the binaries. Errors are possible.
Contributors may find help in the Contributors guide to the Civ5 API.