Events.SerialEventRoadCreated (Civ5 API)
This page is a part of the Lua and UI Reference (Civ5).
This function is a member of Events. This is a static method, invoke it with a dot. |
This event is triggered whenever a route is built (triggers on railroads despite the name). The tile must have been discovered by the active player but doesn't have to be visible. This also triggers when a new city is founded, which immediately builds a road and railroad on the spot.
Usage
void Events.SerialEventRoadCreated(int hexX, int hexY, PlayerID player, int routeType)
Event Type
- Regular event: you can subscribe to it through
Events.SerialEventRoadCreated.Add(<function handler>)
or invoke it directly throughEvents.SerialEventRoadCreated(<arguments list>)
.
Parameters
hexX: Hex x-coordinate of the tile the road was built on which can be converted to map grid coordinates with the ToGridFromHex function (see example) 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) player: the ID of the player who built the road routeType: the ID of the route type that was built
Examples
function onRoadCreated(iHexX, iHexY, iPlayerID, iRouteType)
local pPlot = Map.GetPlot(ToGridFromHex(iHexX, iHexY))
local plotOwner = pPlot:GetOwner() > -1 and Players[pPlot:GetOwner()]:GetName() or "nobody"
print(string.format("Route of type %d built on tile %d, %d by player %d. Plot owned by %s", iRouteType, pPlot:GetX(), pPlot:GetY(), iPlayerID, plotOwner))
end
Events.SerialEventRoadCreated.Add(onRoadCreated)
Source code samples
DebugMode.lua
UI/InGame/DebugMode.lua
0428
|
Events.SerialEventRoadCreated( g_iHexX, g_iHexY, g_iCurrPlayer, 0 ); |
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.