OpenTTD GameScript API
20240328-master-gca53e134be
|
Class that handles all town related functions. More...
Public Types | |
enum | TownAction { TOWN_ACTION_ADVERTISE_SMALL, TOWN_ACTION_ADVERTISE_MEDIUM, TOWN_ACTION_ADVERTISE_LARGE, TOWN_ACTION_ROAD_REBUILD, TOWN_ACTION_BUILD_STATUE, TOWN_ACTION_FUND_BUILDINGS, TOWN_ACTION_BUY_RIGHTS, TOWN_ACTION_BRIBE } |
Actions that one can perform on a town. More... | |
enum | TownRating { TOWN_RATING_NONE, TOWN_RATING_APPALLING, TOWN_RATING_VERY_POOR, TOWN_RATING_POOR, TOWN_RATING_MEDIOCRE, TOWN_RATING_GOOD, TOWN_RATING_VERY_GOOD, TOWN_RATING_EXCELLENT, TOWN_RATING_OUTSTANDING, TOWN_RATING_INVALID } |
Different ratings one could have in a town. More... | |
enum | RoadLayout { ROAD_LAYOUT_ORIGINAL, ROAD_LAYOUT_BETTER_ROADS, ROAD_LAYOUT_2x2, ROAD_LAYOUT_3x3, ROAD_LAYOUT_RANDOM, ROAD_LAYOUT_INVALID } |
Possible layouts for the roads in a town. More... | |
enum | TownSize { TOWN_SIZE_SMALL, TOWN_SIZE_MEDIUM, TOWN_SIZE_LARGE, TOWN_SIZE_INVALID } |
Possible town construction sizes. More... | |
enum | TownGrowth { TOWN_GROWTH_NONE, TOWN_GROWTH_NORMAL } |
Special values for SetGrowthRate. More... | |
Static Public Member Functions | |
static SQInteger | GetTownCount () |
Gets the number of towns. More... | |
static bool | IsValidTown (TownID town_id) |
Checks whether the given town index is valid. More... | |
static std::optional< std::string > | GetName (TownID town_id) |
Get the name of the town. More... | |
static bool | SetName (TownID town_id, Text *name) |
Rename a town. More... | |
static bool | SetText (TownID town_id, Text *text) |
Set the custom text of a town, shown in the GUI. More... | |
static SQInteger | GetPopulation (TownID town_id) |
Gets the number of inhabitants in the town. More... | |
static SQInteger | GetHouseCount (TownID town_id) |
Gets the number of houses in the town. More... | |
static TileIndex | GetLocation (TownID town_id) |
Gets the location of the town. More... | |
static SQInteger | GetLastMonthProduction (TownID town_id, CargoID cargo_id) |
Get the total last month's production of the given cargo at a town. More... | |
static SQInteger | GetLastMonthSupplied (TownID town_id, CargoID cargo_id) |
Get the total amount of cargo supplied from a town last month. More... | |
static SQInteger | GetLastMonthTransportedPercentage (TownID town_id, CargoID cargo_id) |
Get the percentage of transported production of the given cargo at a town. More... | |
static SQInteger | GetLastMonthReceived (TownID town_id, GSCargo::TownEffect towneffect_id) |
Get the total amount of cargo effects received by a town last month. More... | |
static bool | SetCargoGoal (TownID town_id, GSCargo::TownEffect towneffect_id, SQInteger goal) |
Set the goal of a cargo for this town. More... | |
static SQInteger | GetCargoGoal (TownID town_id, GSCargo::TownEffect towneffect_id) |
Get the amount of cargo that needs to be delivered (per TownEffect) for a town to grow. More... | |
static bool | SetGrowthRate (TownID town_id, SQInteger days_between_town_growth) |
Set the amount of days between town growth. More... | |
static SQInteger | GetGrowthRate (TownID town_id) |
Get the amount of days between town growth. More... | |
static SQInteger | GetDistanceManhattanToTile (TownID town_id, TileIndex tile) |
Get the manhattan distance from the tile to the GSTown::GetLocation() of the town. More... | |
static SQInteger | GetDistanceSquareToTile (TownID town_id, TileIndex tile) |
Get the square distance from the tile to the GSTown::GetLocation() of the town. More... | |
static bool | IsWithinTownInfluence (TownID town_id, TileIndex tile) |
Find out if this tile is within the rating influence of a town. More... | |
static bool | HasStatue (TownID town_id) |
Find out if this town has a statue for the current company. More... | |
static bool | IsCity (TownID town_id) |
Find out if the town is a city. More... | |
static SQInteger | GetRoadReworkDuration (TownID town_id) |
Find out how long the town is undergoing road reconstructions. More... | |
static SQInteger | GetFundBuildingsDuration (TownID town_id) |
Find out how long new buildings are still being funded in a town. More... | |
static GSCompany::CompanyID | GetExclusiveRightsCompany (TownID town_id) |
Find out which company currently has the exclusive rights of this town. More... | |
static SQInteger | GetExclusiveRightsDuration (TownID town_id) |
Find out how long the town is under influence of the exclusive rights. More... | |
static bool | IsActionAvailable (TownID town_id, TownAction town_action) |
Find out if an action can currently be performed on the town. More... | |
static bool | PerformTownAction (TownID town_id, TownAction town_action) |
Perform a town action on this town. More... | |
static bool | ExpandTown (TownID town_id, SQInteger houses) |
Expand the town. More... | |
static bool | FoundTown (TileIndex tile, TownSize size, bool city, RoadLayout layout, Text *name) |
Found a new town. More... | |
static TownRating | GetRating (TownID town_id, GSCompany::CompanyID company_id) |
Get the rating of a company within a town. More... | |
static SQInteger | GetDetailedRating (TownID town_id, GSCompany::CompanyID company_id) |
Get the accurate rating of a company within a town. More... | |
static bool | ChangeRating (TownID town_id, GSCompany::CompanyID company_id, SQInteger delta) |
Change the rating of a company within a town. More... | |
static SQInteger | GetAllowedNoise (TownID town_id) |
Get the maximum level of noise that still can be added by airports before the town start to refuse building a new airport. More... | |
static RoadLayout | GetRoadLayout (TownID town_id) |
Get the road layout for a town. More... | |
Class that handles all town related functions.
enum GSTown::RoadLayout |
Possible layouts for the roads in a town.
enum GSTown::TownAction |
Actions that one can perform on a town.
enum GSTown::TownGrowth |
enum GSTown::TownRating |
Different ratings one could have in a town.
enum GSTown::TownSize |
|
static |
Change the rating of a company within a town.
town_id | The town to change the rating in. |
company_id | The company to change the rating for. |
delta | How much to change rating by (range -1000 to +1000). |
|
static |
Expand the town.
town_id | The town to expand. |
houses | The amount of houses to grow the town with. The value will be clamped to 0 .. MAX(uint32_t). |
|
static |
Found a new town.
tile | The location of the new town. |
size | The town size of the new town. |
city | True if the new town should be a city. |
layout | The town layout of the new town. |
name | The name of the new town. Pass null, or an empty string, to use a random town name. |
|
static |
Get the maximum level of noise that still can be added by airports before the town start to refuse building a new airport.
town_id | The town to get the allowed noise from. |
|
static |
Get the amount of cargo that needs to be delivered (per TownEffect) for a town to grow.
All goals need to be reached before a town will grow.
town_id | The index of the town. |
towneffect_id | The index of the towneffect. |
|
static |
Get the accurate rating of a company within a town.
town_id | The town to get the rating for. |
company_id | The company to get the rating for. |
|
static |
Get the manhattan distance from the tile to the GSTown::GetLocation() of the town.
town_id | The town to get the distance to. |
tile | The tile to get the distance to. |
|
static |
Get the square distance from the tile to the GSTown::GetLocation() of the town.
town_id | The town to get the distance to. |
tile | The tile to get the distance to. |
|
static |
Find out which company currently has the exclusive rights of this town.
town_id | The town to check. |
|
static |
Find out how long the town is under influence of the exclusive rights.
town_id | The town to check. |
|
static |
Find out how long new buildings are still being funded in a town.
town_id | The town to check. |
|
static |
Get the amount of days between town growth.
town_id | The index of the town. |
|
static |
Gets the number of houses in the town.
town_id | The town to get the number of houses of. |
|
static |
Get the total last month's production of the given cargo at a town.
town_id | The index of the town. |
cargo_id | The index of the cargo. |
|
static |
Get the total amount of cargo effects received by a town last month.
town_id | The index of the town. |
towneffect_id | The index of the cargo. |
|
static |
Get the total amount of cargo supplied from a town last month.
town_id | The index of the town. |
cargo_id | The index of the cargo. |
|
static |
Get the percentage of transported production of the given cargo at a town.
town_id | The index of the town. |
cargo_id | The index of the cargo. |
|
static |
Gets the location of the town.
town_id | The town to get the location of. |
|
static |
Get the name of the town.
town_id | The town to get the name of. |
|
static |
Gets the number of inhabitants in the town.
town_id | The town to get the population of. |
|
static |
Get the rating of a company within a town.
town_id | The town to get the rating for. |
company_id | The company to get the rating for. |
|
static |
Get the road layout for a town.
town_id | The town to get the road layout from. |
|
static |
Find out how long the town is undergoing road reconstructions.
town_id | The town to check. |
|
static |
Gets the number of towns.
|
static |
Find out if this town has a statue for the current company.
town_id | The town to check. |
|
static |
Find out if an action can currently be performed on the town.
town_id | The town to perform the action on. |
town_action | The action to perform on the town. |
|
static |
Find out if the town is a city.
town_id | The town to check. |
|
static |
Checks whether the given town index is valid.
town_id | The index to check. |
|
static |
Find out if this tile is within the rating influence of a town.
If a station sign would be on this tile, the servicing quality of the station would influence the rating of the town.
town_id | The town to check. |
tile | The tile to check. |
|
static |
Perform a town action on this town.
town_id | The town to perform the action on. |
town_action | The action to perform on the town. |
|
static |
Set the goal of a cargo for this town.
town_id | The index of the town. |
towneffect_id | The index of the towneffect. |
goal | The new goal. The value will be clamped to 0 .. MAX(uint32_t). |
|
static |
Set the amount of days between town growth.
town_id | The index of the town. |
days_between_town_growth | The amount of days between town growth, TOWN_GROWTH_NONE or TOWN_GROWTH_NORMAL. |
|
static |
Rename a town.
town_id | The town to rename |
name | The new name of the town. If null, or an empty string, is passed, the town name will be reset to the default name. |
|
static |
Set the custom text of a town, shown in the GUI.
town_id | The town to set the custom text of. |
text | The text to set it to (can be either a raw string, or a GSText object). If null, or an empty string, is passed, the text will be removed. |