LuaEvents (Civ5 Type)

From Civilization Modding Wiki
Revision as of 15:20, 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).


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 ___________________________
AdditionalInformationDropdownGatherEntries(table(int => table) additionalEntries)
AdditionalInformationDropdownSortEntries(table(int => table) entries)
AdvisorButtonEvent(MouseType button)

C

Base game Gods & Kings ___________________________
ChatShow(int chatOpen)

E

Base game Gods & Kings ___________________________
EnemyPanelHide(bool isHide)

M

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

O

Base game Gods & Kings ___________________________
OnModBrowserDeleteButtonClicked()
OnModBrowserDownloadButtonClicked()
OnModsBrowserNavigateBack(table args)
OnRecommendationCheckChanged(bool value)

P

Base game Gods & Kings ___________________________
PasswordChanged(PlayerID player)
ProductionPopup(bool isHide)

R

Base game Gods & Kings ___________________________
ReplayViewer_LoadReplay(unknown replayFile)
RequestRefreshAdditionalInformationDropdownEntries()

S

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

T

Base game Gods & Kings ___________________________
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.

Base game Gods & Kings ___________________________
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.