Events.SerialEventHexHighlight (Civ5 API)

From Civilization Modding Wiki
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 every time a hex is highlighted by the UI. Can be invoked from the Lua side, which highlights a hex and is the common usage. If a highlight style is given, it can be cleared again by using ClearHexHighlightStyle or ClearHexHighlights


Usage

void Events.SerialEventHexHighlight(Vector2 hex, bool highlight, Vector4 highlightColor, string highlightStyle)


Event Type

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

Parameters

hex: Hex coordinates of the tile to highlight. Can be created by using the Vector2(iHexX, iHexY) constructor when including FLuaVector.lua (see example)
highlight: If true, highlight, if false, remove highlight
highlightColor: The color to highlight in. Can be created by using the Vector4(r, g, b, a) constructor when including FLuaVector.lua (see example). Only allows certain colors. Known colors to work: (1,0,0,1), (0,1,0,1), (0,0,1,1), (0,0,1,0.25), (1,1,0,1), (1,0,1,1), (0.5,0.5,0.5,1)
highlightStyle: Use a custom highlighting style, in which case highlightColor is irrelevant. Known highlighting styles are: "MovementRangeBorder", "AMRBorder", "FireRangeBorder", "ValidFireTargetBorder", "GroupBorder"


Examples

include( "FLuaVector" );
-- highlight a hex when it changes ownership
function onHexCultureChanged(iHexX, iHexY, iPlayerID, bUnknown)
Events.SerialEventHexHighlight(Vector2(iHexX, iHexY), true, Vector4(1, 0.5, 0, 1))
end
Events.SerialEventHexCultureChanged.Add(onHexCultureChanged)


Source code samples

Redundant occurences have been removed.

Bombardment.lua

UI/InGame/Bombardment.lua
0072
Events.SerialEventHexHighlight( hexID, true, highlightColor, "FireRangeBorder" );
0073
Events.SerialEventHexHighlight( hexID, true, redColor, "ValidFireTargetBorder");


CityView.lua

UI/InGame/CityView/CityView.lua
1824
Events.SerialEventHexHighlight( ToHexFromGrid( Vector2( plot:GetX(), plot:GetY() ) ), false, Vector4( 0.0, 1.0, 0.0, 1 ) );
1861
Events.SerialEventHexHighlight( ToHexFromGrid( Vector2( aPurchasablePlots[i]:GetX(), aPurchasablePlots[i]:GetY() ) ), true, Vector4( 1.0, 0.0, 1.0, 1 ) );


DebugMode.lua

UI/InGame/DebugMode.lua
0037
Events.SerialEventHexHighlight( Vector2( g_iHexX, g_iHexY ), false, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
0420
Events.SerialEventHexHighlight( Vector2( g_iHexX, g_iHexY ), true, Vector4( 0.5, 0.5, 0.5, 1.0 ) );


InGame.lua

UI/InGame/InGame.lua
0305
Events.SerialEventHexHighlight( hexID, false, workerSuggestHighlightColor, genericUnitHexBorder );
0423
Events.SerialEventHexHighlight( hexID, true, Vector4( 1.0, 1.0, 0.0, 1 ), genericUnitHexBorder );
0464
Events.SerialEventHexHighlight( hexID, true, embarkColor, genericUnitHexBorder );
0490
Events.SerialEventHexHighlight( hexID, true, upgradeColor, genericUnitHexBorder );
0558
Events.SerialEventHexHighlight( hexID, true, turn2Color, "GroupBorder" );
0595
Events.SerialEventHexHighlight( hexID, true, turn1Color, pathBorderStyle );


InGame.lua (G&K)

DLC/Expansion/UI/InGame/InGame.lua
0689
Events.SerialEventHexHighlight( iHexID, true, vGiftTileImprovementColor, genericUnitHexBorder );


WorldView.lua

UI/InGame/WorldView/WorldView.lua
0765
Events.SerialEventHexHighlight( Vector2( i, j ), true, turn1Color, attackPathBorderStyle );
0767
Events.SerialEventHexHighlight( Vector2( i, j ), true, turn1Color, pathBorderStyle );



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.