OpenTTD GameScript API: GSNews Class Reference

OpenTTD GameScript API 15.1

Public Types | Static Public Member Functions
GSNews Class Reference

Class that handles news messages. More...

`#include <script_news.hpp>`

Inheritance diagram for GSNews:

## Public Types
enum | NewsType { NT_ACCIDENT , NT_COMPANY_INFO , NT_ECONOMY , NT_ADVICE , NT_ACCEPTANCE , NT_SUBSIDIES , NT_GENERAL }
| Enumeration for the news types that a script can create news for. More...
enum | NewsReferenceType { NR_NONE , NR_TILE , NR_STATION , NR_INDUSTRY , NR_TOWN }
| Reference to a game element. More...

## Static Public Member Functions
static bool | Create (NewsType type, Text *text, GSCompany::CompanyID company, NewsReferenceType ref_type, int reference)
| Create a news message for everybody, or for one company.

## Detailed Description

Class that handles news messages.

## Member Enumeration Documentation

## ◆ NewsReferenceType

enum GSNews::NewsReferenceType

Reference to a game element.

Enumerator
NR_NONE | No reference supplied.
NR_TILE | Reference location, scroll to the location when clicking on the news.
NR_STATION | Reference station, scroll to the station when clicking on the news. Delete news when the station is deleted.
NR_INDUSTRY | Reference industry, scrolls to the industry when clicking on the news. Delete news when the industry is deleted.
NR_TOWN | Reference town, scroll to the town when clicking on the news.

## ◆ NewsType

enum GSNews::NewsType

Enumeration for the news types that a script can create news for.

Enumerator
NT_ACCIDENT | Category accidents.
NT_COMPANY_INFO | Category company info.
NT_ECONOMY | Category economy.
NT_ADVICE | Category vehicle advice.
NT_ACCEPTANCE | Category acceptance changes.
NT_SUBSIDIES | Category subsidies.
NT_GENERAL | Category general.

## Member Function Documentation

## ◆ Create()

static bool GSNews::Create | ( | NewsType | type,
|  | Text * | text,
|  | GSCompany::CompanyID | company,
|  | NewsReferenceType | ref_type,
|  | int | reference
| ) |  |
| static

Create a news message for everybody, or for one company.

Parameters

  type | The type of the news.
  text | The text message to show (can be either a raw string, or a GSText object).
  company | The company, or COMPANY_INVALID for all companies.
  ref_type | Type of referred game element.
  reference | The referenced game element of ref_type. For NR_NONE this parameter is ignored. For NR_TILE this parameter should be a valid location (GSMap::IsValidTile). For NR_STATION this parameter should be a valid stationID (GSStation::IsValidStation). For NR_INDUSTRY this parameter should be a valid industryID (GSIndustry::IsValidIndustry). For NR_TOWN this parameter should be a valid townID (GSTown::IsValidTown).

Returns
  True if the action succeeded.

Precondition
  type must be #NewsType::Economy, #NewsType::Subsidies, or #NewsType::General.
  text != null.
  company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
  The reference condition must be fulfilled.
  GSCompanyMode::IsDeity().