OpenTTD GameScript API: GSObjectType Class Reference

OpenTTD GameScript API 14.0-beta2

Static Public Member Functions
GSObjectType Class Reference

Class that handles all object-type related functions. More...

Inheritance diagram for GSObjectType:

## Static Public Member Functions
static bool | IsValidObjectType (ObjectType object_type)
| Checks whether the given object-type is valid. More...
static std::optional< std::string > | GetName (ObjectType object_type)
| Get the name of an object-type. More...
static SQInteger | GetViews (ObjectType object_type)
| Get the number of views for an object-type. More...
static bool | BuildObject (ObjectType object_type, SQInteger view, TileIndex tile)
| Build an object of the specified type. More...
static ObjectType | ResolveNewGRFID (SQInteger grfid, SQInteger grf_local_id)
| Get a specific object-type from a grf. More...

## Detailed Description

Class that handles all object-type related functions.

## Member Function Documentation

## ◆ BuildObject()

static bool GSObjectType::BuildObject | ( | ObjectType | object_type,
|  | SQInteger | view,
|  | TileIndex | tile
| ) |  |
| static

Build an object of the specified type.

Parameters

  object_type | The type of the object to build.
  view | The view for teh object.
  tile | The tile to build the object on.

Precondition
  IsValidObjectType(object_type).

Returns
  True if the object was successfully build.

## ◆ GetName()

static std::optional<std::string> GSObjectType::GetName | ( | ObjectType | object_type | ) |
| static

Get the name of an object-type.

Parameters

  object_type | The type to get the name for.

Precondition
  IsValidObjectType(object_type).

Returns
  The name of an object.

## ◆ GetViews()

static SQInteger GSObjectType::GetViews | ( | ObjectType | object_type | ) |
| static

Get the number of views for an object-type.

Parameters

  object_type | The type to get the number of views for.

Precondition
  IsValidObjectType(object_type).

Returns
  The number of views for an object.

## ◆ IsValidObjectType()

static bool GSObjectType::IsValidObjectType | ( | ObjectType | object_type | ) |
| static

Checks whether the given object-type is valid.

Parameters

  object_type | The type to check.

Returns
  True if and only if the object-type is valid.

## ◆ ResolveNewGRFID()

static ObjectType GSObjectType::ResolveNewGRFID | ( | SQInteger | grfid,
|  | SQInteger | grf_local_id
| ) |  |
| static

Get a specific object-type from a grf.

Parameters

  grfid | The ID of the NewGRF.
  grf_local_id | The ID of the object, local to the NewGRF.

Precondition
  0x00 <= grf_local_id < NUM_OBJECTS_PER_GRF.

Returns
  the object-type ID, local to the current game (this diverges from the grf_local_id).