Lua Reference

From Civilization V Wiki

Jump to: navigation, search

This section lists the Lua files contained in the core Assets directory. Each section is named for the folder that contains the files and subfolders. Where it makes sense, each directory has an overall description of the types of files it contains. Each file has a brief description if necessary and links to its own page for more details. Most file lists are alphabetized, but some are grouped by related purpose.

This page does not describe the classes and functions exposed to Lua by the SDK. Perhaps we need three pages: SDK (Game Objects), Utilities, and UI.

For the list of game objects available, see Lua Game Objects.

For the list of events, see Lua Game Events.

Contents

Automation

Provides examples of using the Automation Lua object to run autoplay games.

Each module has the same structure. SetupGame() sets up the game and number of turns, and OnEndFrameEvent() dumps out profiling or other stats after each frame and exits the game when the setup turn limit is reached. These are followed by top-level code that sets the event callback, calls SetupGame(), and fires a StartGame event.

Gameplay

Miscellaneous utilities and map generator modules.

  • FLuaVector.lua
    Functions to create tables containing two to four coordinates named x, y, z, and w: Vector2(x, y), Vector3(x, y, z), Vector4(x, y, z, w). Color(r, g, b, a) is an alias for Vector4(). Also VecAdd(v1, v2) and VecSubtract(v1, v2).
  • GameplayUtilities.lua
    GameplayUtilities.GetLocalizedLeaderTitle(Player) returns the formal name and title of a leader.
  • ModBrowserUtilities.lua
    Functions for handling mod download state and providing localized messages in the mod browser.

Map Generator Core

These are used by the map scripts in Maps.

Landmass Type Generators

These are used by the map scripts in Maps.

Maps

Contains the built-in map scripts and some custom maps. See [#Gameplay_/_Lua] for the map generator core and scripts related to generating maps.

Tutorial

Controls the in-game tutorial.

UI

Builds the entire game user interface including screens, overlays, menus, popups, hover text, etc.

This section should probably be moved to its own page as it will get very, very large and is somewhat unrelated to the above.

Three folders contain a single Lua and XML file pair each.

FrontEnd

Contains the screens and menus that exist outside of an active game: main menu, game settings, multiplayer lobby, mod browsing, etc.

GameSetup

Modding

Multiplayer

InGame

Contains the screens, menus, and popups for the entire in-game interface: main screen, city screen, advisors, tech tree, strategy layer, diplomacy, trading, etc.

CityView

LeaderHead

Menus

Popups

PopupsGeneric

TechTree

WorldView

Personal tools