The civ library: Difference between revisions

From Scenario League Wiki
Jump to navigationJump to search
(Copied The Civ Library Information)
 
m (Added to category lua resources)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Lua Resources]]
Back to [[TOTPP Functions]]
----
Follow the link in the function name for additional information about that function, if it is available.
Follow the link in the function name for additional information about that function, if it is available.


[[addImprovement]]


civ.addImprovement(city, improvement)
[[civ.addImprovement|addImprovement]]
 
<code>civ.addImprovement(city, improvement)</code>


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




[[canEnter]]
[[civ.canEnter|canEnter]]


civ.canEnter(unittype, tile) -> boolean
<code>civ.canEnter(unittype, tile) -> boolean</code>


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




[[captureCity]]
[[civ.captureCity|captureCity]]


civ.captureCity(city, tribe)
<code>civ.captureCity(city, tribe)</code>


Captures city `city` for tribe `tribe`.
Captures city `city` for tribe `tribe`.




[[createCity]]
[[civ.createCity|createCity]]


civ.createCity(tribe, tile) -> city
<code>civ.createCity(tribe, tile) -> city</code>


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




[[createUnit]]
[[civ.createUnit|createUnit]]


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


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




[[deleteCity]]
[[civ.deleteCity|deleteCity]]


civ.deleteCity(city)
<code>civ.deleteCity(city)</code>


Deletes city `city` from the game.
Deletes city `city` from the game.




[[deleteUnit]]
[[civ.deleteUnit|deleteUnit]]


civ.deleteUnit(unit)
<code>civ.deleteUnit(unit)</code>


Deletes unit `unit` from the game.
Deletes unit `unit` from the game.




[[destroyWonder]]
[[civ.destroyWonder|destroyWonder]]


civ.destroyWonder(wonder)
<code>civ.destroyWonder(wonder)</code>


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




[[enableTechGroup]]
[[civ.enableTechGroup|enableTechGroup]]


