OpenTTD GameScript API 20241220-master-g59680867c3
Public Types | Static Public Member Functions
GSSign Class Reference

Class that handles all sign related functions. More...

#include <script_sign.hpp>

Inheritance diagram for GSSign:

Public Types

enum  ErrorMessages {
  ERR_SIGN_BASE ,
  ERR_SIGN_TOO_MANY_SIGNS
}
 All sign related error messages. More...
 

Static Public Member Functions

static bool IsValidSign (SignID sign_id)
 Checks whether the given sign index is valid.
 
static bool SetName (SignID sign_id, Text *name)
 Set the name of a sign.
 
static string GetName (SignID sign_id)
 Get the name of the sign.
 
static GSCompany::CompanyID GetOwner (SignID sign_id)
 Get the owner of a sign.
 
static TileIndex GetLocation (SignID sign_id)
 Gets the location of the sign.
 
static SignID BuildSign (TileIndex location, Text *name)
 Builds a sign on the map.
 
static bool RemoveSign (SignID sign_id)
 Removes a sign from the map.
 

Detailed Description

Class that handles all sign related functions.

Member Enumeration Documentation

◆ ErrorMessages

All sign related error messages.

See also
ScriptErrorType
Enumerator
ERR_SIGN_BASE 

Base for sign building related errors.

ERR_SIGN_TOO_MANY_SIGNS 

Too many signs have been placed.

Member Function Documentation

◆ BuildSign()

static SignID GSSign::BuildSign ( TileIndex  location,
Text *  name 
)
static

Builds a sign on the map.

Parameters
locationThe place to build the sign.
nameThe text to place on the sign (can be either a raw string, or a GSText object).
Precondition
GSMap::IsValidTile(location).
name != null && len(name) != 0.
Exceptions
GSSign::ERR_SIGN_TOO_MANY_SIGNS
Returns
The SignID of the build sign (use IsValidSign() to check for validity). In test-mode it returns 0 if successful, or any other value to indicate failure.

◆ GetLocation()

static TileIndex GSSign::GetLocation ( SignID  sign_id)
static

Gets the location of the sign.

Parameters
sign_idThe sign to get the location of.
Precondition
IsValidSign(sign_id).
Returns
The location of the sign.

◆ GetName()

static string GSSign::GetName ( SignID  sign_id)
static

Get the name of the sign.

Parameters
sign_idThe sign to get the name of.
Precondition
IsValidSign(sign_id).
Returns
The name of the sign.

◆ GetOwner()

static GSCompany::CompanyID GSSign::GetOwner ( SignID  sign_id)
static

Get the owner of a sign.

Parameters
sign_idThe sign to get the owner of.
Precondition
IsValidSign(sign_id).
Returns
The owner the sign has.

◆ IsValidSign()

static bool GSSign::IsValidSign ( SignID  sign_id)
static

Checks whether the given sign index is valid.

Parameters
sign_idThe index to check.
Returns
True if and only if the sign is valid.

◆ RemoveSign()

static bool GSSign::RemoveSign ( SignID  sign_id)
static

Removes a sign from the map.

Parameters
sign_idThe sign to remove.
Precondition
IsValidSign(sign_id).
Returns
True if and only if the sign has been removed.

◆ SetName()

static bool GSSign::SetName ( SignID  sign_id,
Text *  name 
)
static

Set the name of a sign.

Parameters
sign_idThe sign to set the name for.
nameThe name for the sign (can be either a raw string, or a GSText object).
Precondition
IsValidSign(sign_id).
name != null && len(name) != 0.
Exceptions
GSError::ERR_NAME_IS_NOT_UNIQUE
Returns
True if and only if the name was changed.