LuaEvents (Civ5 Type)
This page is a part of the Lua and UI Reference (Civ5).
Usage
This object provides a mechanism modders can use to define and subscribe their own events. Those events are then visible in all contexts and all mods.
To define a custom event, you just need to subscribe it or invoke it, the event will then be lazily created and no error will be thrown.
The following example defines a "VelociratproAttack" event and subscribes a "RunAway" handler to it.
function RunAway(name)
print("Run "..name.."!")
end
LuaEvents.VelociraptorAttack.Add(RunAway)
-- Now fires the event. Prints "Run Forest!"
LuaEvents.VelociraptorAttack("Forest")
Events declared by the UI
Events can be subscribed by using LuaEvents.SomeEvent.Add(SomeFunction)
. Regular events can also be fired through a dot by using LuaEvents.SomeEvent(<args>)
. This will invoke all subscribers with the provided arguments.
A
|
AdditionalInformationDropdownGatherEntries(table(int => table) additionalEntries)
| ||||
|
AdditionalInformationDropdownSortEntries(table(int => table) entries)
| ||||
|
AdvisorButtonEvent(MouseType button)
|
C
|
ChatShow(int chatOpen)
|
E
|
EnemyPanelHide(bool isHide)
|
M
|
ModBrowserSetDeleteButtonState(..., bool arg1, string arg2 = nil)
| ||||
|
ModBrowserSetDownloadButtonState(bool arg0, bool arg1)
| ||||
|
ModBrowserSetLikeButtonState(bool arg0, bool arg1)
| ||||
|
ModBrowserSetReportButtonState(bool arg0, bool arg1)
|
O
|
OnModBrowserDeleteButtonClicked()
| ||||
|
OnModBrowserDownloadButtonClicked()
| ||||
|
(table args) | ||||
|
OnRecommendationCheckChanged(bool value)
|
P
|
PasswordChanged(PlayerID player)
| ||||
|
ProductionPopup(bool isHide)
|
R
|
ReplayViewer_LoadReplay(unknown replayFile)
| ||||
|
RequestRefreshAdditionalInformationDropdownEntries()
|
S
|
ScenarioPlayerStatusChanged(table(PlayerID => table(string => table)) tPlayerStatus, PlayerID turn, int year, PlayerID playerAboutToWin, int turnsControlHeld)
| ||||
|
ScenarioUnitTiersChanged(table(string => PlayerID) tUnitTiers)
| ||||
|
SetCivNameEditSlot(PlayerID slot)
|
T
|
TryDismissTutorial(string tutorialID)
| ||||
|
TryQueueTutorial(string tutorialID, bool highPriority)
|
Static Methods
Methods are functions that belong to an object. Static methods are invoked through a dot, as in LuaEvents.SomeMethod(<args>)
. When a dot is used the caller object is not implicitly provided as the first argument.
|
Add
| ||||
|
Call
| ||||
|
Count
| ||||
|
Remove
| ||||
|
RemoveAll
|
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.