civ.enableTechGroup(tribe, techgroup, value)
<code>civ.enableTechGroup(tribe, techgroup, value)</code>


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`.
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|endGame]]


civ.endGame(endscreens=false)
<code>civ.endGame(endscreens=false)</code>


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




[[getActiveUnit]]
[[civ.getActiveUnit|getActiveUnit]]


civ.getActiveUnit() -> unit
<code>civ.getActiveUnit() -> unit</code>


Returns the currently active unit.
Returns the currently active unit.




[[getCity]]
[[civ.getCity|getCity]]


civ.getCity(id) -> city
<code>civ.getCity(id) -> city</code>


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




[[getCurrentTile]]
[[civ.getCurrentTile|getCurrentTile]]


civ.getCurrentTile() -> tile
<code>civ.getCurrentTile() -> tile</code>


Returns the currently selected tile.
Returns the currently selected tile.




[[getCurrentTribe]]
[[civ.getCurrentTribe|getCurrentTribe]]


civ.getCurrentTribe() -> tribe
<code>civ.getCurrentTribe() -> tribe</code>


Returns the currently active tribe.
Returns the currently active tribe.




[[getGameYear]]
[[civ.getGameYear|getGameYear]]


civ.getGameYear() -> integer
<code>civ.getGameYear() -> integer</code>


Returns the current game year.
Returns the current game year.




[[getImprovement]]
[[civ.getImprovement|getImprovement]]


civ.getImprovement(id) -> improvement
<code>civ.getImprovement(id) -> improvement</code>


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




[[getMapDimensions]]
[[civ.getMapDimensions|getMapDimensions]]


civ.getMapDimensions() -> width, height, number_of_maps
<code>civ.getMapDimensions() -> width, height, number_of_maps</code>


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




[[getPlayerTribe]]
[[civ.getPlayerTribe|getPlayerTribe]]


civ.getPlayerTribe() -> tribe
<code>civ.getPlayerTribe() -> tribe</code>


Returns the player's tribe.
Returns the player's tribe.




[[getTech]]
[[civ.getTech|getTech]]


civ.getTech(id) -> tech
<code>civ.getTech(id) -> tech</code>


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




[[getTile]]
[[civ.getTile|getTile]]


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


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




[[getToTDir]]
[[civ.getToTDir|getToTDir]]


civ.getToTDir() -> string
<code>civ.getToTDir() -> string</code>


Returns the absolute path of the ToT installation directory.
Returns the absolute path of the ToT installation directory.




[[getTribe]]
[[civ.getTribe|getTribe]]


civ.getTribe(id) -> tribe
<code>civ.getTribe(id) -> tribe</code>


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




[[getTurn]]
[[civ.getTurn|getTurn]]


civ.getTurn() -> integer
<code>civ.getTurn() -> integer</code>


Returns the current turn number.
Returns the current turn number.




[[getUnit]]
[[civ.getUnit|getUnit]]


civ.getUnit(id) -> integer
<code>civ.getUnit(id) -> integer</code>


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




[[getUnitType]]
[[civ.getUnitType|getUnitType]]


civ.getUnitType(id) -> unittype
<code>civ.getUnitType(id) -> unittype</code>


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




[[getWonder]]
[[civ.getWonder|getWonder]]


civ.getWonder(id) -> wonder
<code>civ.getWonder(id) -> wonder</code>


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




[[giveTech]]
[[civ.giveTech|giveTech]]


civ.giveTech(tribe, tech)
<code>civ.giveTech(tribe, tech)</code>


Gives tech `tech` to tribe `tribe`.
Gives tech `tech` to tribe `tribe`.




[[hasImprovement]]
[[civ.hasImprovement|hasImprovement]]


civ.hasImprovement(city, improvement)
<code>civ.hasImprovement(city, improvement)</code>


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




[[hasTech]]
[[civ.hasTech|hasTech]]


civ.hasTech(tribe, tech) -> boolean
<code>civ.hasTech(tribe, tech) -> boolean</code>


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




[[isCity]]
[[civ.isCity|isCity]]


civ.isCity(object) -> boolean
<code>civ.isCity(object) -> boolean</code>


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




[[isImprovement]]
[[civ.isImprovement|isImprovement]]


civ.isImprovement(object) -> boolean
<code>civ.isImprovement(object) -> boolean</code>


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




[[isLeader]]
[[civ.isLeader|isLeader]]


civ.isLeader(object) -> boolean
<code>civ.isLeader(object) -> boolean</code>


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




[[isTech]]
[[civ.isTech|isTech]]


civ.isTech(object) -> boolean
<code>civ.isTech(object) -> boolean</code>


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




[[isTile]]
[[civ.isTile|isTile]]


civ.isTile(object) -> boolean
<code>civ.isTile(object) -> boolean</code>


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




[[isTribe]]
[[civ.isTribe|isTribe]]


civ.isTribe(object) -> boolean
<code>civ.isTribe(object) -> boolean</code>


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




[[isUnit]]
[[civ.isUnit|isUnit]]


civ.isUnit(object) -> boolean
<code>civ.isUnit(object) -> boolean</code>


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




[[isUnitType]]
[[civ.isUnitType|isUnitType]]


civ.isUnitType(object) -> boolean
<code>civ.isUnitType(object) -> boolean</code>


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




[[isWonder]]
[[civ.isWonder|isWonder]]


civ.isWonder(object) -> boolean
<code>civ.isWonder(object) -> boolean</code>


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




[[iterateCities]]
[[civ.iterateCities|iterateCities]]


civ.iterateCities() -> iterator
<code>civ.iterateCities() -> iterator</code>


Returns an iterator yielding all cities in the game.
Returns an iterator yielding all cities in the game.




[[iterateUnits]]
[[civ.iterateUnits|iterateUnits]]


civ.iterateUnits() -> iterator
<code>civ.iterateUnits() -> iterator</code>


Returns an iterator yielding all units in the game.
Returns an iterator yielding all units in the game.




[[killTribe]]
[[civ.killTribe|killTribe]]


civ.killTribe(tribe)
<code>civ.killTribe(tribe)</code>


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




[[makeAggression]]
[[civ.makeAggression|makeAggression]]


civ.makeAggression(who, whom)
<code>civ.makeAggression(who, whom)</code>


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




[[playMusic]]
[[civ.playMusic|playMusic]]


civ.playMusic(trackNo or filename)
<code>civ.playMusic(trackNo or filename)</code>


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.
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|playSound]]


civ.playSound(filename)
<code>civ.playSound(filename)</code>


Plays the sound file given by `filename`.
Plays the sound file given by `filename`.




[[playVideo]]
[[civ.playVideo|playVideo]]


civ.playVideo(filename)
<code>civ.playVideo(filename)</code>


Plays the video file given by `filename`.
Plays the video file given by `filename`.




[[removeImprovement]]
[[civ.removeImprovement|removeImprovement]]


civ.removeImprovement(city, improvement)
<code>civ.removeImprovement(city, improvement)</code>


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




[[sleep]]
[[civ.sleep|sleep]]


civ.sleep(milliseconds)
<code>civ.sleep(milliseconds)</code>


Sleeps for the given number of milliseconds.
Sleeps for the given number of milliseconds.




[[takeTech]]
[[civ.takeTech|takeTech]]


civ.takeTech(tribe, tech, collapse=false)
<code>civ.takeTech(tribe, tech, collapse=false)</code>


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.
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|teleportUnit]]


civ.teleportUnit(unit, tile)
<code>civ.teleportUnit(unit, tile)</code>


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`.
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`.

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`.