MinchinWeb's MetaLibrary v.11
Library functions for OpenTTD AI (and GS) writers.
Loading...
Searching...
No Matches
_MinchinWeb_Station_ Class Reference

Station. More...

Public Member Functions

function BuildStreetcarStation (Tile, Loop=true)
 Build a streetcar station.
function GetName (Tile, StationType=AIStation.STATION_ANY)
 Get a station's name.

Static Public Member Functions

function IsCargoAccepted (StationID, CargoID)
 Checks whether a certain Station accepts a given cargo.
function IsNextToDock (TileID)
 Checks whether a given tile is next to a dock.
function DistanceFromStation (VehicleID, StationID)
 Returns the distance between a given vehicle and a given station.

Private Attributes

 main = null

Detailed Description

Station.

Version
v.4 (2025-07-16)
Author
W. Minchin (MinchinWeb)
Since
MetaLibrary v.2

These are functions relating to dealing with stations.

Definition at line 38 of file Station.nut.

Member Function Documentation

◆ BuildStreetcarStation()

function _MinchinWeb_Station_::BuildStreetcarStation ( Tile ,
Loop = true )

Build a streetcar station.

First tries to build a streetcar station with a half-tile loop on each end; if that works, actually build it.

Parameters
Tile
LoopIf true, build a loop connecting the two ends
Returns
true or false depending on if the building the station was successful

Definition at line 132 of file Station.nut.

◆ DistanceFromStation()

function _MinchinWeb_Station_::DistanceFromStation ( VehicleID ,
StationID  )
static

Returns the distance between a given vehicle and a given station.

Note
Designed to be usable as a Valuator on a AIList of vehicles
Parameters
VehicleIDID of the vehicle (as an integer)
StationIDID of the station (as an integer)
Returns
Manhattan Distance between the vehicle and the station.
Todo

Add check that supplied VehicleID and StationID are valid

Add example of valuator code

Definition at line 125 of file Station.nut.

◆ GetName()

function _MinchinWeb_Station_::GetName ( Tile ,
StationType = AIStation.STATION_ANY )

Get a station's name.

Parameters
TileTile assumed to be part of the station.
StationTypeOne of AIStation: AIStation.STATION_TRAIN, AIStation.STATION_TRUCK_STOP, AIStation.STATION_BUS_STOP, AIStation.STATION_AIRPORT, AIStation.STATION_DOCK, or AIStation.STATION_ANY.
Returns
string of station name

Definition at line 200 of file Station.nut.

◆ IsCargoAccepted()

function _MinchinWeb_Station_::IsCargoAccepted ( StationID ,
CargoID  )
static

Checks whether a certain Station accepts a given cargo.

Parameters
StationIDID of the station (as an integer)
CargoIDID of the cargo (as an integer)
Note
Can be used as a Valuator on a AIList of stations
Returns
Returns null if the StationID or CargoID are invalid. Returns true or false, depending on if the cargo is accepted
Todo
Add example of valuator code

Definition at line 97 of file Station.nut.

◆ IsNextToDock()

function _MinchinWeb_Station_::IsNextToDock ( TileID )
static

Checks whether a given tile is next to a dock.

Parameters
TileIDID of the tile (as an integer)
Returns
True if the tile is next to a dock, False otherwise.

Definition at line 112 of file Station.nut.

Member Data Documentation

◆ main

_MinchinWeb_Station_::main = null
private

Definition at line 39 of file Station.nut.


The documentation for this class was generated from the following file: