LuaEvents (Civ5 Type)

From Civilization Modding Wiki
Jump to: navigation, search

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

Base game Gods & Kings ___________________________
Check.png Check.png Star.png Speech.png AdditionalInformationDropdownGatherEntries(table(int => table) additionalEntries)
Check.png Check.png Star.png Speech.png AdditionalInformationDropdownSortEntries(table(int => table) entries)
Check.png Check.png Star.png Speech.png AdvisorButtonEvent(MouseType button)

C

Base game Gods & Kings ___________________________
Check.png Check.png Star.png Speech.png ChatShow(int chatOpen)

E

Base game Gods & Kings ___________________________
Check.png Check.png Star.png Speech.png EnemyPanelHide(bool isHide)

M

Base game Gods & Kings ___________________________
Check.png Check.png Star.png Speech.png ModBrowserSetDeleteButtonState(..., bool arg1, string arg2 = nil)
Check.png Check.png Star.png Speech.png ModBrowserSetDownloadButtonState(bool arg0, bool arg1)
Check.png Check.png Star.png Speech.png ModBrowserSetLikeButtonState(bool arg0, bool arg1)
Check.png Check.png Star.png Speech.png ModBrowserSetReportButtonState(bool arg0, bool arg1)

O

Base game Gods & Kings ___________________________
Check.png Check.png Star.png Speech.png OnModBrowserDeleteButtonClicked()
Check.png Check.png Star.png Speech.png OnModBrowserDownloadButtonClicked()
Check.png Check.png Star.png Speech.png OnModsBrowserNavigateBack(table args)
Check.png Check.png Star.png Speech.png OnRecommendationCheckChanged(bool value)

P

Base game Gods & Kings ___________________________
Check.png Check.png Star.png Speech.png PasswordChanged(PlayerID player)
Check.png Check.png Star.png Speech.png ProductionPopup(bool isHide)

R

Base game Gods & Kings ___________________________
Check.png Check.png Star.png Speech.png ReplayViewer_LoadReplay(unknown replayFile)
Check.png Check.png Star.png Speech.png RequestRefreshAdditionalInformationDropdownEntries()

S

Base game Gods & Kings ___________________________
Question.png Check.png Star.png Speech.png ScenarioPlayerStatusChanged(table(PlayerID => table(string => table)) tPlayerStatus, PlayerID turn, int year, PlayerID playerAboutToWin, int turnsControlHeld)
Question.png Check.png Star.png Speech.png ScenarioUnitTiersChanged(table(string => PlayerID) tUnitTiers)
Check.png Check.png Star.png Speech.png SetCivNameEditSlot(PlayerID slot)

T

Base game Gods & Kings ___________________________
Check.png Check.png Star.png Speech.png TryDismissTutorial(string tutorialID)
Check.png Check.png Star.png Speech.png 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.

Base game Gods & Kings ___________________________
CheckButZero.png CheckButZero.png Star.png Speech.png Question-blue.png Add
CheckButZero.png CheckButZero.png Star.png Speech.png Question-blue.png Call
CheckButZero.png CheckButZero.png Star.png Speech.png Question-blue.png Count
CheckButZero.png CheckButZero.png Star.png Speech.png Question-blue.png Remove
CheckButZero.png CheckButZero.png Star.png Speech.png Question-blue.png 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.