Module NeighborCity
Neighbor City library for TheoTown.
This library provides functions to manage custom, virtual neighboring cities that the player can trade with. The goal is to extend the user experience especially in Online Mode where by default no neighborhood commercial is available.
Each neighbor city belongs to the draft that created it. Because of that, uninstalling a plugin that created a virtual neighbor will also remove that neighbor city.
This library is only available while a city is open.
Functions
| create (id[, name=nil]) | Creates a new virtual neighboring city using the given id and name. |
| get (id) | Returns the neighbor city object of this draft that has the given id. |
| getNeighbors () | Returns an array of all neighbor city objects that belong to this draft. |
Class NeighborCity
| neighborCity:delete () | Deletes this neighbor city so it can no longer be used for trading. |
| neighborCity:getBodyDisposal () | Returns the amount of body disposal services this neighbor city can export. |
| neighborCity:getId () | Returns the unique id of this neighbor city. |
| neighborCity:getName () | Returns the displayed name for this city. |
| neighborCity:getPower () | Returns the amount of power this neighbor city can export. |
| neighborCity:getPowerExport () | Returns the current power trade with this neighbor city. |
| neighborCity:getWasteDisposal () | Returns the amount of waste disposal services this neighbor city can export. |
| neighborCity:getWater () | Returns the amount of water this neighbor city can export. |
| neighborCity:isValid () | Determines whether this neighbor city object is valid. |
| neighborCity:setBodyDisposal (amount) | Sets the amount of body disposal services this neighbor city can export. |
| neighborCity:setName (name) | Sets a visible name for this city. |
| neighborCity:setPower (amount) | Sets the amount of power this neighbor city can export. |
| neighborCity:setWasteDisposal (amount) | Sets the amount of waste disposal services this neighbor city can export. |
| neighborCity:setWater (amount) | Sets the amount of water this neighbor city can export. |
Functions
- create (id[, name=nil])
-
Creates a new virtual neighboring city using the given id and name.
Parameters:
- id string An id unique to the calling draft that identifies the neighbor. If a neighbor with the same id was already created it will be replaced by the new one.
- name string A name that will be shown for the created city. If no name was provided the game will generate a random one. (default nil)
Returns:
-
NeighborCity
A neighbor city object.
- get (id)
-
Returns the neighbor city object of this draft that has the given id.
Parameters:
- id string The id that should be found.
Returns:
-
NeighborCity
The neighbor city object with the given id or nil if
no such neighbor object exists.
- getNeighbors ()
-
Returns an array of all neighbor city objects that belong to this draft.
Returns:
-
Array
An array of all virtual neighbor cities.
Class NeighborCity
This type represents NeighborCity objects.- neighborCity:delete ()
- Deletes this neighbor city so it can no longer be used for trading.
- neighborCity:getBodyDisposal ()
-
Returns the amount of body disposal services this neighbor city can export.
Returns:
-
int
The amount of body disposal services that can be exported from
the neighbor city.
- neighborCity:getId ()
-
Returns the unique id of this neighbor city.
The id is unique between the neighbor cities that belong to the calling draft.
Returns:
-
string
The id associated during the creation process.
- neighborCity:getName ()
-
Returns the displayed name for this city.
Returns:
-
string
The name of the neighbor city.
- neighborCity:getPower ()
-
Returns the amount of power this neighbor city can export.
Returns:
-
int
The amount of power that can be exported from the neighbor city.
- neighborCity:getPowerExport ()
- Returns the current power trade with this neighbor city. Positive values indicate exports to it; negative values indicate imports from it.
- neighborCity:getWasteDisposal ()
-
Returns the amount of waste disposal services this neighbor city can export.
Returns:
-
int
The amount of waste disposal services that can be exported from
the neighbor city.
- neighborCity:getWater ()
-
Returns the amount of water this neighbor city can export.
Returns:
-
int
The amount of water that can be exported from the neighbor city.
- neighborCity:isValid ()
-
Determines whether this neighbor city object is valid.
Returns:
-
bool
True if this neighbor city object is still valid.
- neighborCity:setBodyDisposal (amount)
-
Sets the amount of body disposal services this neighbor city can export.
Parameters:
- amount int The amount of body disposal services that can be exported from the neighbor city.
- neighborCity:setName (name)
-
Sets a visible name for this city.
Parameters:
- name string The new name of the neighbor city.
- neighborCity:setPower (amount)
-
Sets the amount of power this neighbor city can export.
Parameters:
- amount int The amount of power that can be exported from the neighbor city.
- neighborCity:setWasteDisposal (amount)
-
Sets the amount of waste disposal services this neighbor city can export.
Parameters:
- amount int The amount of waste disposal services that can be exported from the neighbor city.
- neighborCity:setWater (amount)
-
Sets the amount of water this neighbor city can export.
Parameters:
- amount int The amount of water that can be exported from the neighbor city.