Simutrans-Squirrel-API OTRP v63_4
Loading...
Searching...
No Matches
Scenario only functions

Classes

class  rules

Functions

static string gui::add_message_at (string text, coord position)
static string gui::add_message (player_x text, string)
void player_x::book_cash (integer delta)
string load_language_file (string file)
static bool world::create_player (integer player_nr, integer player_type)
static bool world::remove_player (player_x pl)
static integer world::generate_goods (coord from, coord to, good_desc_x desc, integer count)

Detailed Description

These classes and methods are only available for scripted scenarios.

Function Documentation

◆ add_message()

string gui::add_message ( player_x text,
string  )
static

Adds message to the players mailboxes. Will be shown in ticker or as pop-up window depending on players preferences.

Parameters
textText to be shown. Has to be a translated string or a translatable string.
Note
Only available in scenario mode.

◆ add_message_at()

string gui::add_message_at ( string text,
coord position )
static

Adds message to the players mailboxes. Will be shown in ticker or as pop-up window depending on players preferences. Message window has small view of world.

Parameters
textText to be shown. Has to be a translated string or a translatable string.
positionPosition of the view on the map. Clicking on the message will center viewport at this position.
Note
Only available in scenario mode.

◆ book_cash()

void player_x::book_cash ( integer delta)

Change bank account of player by given amount delta.

Parameters
delta

◆ create_player()

bool world::create_player ( integer player_nr,
integer player_type )
static

Creates a player company in an unused player slot.

Player numbers 0 and 1 are reserved for the default human and public players. Valid new player numbers are 2 through 14.

Player types are 1 = human, 2 = goods AI, 3 = passenger AI, and 4 = scripted AI.

In network games, there will be a delay between the call to this function and creation of the player.

Parameters
player_nrunused player number
player_typeplayer type to create
Returns
whether the creation request was accepted

◆ generate_goods()

integer world::generate_goods ( coord from,
coord to,
good_desc_x desc,
integer count )
static

Generates goods packet and sends it on its way.

Parameters
fromorigin position
todestination position
desctype of goods
countnumber of goods
Return values
0No route found
1Passengers/mail/freight successfully generated
2Destination is within station catchment area
8Route is overcrowded (if no_routing_over_overcrowded is enabled)

◆ load_language_file()

string load_language_file ( string file)

Helper method to load scenario-related translation files. Tries to load files in the following order relative to pakxx/scenario:

  1. scenario-name/iso/filename
  2. scenario-name/en/filename
  3. scenario-name/filename

Here, iso refers to iso-abbreviation of currently active language.

The content of the files is cached. The cache is cleared upon reloading of savegame.

Parameters
filename of txt-file
Returns
content of loaded file
Note
Only available in scenario mode.

◆ remove_player()

bool world::remove_player ( player_x pl)
static

Removes player company: removes all assets. Use with care.

If pl is the first player (nr == 0) it is restarted immediately. Public player (nr == 1) cannot be removed.

In network games, there will be a delay between the call to this function and the removal of the player.

Parameters
plplayer to be removed
Returns
whether operation was successful