The civ library: Difference between revisions

From Scenario League Wiki
Jump to navigationJump to search
(Put code tags in the code lines)
m (Added to category lua resources)
 
Line 1: Line 1:
[[Category:Lua Resources]]
Back to [[TOTPP Functions]]
Back to [[TOTPP Functions]]
----
----



Latest revision as of 20:08, 26 January 2019

Back to TOTPP Functions


Follow the link in the function name for additional information about that function, if it is available.


addImprovement

civ.addImprovement(city, improvement)

Adds city improvement `improvement` to city `city`.


canEnter

civ.canEnter(unittype, tile) -> boolean

Returns `true` if the given unittype can enter tile `tile`, `false` otherwise.


captureCity

civ.captureCity(city, tribe)

Captures city `city` for tribe `tribe`.


createCity

civ.createCity(tribe, tile) -> city

Creates a city owned by `tribe` at the location given by `tile`. Returns `nil` if a city could not be created.


createUnit

civ.createUnit(unittype, tribe, tile) -> unit

Creates a unit of type `unittype`, owned by `tribe`, at the location given by `tile`.


deleteCity

civ.deleteCity(city)

Deletes city `city` from the game.


deleteUnit

civ.deleteUnit(unit)

Deletes unit `unit` from the game.


destroyWonder

civ.destroyWonder(wonder)

Destroys wonder `wonder`, removing it from the game, and marking it as 'lost'.


enableTechGroup

civ.enableTechGroup(tribe, techgroup, value)

Sets the value of tech group `techgroup` (0-7) to value `value` (0-2, 0 = can research, can own, 1 = can't research, can own, 2 = can't research, can't own) for tribe `tribe`.


endGame

civ.endGame(endscreens=false)

Ends the game. `endscreens` is a boolean that determines whether to show the powergraph and related screens.


getActiveUnit

civ.getActiveUnit() -> unit

Returns the currently active unit.


getCity

civ.getCity(id) -> city

Returns the city with id `id`, or `nil` if it doesn't exist.


getCurrentTile

civ.getCurrentTile() -> tile

Returns the currently selected tile.


getCurrentTribe

civ.getCurrentTribe() -> tribe

Returns the currently active tribe.


getGameYear

civ.getGameYear() -> integer

Returns the current game year.


getImprovement

civ.getImprovement(id) -> improvement

Returns the improvement with id `id` (0-39), or `nil` if it doesn't exist.


getMapDimensions

civ.getMapDimensions() -> width, height, number_of_maps

Returns three integers, the width and height of the map and the number of maps.


getPlayerTribe

civ.getPlayerTribe() -> tribe

Returns the player's tribe.


getTech

civ.getTech(id) -> tech

Returns the tech with id `id` (0-99), or `nil` if it doesn't exist.


getTile

civ.getTile(x, y, z) -> tile

Returns the tile with coordinates `x`, `y`, `z`, or `nil` if it doesn't exist.


getToTDir

civ.getToTDir() -> string

Returns the absolute path of the ToT installation directory.


getTribe

civ.getTribe(id) -> tribe

Returns the tech with id `id` (0-7), or `nil` if it doesn't exist.


getTurn

civ.getTurn() -> integer

Returns the current turn number.


getUnit

civ.getUnit(id) -> integer

Returns the unit with id `id`, or `nil` if it doesn't exist.


getUnitType

civ.getUnitType(id) -> unittype

Returns the unit type with id `id`, or `nil` if it doesn't exist.


getWonder

civ.getWonder(id) -> wonder

Returns the wonder with id `id` (0-27), or `nil` if it doesn't exist.


giveTech

civ.giveTech(tribe, tech)

Gives tech `tech` to tribe `tribe`.


hasImprovement

civ.hasImprovement(city, improvement)

Returns `true` if city `city` has improvement `improvement`, `false` otherwise.


hasTech

civ.hasTech(tribe, tech) -> boolean

Returns `true` if tribe `tribe` has tech `tech`, `false` otherwise.


isCity

civ.isCity(object) -> boolean

Returns `true` if `object` is a city, `false` otherwise.


isImprovement

civ.isImprovement(object) -> boolean

Returns `true` if `object` is a city improvement, `false` otherwise.


isLeader

civ.isLeader(object) -> boolean

Returns `true` if `object` is a leader, `false` otherwise.


isTech

civ.isTech(object) -> boolean

Returns `true` if `object` is a tech, `false` otherwise.


isTile

civ.isTile(object) -> boolean

Returns `true` if `object` is a tile, `false` otherwise.


isTribe

civ.isTribe(object) -> boolean

Returns `true` if `object` is a tribe, `false` otherwise.


isUnit

civ.isUnit(object) -> boolean

Returns `true` if `object` is a unit, `false` otherwise.


isUnitType

civ.isUnitType(object) -> boolean

Returns `true` if `object` is a unit type, `false` otherwise.


isWonder

civ.isWonder(object) -> boolean

Returns `true` if `object` is a wonder, `false` otherwise.


iterateCities

civ.iterateCities() -> iterator

Returns an iterator yielding all cities in the game.


iterateUnits

civ.iterateUnits() -> iterator

Returns an iterator yielding all units in the game.


killTribe

civ.killTribe(tribe)

Removes tribe `tribe` from the game. All its cities and units are removed.


makeAggression

civ.makeAggression(who, whom)

Cancels any peace treaties between tribe `who` and tribe `whom`, and make `who` declare war on `whom`.


playMusic

civ.playMusic(trackNo or filename)

Plays CD track `trackNo`, or with the DirectShow music patch enabled, play the file given by `filename`, where `filename` is relative to the 'Music' directory.


playSound

civ.playSound(filename)

Plays the sound file given by `filename`.


playVideo

civ.playVideo(filename)

Plays the video file given by `filename`.


removeImprovement

civ.removeImprovement(city, improvement)

Removes city improvement `improvement` from city `city`.


sleep

civ.sleep(milliseconds)

Sleeps for the given number of milliseconds.


takeTech

civ.takeTech(tribe, tech, collapse=false)

Takes away tech `tech` from tribe `tribe`, the optional `collapse` parameter determines whether to take away all techs that have `tech` as a prerequisite somewhere up the tree.


teleportUnit

civ.teleportUnit(unit, tile)

Teleports (i.e. moves at no cost) unit `unit` to tile `tile`. The unit is moved regardless of whether it is a valid location for the unit. To check this, see `civ.canEnter` and `civlua.isValidUnitLocation`.