Simutrans-Squirrel-API
Classes | Functions
Scenario only functions

Classes

class  rules
 

Functions

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

Detailed Description

These classes and methods are only available for scripted scenarios.

Function Documentation

◆ add_message()

static 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()

static string gui::add_message_at ( string  text,
coord3d  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

◆ generate_goods()

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

Generates goods (passengers, mail or freight) that want to travel from from to to. Updates halt statistics (happy, unhappy, no route) for passengers if possible.

Parameters
fromstart position for good
todestination position for good
descGood descriptor
countNumber of goods to generate
Return values
0No route to destination or start position not valid
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()

static 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