OpenTTD GameScript API
20241118-master-gb8f3d0dd68
|
Class that handles all rail related functions. More...
Public Types | |
enum | ErrorMessages { ERR_RAIL_BASE , ERR_CROSSING_ON_ONEWAY_ROAD , ERR_UNSUITABLE_TRACK , ERR_RAILTYPE_DISALLOWS_CROSSING } |
All rail related error messages. More... | |
enum | RailType : int { RAILTYPE_INVALID } |
Types of rail known to the game. More... | |
enum | RailTrack { RAILTRACK_NE_SW , RAILTRACK_NW_SE , RAILTRACK_NW_NE , RAILTRACK_SW_SE , RAILTRACK_NW_SW , RAILTRACK_NE_SE , RAILTRACK_INVALID } |
A bitmap with all possible rail tracks on a tile. More... | |
enum | SignalType { SIGNALTYPE_NORMAL , SIGNALTYPE_ENTRY , SIGNALTYPE_EXIT , SIGNALTYPE_COMBO , SIGNALTYPE_PBS , SIGNALTYPE_PBS_ONEWAY , SIGNALTYPE_TWOWAY , SIGNALTYPE_NORMAL_TWOWAY , SIGNALTYPE_ENTRY_TWOWAY , SIGNALTYPE_EXIT_TWOWAY , SIGNALTYPE_COMBO_TWOWAY , SIGNALTYPE_NONE } |
Types of signal known to the game. More... | |
enum | BuildType { BT_TRACK , BT_SIGNAL , BT_DEPOT , BT_STATION , BT_WAYPOINT } |
Types of rail-related objects in the game. More... | |
Static Public Member Functions | |
static string | GetName (RailType rail_type) |
Get the name of a rail type. More... | |
static bool | IsRailTile (TileIndex tile) |
Checks whether the given tile is actually a tile with rail that can be used to traverse a tile. More... | |
static bool | IsLevelCrossingTile (TileIndex tile) |
Checks whether there is a road / rail crossing on a tile. More... | |
static bool | IsRailDepotTile (TileIndex tile) |
Checks whether the given tile is actually a tile with a rail depot. More... | |
static bool | IsRailStationTile (TileIndex tile) |
Checks whether the given tile is actually a tile with a rail station. More... | |
static bool | IsRailWaypointTile (TileIndex tile) |
Checks whether the given tile is actually a tile with a rail waypoint. More... | |
static bool | IsRailTypeAvailable (RailType rail_type) |
Check if a given RailType is available. More... | |
static RailType | GetCurrentRailType () |
Get the current RailType set for all GSRail functions. More... | |
static void | SetCurrentRailType (RailType rail_type) |
Set the RailType for all further GSRail functions. More... | |
static bool | TrainCanRunOnRail (GSRail::RailType engine_rail_type, GSRail::RailType track_rail_type) |
Check if a train build for a rail type can run on another rail type. More... | |
static bool | TrainHasPowerOnRail (GSRail::RailType engine_rail_type, GSRail::RailType track_rail_type) |
Check if a train build for a rail type has power on another rail type. More... | |
static RailType | GetRailType (TileIndex tile) |
Get the RailType that is used on a tile. More... | |
static bool | ConvertRailType (TileIndex start_tile, TileIndex end_tile, GSRail::RailType convert_to) |
Convert the tracks on all tiles within a rectangle to another RailType. More... | |
static TileIndex | GetRailDepotFrontTile (TileIndex depot) |
Gets the tile in front of a rail depot. More... | |
static RailTrack | GetRailStationDirection (TileIndex tile) |
Gets the direction of a rail station tile. More... | |
static bool | BuildRailDepot (TileIndex tile, TileIndex front) |
Builds a rail depot. More... | |
static bool | BuildRailStation (TileIndex tile, RailTrack direction, int num_platforms, int platform_length, StationID station_id) |
Build a rail station. More... | |
static bool | BuildNewGRFRailStation (TileIndex tile, RailTrack direction, int num_platforms, int platform_length, StationID station_id, CargoID cargo_id, IndustryType source_industry, IndustryType goal_industry, int distance, bool source_station) |
Build a NewGRF rail station. More... | |
static bool | BuildRailWaypoint (TileIndex tile) |
Build a rail waypoint. More... | |
static bool | RemoveRailWaypointTileRectangle (TileIndex tile, TileIndex tile2, bool keep_rail) |
Remove all rail waypoint pieces within a rectangle on the map. More... | |
static bool | RemoveRailStationTileRectangle (TileIndex tile, TileIndex tile2, bool keep_rail) |
Remove all rail station platform pieces within a rectangle on the map. More... | |
static int | GetRailTracks (TileIndex tile) |
Get all RailTracks on the given tile. More... | |
static bool | BuildRailTrack (TileIndex tile, RailTrack rail_track) |
Build rail on the given tile. More... | |
static bool | RemoveRailTrack (TileIndex tile, RailTrack rail_track) |
Remove rail on the given tile. More... | |
static bool | AreTilesConnected (TileIndex from, TileIndex tile, TileIndex to) |
Check if a tile connects two adjacent tiles. More... | |
static bool | BuildRail (TileIndex from, TileIndex tile, TileIndex to) |
Build a rail connection between two tiles. More... | |
static bool | RemoveRail (TileIndex from, TileIndex tile, TileIndex to) |
Remove a rail connection between two tiles. More... | |
static SignalType | GetSignalType (TileIndex tile, TileIndex front) |
Get the SignalType of the signal on a tile or SIGNALTYPE_NONE if there is no signal. More... | |
static bool | BuildSignal (TileIndex tile, TileIndex front, SignalType signal) |
Build a signal on a tile. More... | |
static bool | RemoveSignal (TileIndex tile, TileIndex front) |
Remove a signal. More... | |
static Money | GetBuildCost (RailType railtype, BuildType build_type) |
Get the baseprice of building a rail-related object. More... | |
static int | GetMaxSpeed (RailType railtype) |
Get the maximum speed of trains running on this railtype. More... | |
static int | GetMaintenanceCostFactor (RailType railtype) |
Get the maintenance cost factor of a railtype. More... | |
Class that handles all rail related functions.
enum GSRail::BuildType |
All rail related error messages.
enum GSRail::RailTrack |
A bitmap with all possible rail tracks on a tile.
enum GSRail::RailType : int |
enum GSRail::SignalType |
Types of signal known to the game.
Check if a tile connects two adjacent tiles.
from | The first tile to connect. |
tile | The tile that is checked. |
to | The second tile to connect. |
|
static |
Build a NewGRF rail station.
This calls callback 18 to let a NewGRF provide the station class / id to build, so we don't end up with only the default stations on the map. When no NewGRF provides a rail station, or an unbuildable rail station is returned by a NewGRF, this function will fall back to building a default non-NewGRF station as if GSRail::BuildRailStation was called.
tile | Place to build the station. |
direction | The direction to build the station. |
num_platforms | The number of platforms to build. |
platform_length | The length of each platform. |
station_id | The station to join, GSStation::STATION_NEW or GSStation::STATION_JOIN_ADJACENT. |
cargo_id | The CargoID of the cargo that will be transported from / to this station. |
source_industry | The IndustryType of the industry you'll transport goods from, GSIndustryType::INDUSTRYTYPE_UNKNOWN or GSIndustryType::INDUSTRYTYPE_TOWN. |
goal_industry | The IndustryType of the industry you'll transport goods to, GSIndustryType::INDUSTRYTYPE_UNKNOWN or GSIndustryType::INDUSTRYTYPE_TOWN. |
distance | The manhattan distance you'll transport the cargo over. |
source_station | True if this is the source station, false otherwise. |
Build a rail connection between two tiles.
from | The tile just before the tile to build on. |
tile | The first tile to build on. |
to | The tile just after the last tile to build on. |
GSError::ERR_AREA_NOT_CLEAR | |
GSError::ERR_LAND_SLOPED_WRONG | |
GSRail::ERR_CROSSING_ON_ONEWAY_ROAD | |
GSRoad::ERR_ROAD_WORKS_IN_PROGRESS | |
GSError::ERR_ALREADY_BUILT |
Builds a rail depot.
tile | Place to build the depot. |
front | The tile exactly in front of the depot. |
|
static |
Build a rail station.
tile | Place to build the station. |
direction | The direction to build the station. |
num_platforms | The number of platforms to build. |
platform_length | The length of each platform. |
station_id | The station to join, GSStation::STATION_NEW or GSStation::STATION_JOIN_ADJACENT. |
Build rail on the given tile.
tile | The tile to build on. |
rail_track | The RailTrack to build. |
GSError::ERR_AREA_NOT_CLEAR | |
GSError::ERR_LAND_SLOPED_WRONG | |
GSRoad::ERR_ROAD_WORKS_IN_PROGRESS | |
GSRail::ERR_CROSSING_ON_ONEWAY_ROAD | |
GSError::ERR_ALREADY_BUILT |
|
static |
Build a rail waypoint.
tile | Place to build the waypoint. |
GSError::ERR_FLAT_LAND_REQUIRED |
|
static |
Build a signal on a tile.
tile | The tile to build on. |
front | The tile in front of the signal. |
signal | The SignalType to build. |
GSRail::ERR_UNSUITABLE_TRACK |
|
static |
Convert the tracks on all tiles within a rectangle to another RailType.
start_tile | One corner of the rectangle. |
end_tile | The opposite corner of the rectangle. |
convert_to | The RailType you want to convert the rails to. |
GSRail::ERR_UNSUITABLE_TRACK |
Get the baseprice of building a rail-related object.
railtype | the railtype that is build (on) |
build_type | the type of object to build |
|
static |
Get the current RailType set for all GSRail functions.
|
static |
Get the maintenance cost factor of a railtype.
railtype | The railtype to get the maintenance factor of. |
|
static |
Get the maximum speed of trains running on this railtype.
railtype | The railtype to get the maximum speed of. |
|
static |
Get the name of a rail type.
rail_type | The rail type to get the name of. |
Gets the tile in front of a rail depot.
depot | The rail depot tile. |
Gets the direction of a rail station tile.
tile | The rail station tile. |
|
static |
Get all RailTracks on the given tile.
tile | The tile to check. |
Get the RailType that is used on a tile.
tile | The tile to check. |
|
static |
Get the SignalType of the signal on a tile or SIGNALTYPE_NONE if there is no signal.
tile | The tile that might have a signal. |
front | The tile in front of 'tile'. |
|
static |
Checks whether there is a road / rail crossing on a tile.
tile | The tile to check. |
|
static |
Checks whether the given tile is actually a tile with a rail depot.
tile | The tile to check. |
|
static |
Checks whether the given tile is actually a tile with a rail station.
tile | The tile to check. |
|
static |
Checks whether the given tile is actually a tile with rail that can be used to traverse a tile.
This excludes rail depots but includes stations and waypoints.
tile | The tile to check. |
|
static |
Check if a given RailType is available.
rail_type | The RailType to check for. |
|
static |
Checks whether the given tile is actually a tile with a rail waypoint.
tile | The tile to check. |
Remove a rail connection between two tiles.
from | The tile just before the tile to remove rail from. |
tile | The first tile to remove rail from. |
to | The tile just after the last tile to remove rail from. |
GSRail::ERR_UNSUITABLE_TRACK |
|
static |
Remove all rail station platform pieces within a rectangle on the map.
tile | One corner of the rectangle to clear. |
tile2 | The opposite corner. |
keep_rail | Whether to keep the rail after removal. |
GSRail::ERR_UNSUITABLE_TRACK |
Remove rail on the given tile.
tile | The tile to remove rail from. |
rail_track | The RailTrack to remove. |
GSRail::ERR_UNSUITABLE_TRACK |
|
static |
Remove all rail waypoint pieces within a rectangle on the map.
tile | One corner of the rectangle to clear. |
tile2 | The opposite corner. |
keep_rail | Whether to keep the rail after removal. |
GSRail::ERR_UNSUITABLE_TRACK |
Remove a signal.
tile | The tile to remove the signal from. |
front | The tile in front of the signal. |
GSRail::ERR_UNSUITABLE_TRACK |
|
static |
Set the RailType for all further GSRail functions.
rail_type | The RailType to set. |
|
static |
Check if a train build for a rail type can run on another rail type.
engine_rail_type | The rail type the train is build for. |
track_rail_type | The type you want to check. |
|
static |
Check if a train build for a rail type has power on another rail type.
engine_rail_type | The rail type the train is build for. |
track_rail_type | The type you want to check. |