The civ library: Difference between revisions
mNo edit summary |
(Changed the names of the linked to pages, so that they are the full command (for clarity and to prevent conflicts)) |
||
Line 5: | Line 5: | ||
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|addImprovement]] | |||
civ.addImprovement(city, improvement) | civ.addImprovement(city, improvement) | ||
Line 12: | Line 13: | ||
[[canEnter]] | [[civ.canEnter|canEnter]] | ||
civ.canEnter(unittype, tile) -> boolean | civ.canEnter(unittype, tile) -> boolean | ||
Line 19: | Line 20: | ||
[[captureCity]] | [[civ.captureCity|captureCity]] | ||
civ.captureCity(city, tribe) | civ.captureCity(city, tribe) | ||
Line 26: | Line 27: | ||
[[createCity]] | [[civ.createCity|createCity]] | ||
civ.createCity(tribe, tile) -> city | civ.createCity(tribe, tile) -> city | ||
Line 33: | Line 34: | ||
[[createUnit]] | [[civ.createUnit|createUnit]] | ||
civ.createUnit(unittype, tribe, tile) -> unit | civ.createUnit(unittype, tribe, tile) -> unit | ||
Line 40: | Line 41: | ||
[[deleteCity]] | [[civ.deleteCity|deleteCity]] | ||
civ.deleteCity(city) | civ.deleteCity(city) | ||
Line 47: | Line 48: | ||
[[deleteUnit]] | [[civ.deleteUnit|deleteUnit]] | ||
civ.deleteUnit(unit) | civ.deleteUnit(unit) | ||
Line 54: | Line 55: | ||
[[destroyWonder]] | [[civ.destroyWonder|destroyWonder]] | ||
civ.destroyWonder(wonder) | civ.destroyWonder(wonder) | ||
Line 61: | Line 62: | ||
[[enableTechGroup]] | [[civ.enableTechGroup|enableTechGroup]] | ||
civ.enableTechGroup(tribe, techgroup, value) | civ.enableTechGroup(tribe, techgroup, value) | ||
Line 68: | Line 69: | ||
[[endGame]] | [[civ.endGame|endGame]] | ||
civ.endGame(endscreens=false) | civ.endGame(endscreens=false) | ||
Line 75: | Line 76: | ||
[[getActiveUnit]] | [[civ.getActiveUnit|getActiveUnit]] | ||
civ.getActiveUnit() -> unit | civ.getActiveUnit() -> unit | ||
Line 82: | Line 83: | ||
[[getCity]] | [[civ.getCity|getCity]] | ||
civ.getCity(id) -> city | civ.getCity(id) -> city | ||
Line 89: | Line 90: | ||
[[getCurrentTile]] | [[civ.getCurrentTile|getCurrentTile]] | ||
civ.getCurrentTile() -> tile | civ.getCurrentTile() -> tile | ||
Line 96: | Line 97: | ||
[[getCurrentTribe]] | [[civ.getCurrentTribe|getCurrentTribe]] | ||
civ.getCurrentTribe() -> tribe | civ.getCurrentTribe() -> tribe | ||
Line 103: | Line 104: | ||
[[getGameYear]] | [[civ.getGameYear|getGameYear]] | ||
civ.getGameYear() -> integer | civ.getGameYear() -> integer | ||
Line 110: | Line 111: | ||
[[getImprovement]] | [[civ.getImprovement|getImprovement]] | ||
civ.getImprovement(id) -> improvement | civ.getImprovement(id) -> improvement | ||
Line 117: | Line 118: | ||
[[getMapDimensions]] | [[civ.getMapDimensions|getMapDimensions]] | ||
civ.getMapDimensions() -> width, height, number_of_maps | civ.getMapDimensions() -> width, height, number_of_maps | ||
Line 124: | Line 125: | ||
[[getPlayerTribe]] | [[civ.getPlayerTribe|getPlayerTribe]] | ||
civ.getPlayerTribe() -> tribe | civ.getPlayerTribe() -> tribe | ||
Line 131: | Line 132: | ||
[[getTech]] | [[civ.getTech|getTech]] | ||
civ.getTech(id) -> tech | civ.getTech(id) -> tech | ||
Line 138: | Line 139: | ||
[[getTile]] | [[civ.getTile|getTile]] | ||
civ.getTile(x, y, z) -> tile | civ.getTile(x, y, z) -> tile | ||
Line 145: | Line 146: | ||
[[getToTDir]] | [[civ.getToTDir|getToTDir]] | ||
civ.getToTDir() -> string | civ.getToTDir() -> string | ||
Line 152: | Line 153: | ||
[[getTribe]] | [[civ.getTribe|getTribe]] | ||
civ.getTribe(id) -> tribe | civ.getTribe(id) -> tribe | ||
Line 159: | Line 160: | ||
[[getTurn]] | [[civ.getTurn|getTurn]] | ||
civ.getTurn() -> integer | civ.getTurn() -> integer | ||
Line 166: | Line 167: | ||
[[getUnit]] | [[civ.getUnit|getUnit]] | ||
civ.getUnit(id) -> integer | civ.getUnit(id) -> integer | ||
Line 173: | Line 174: | ||
[[getUnitType]] | [[civ.getUnitType|getUnitType]] | ||
civ.getUnitType(id) -> unittype | civ.getUnitType(id) -> unittype | ||
Line 180: | Line 181: | ||
[[getWonder]] | [[civ.getWonder|getWonder]] | ||
civ.getWonder(id) -> wonder | civ.getWonder(id) -> wonder | ||
Line 187: | Line 188: | ||
[[giveTech]] | [[civ.giveTech|giveTech]] | ||
civ.giveTech(tribe, tech) | civ.giveTech(tribe, tech) | ||
Line 194: | Line 195: | ||
[[hasImprovement]] | [[civ.hasImprovement|hasImprovement]] | ||
civ.hasImprovement(city, improvement) | civ.hasImprovement(city, improvement) | ||
Line 201: | Line 202: | ||
[[hasTech]] | [[civ.hasTech|hasTech]] | ||
civ.hasTech(tribe, tech) -> boolean | civ.hasTech(tribe, tech) -> boolean | ||
Line 208: | Line 209: | ||
[[isCity]] | [[civ.isCity|isCity]] | ||
civ.isCity(object) -> boolean | civ.isCity(object) -> boolean | ||
Line 215: | Line 216: | ||
[[isImprovement]] | [[civ.isImprovement|isImprovement]] | ||
civ.isImprovement(object) -> boolean | civ.isImprovement(object) -> boolean | ||
Line 222: | Line 223: | ||
[[isLeader]] | [[civ.isLeader|isLeader]] | ||
civ.isLeader(object) -> boolean | civ.isLeader(object) -> boolean | ||
Line 229: | Line 230: | ||
[[isTech]] | [[civ.isTech|isTech]] | ||
civ.isTech(object) -> boolean | civ.isTech(object) -> boolean | ||
Line 236: | Line 237: | ||
[[isTile]] | [[civ.isTile|isTile]] | ||
civ.isTile(object) -> boolean | civ.isTile(object) -> boolean | ||
Line 243: | Line 244: | ||
[[isTribe]] | [[civ.isTribe|isTribe]] | ||
civ.isTribe(object) -> boolean | civ.isTribe(object) -> boolean | ||
Line 250: | Line 251: | ||
[[isUnit]] | [[civ.isUnit|isUnit]] | ||
civ.isUnit(object) -> boolean | civ.isUnit(object) -> boolean | ||
Line 257: | Line 258: | ||
[[isUnitType]] | [[civ.isUnitType|isUnitType]] | ||
civ.isUnitType(object) -> boolean | civ.isUnitType(object) -> boolean | ||
Line 264: | Line 265: | ||
[[isWonder]] | [[civ.isWonder|isWonder]] | ||
civ.isWonder(object) -> boolean | civ.isWonder(object) -> boolean | ||
Line 271: | Line 272: | ||
[[iterateCities]] | [[civ.iterateCities|iterateCities]] | ||
civ.iterateCities() -> iterator | civ.iterateCities() -> iterator | ||
Line 278: | Line 279: | ||
[[iterateUnits]] | [[civ.iterateUnits|iterateUnits]] | ||
civ.iterateUnits() -> iterator | civ.iterateUnits() -> iterator | ||
Line 285: | Line 286: | ||
[[killTribe]] | [[civ.killTribe|killTribe]] | ||
civ.killTribe(tribe) | civ.killTribe(tribe) | ||
Line 292: | Line 293: | ||
[[makeAggression]] | [[civ.makeAggression|makeAggression]] | ||
civ.makeAggression(who, whom) | civ.makeAggression(who, whom) | ||
Line 299: | Line 300: | ||
[[playMusic]] | [[civ.playMusic|playMusic]] | ||
civ.playMusic(trackNo or filename) | civ.playMusic(trackNo or filename) | ||
Line 306: | Line 307: | ||
[[playSound]] | [[civ.playSound|playSound]] | ||
civ.playSound(filename) | civ.playSound(filename) | ||
Line 313: | Line 314: | ||
[[playVideo]] | [[civ.playVideo|playVideo]] | ||
civ.playVideo(filename) | civ.playVideo(filename) | ||
Line 320: | Line 321: | ||
[[removeImprovement]] | [[civ.removeImprovement|removeImprovement]] | ||
civ.removeImprovement(city, improvement) | civ.removeImprovement(city, improvement) | ||
Line 327: | Line 328: | ||
[[sleep]] | [[civ.sleep|sleep]] | ||
civ.sleep(milliseconds) | civ.sleep(milliseconds) | ||
Line 334: | Line 335: | ||
[[takeTech]] | [[civ.takeTech|takeTech]] | ||
civ.takeTech(tribe, tech, collapse=false) | civ.takeTech(tribe, tech, collapse=false) | ||
Line 341: | Line 342: | ||
[[teleportUnit]] | [[civ.teleportUnit|teleportUnit]] | ||
civ.teleportUnit(unit, tile) | 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`. | 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`. |
Revision as of 21:42, 1 January 2019
Back to TOTPP Functions
Follow the link in the function name for additional information about that function, if it is available.
civ.addImprovement(city, improvement)
Adds city improvement `improvement` to city `city`.
civ.canEnter(unittype, tile) -> boolean
Returns `true` if the given unittype can enter tile `tile`, `false` otherwise.
civ.captureCity(city, tribe)
Captures city `city` for tribe `tribe`.
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.
civ.createUnit(unittype, tribe, tile) -> unit
Creates a unit of type `unittype`, owned by `tribe`, at the location given by `tile`.
civ.deleteCity(city)
Deletes city `city` from the game.
civ.deleteUnit(unit)
Deletes unit `unit` from the game.
civ.destroyWonder(wonder)
Destroys wonder `wonder`, removing it from the game, and marking it as 'lost'.
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`.
civ.endGame(endscreens=false)
Ends the game. `endscreens` is a boolean that determines whether to show the powergraph and related screens.
civ.getActiveUnit() -> unit
Returns the currently active unit.
civ.getCity(id) -> city
Returns the city with id `id`, or `nil` if it doesn't exist.
civ.getCurrentTile() -> tile
Returns the currently selected tile.
civ.getCurrentTribe() -> tribe
Returns the currently active tribe.
civ.getGameYear() -> integer
Returns the current game year.
civ.getImprovement(id) -> improvement
Returns the improvement with id `id` (0-39), or `nil` if it doesn't exist.
civ.getMapDimensions() -> width, height, number_of_maps
Returns three integers, the width and height of the map and the number of maps.
civ.getPlayerTribe() -> tribe
Returns the player's tribe.
civ.getTech(id) -> tech
Returns the tech with id `id` (0-99), or `nil` if it doesn't exist.
civ.getTile(x, y, z) -> tile
Returns the tile with coordinates `x`, `y`, `z`, or `nil` if it doesn't exist.
civ.getToTDir() -> string
Returns the absolute path of the ToT installation directory.
civ.getTribe(id) -> tribe
Returns the tech with id `id` (0-7), or `nil` if it doesn't exist.
civ.getTurn() -> integer
Returns the current turn number.
civ.getUnit(id) -> integer
Returns the unit with id `id`, or `nil` if it doesn't exist.
civ.getUnitType(id) -> unittype
Returns the unit type with id `id`, or `nil` if it doesn't exist.
civ.getWonder(id) -> wonder
Returns the wonder with id `id` (0-27), or `nil` if it doesn't exist.
civ.giveTech(tribe, tech)
Gives tech `tech` to tribe `tribe`.
civ.hasImprovement(city, improvement)
Returns `true` if city `city` has improvement `improvement`, `false` otherwise.
civ.hasTech(tribe, tech) -> boolean
Returns `true` if tribe `tribe` has tech `tech`, `false` otherwise.
civ.isCity(object) -> boolean
Returns `true` if `object` is a city, `false` otherwise.
civ.isImprovement(object) -> boolean
Returns `true` if `object` is a city improvement, `false` otherwise.
civ.isLeader(object) -> boolean
Returns `true` if `object` is a leader, `false` otherwise.
civ.isTech(object) -> boolean
Returns `true` if `object` is a tech, `false` otherwise.
civ.isTile(object) -> boolean
Returns `true` if `object` is a tile, `false` otherwise.
civ.isTribe(object) -> boolean
Returns `true` if `object` is a tribe, `false` otherwise.
civ.isUnit(object) -> boolean
Returns `true` if `object` is a unit, `false` otherwise.
civ.isUnitType(object) -> boolean
Returns `true` if `object` is a unit type, `false` otherwise.
civ.isWonder(object) -> boolean
Returns `true` if `object` is a wonder, `false` otherwise.
civ.iterateCities() -> iterator
Returns an iterator yielding all cities in the game.
civ.iterateUnits() -> iterator
Returns an iterator yielding all units in the game.
civ.killTribe(tribe)
Removes tribe `tribe` from the game. All its cities and units are removed.
civ.makeAggression(who, whom)
Cancels any peace treaties between tribe `who` and tribe `whom`, and make `who` declare war on `whom`.
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.
civ.playSound(filename)
Plays the sound file given by `filename`.
civ.playVideo(filename)
Plays the video file given by `filename`.
civ.removeImprovement(city, improvement)
Removes city improvement `improvement` from city `city`.
civ.sleep(milliseconds)
Sleeps for the given number of milliseconds.
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.
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`.