The city object

From Scenario League Wiki
Revision as of 20:09, 26 January 2019 by Prof. Garfield (talk | contribs) (Added to category lua resources)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Back To TOTPP Functions

id (get)

city.id -> integer

Returns the city's id.


name (get/set)

city.name -> string

Returns the city's name.


location (get)

city.location -> tile

Returns the city's location. See the `relocate` method for a way to set this.


size (get/set)

city.size -> integer

Returns the city's size.


attributes (get/set)

city.attributes -> integer

Returns the city's attributes (bitmask).


owner (get/set)

city.owner -> tribe

Returns the city's owner.


originalOwner (get/set)

city.originalOwner -> tribe

Returns the city's original owner. This can be different from `owner` if the city was captured in the past.


turnsSinceCapture (get/set)

city.turnsSinceCapture -> integer

Returns the number of turns since the city was last captured.


knownTo (get/set)

city.knownTo -> integer

Returns a bitmask indicating the tribes that have knowledge of this city.


specialists (get/set)

city.specialists -> integer

Returns the city's specialists as a integer, 16 x 2 bits per specialist (0 - No specialist, 1 - Entertainer, 2 - Taxman, 3 - Scientist)


food (get/set)

city.food -> integer

Returns the quantity of food in store.


shields (get/set)

city.shields -> integer

Returns the number of shields towards the current item in production.


baseTrade (get)

city.baseTrade -> integer

Returns the number of trade arrows before trade routes.


workers (get/set)

city.workers -> integer

Returns a bitmask with the workers and specialists of the city.


numTradeRoutes (get)

city.numTradeRoutes -> integer

Returns the number of trade routes of the city.


science (get)

city.science -> integer

Returns the amount of science the city produces.


tax (get)

city.tax -> integer

Returns the amount of tax the city produces.


totalTrade (get)

city.totalTrade -> integer

Returns the total amount of trade arrows the city produces (including trade routes).


totalFood (get)

city.totalFood -> integer

Returns the total amount of food the city produces.


totalShield (get)

city.totalShield -> integer

Returns the total amount of shields the city produces.


numHappy (get)

city.numHappy -> integer

Returns the number of happy citizens.


numUnhappy (get)

city.numUnhappy -> integer

Returns the number of unhappy citizens.


coastal (get)

city.coastal -> boolean

Returns whether or not the city is on a coast (can build coastal improvements).


addImprovement

city:addImprovement(improvement)

Alias for `civ.addImprovement(city, improvement)`.


hasImprovement

city:hasImprovement(improvement) -> boolean

Alias for `civ.hasImprovement(city, improvement)`.


removeImprovement

city:removeImprovement(improvement)

Alias for `civ.removeImprovement(city, improvement)`.


relocate

city:relocate(tile) -> boolean

Relocates the city to the location given by `tile`. Returns `true` if successful, `false` otherwise (if a city is already present for example).


canBuild

city:canBuild(item) -> boolean

Returns whether or not `item` can currently be built in the city. `item` can be a unittype, improvement or wonder.