Simutrans-Squirrel-API  r11875
Classes | Functions
Scenario only functions

Classes

class  rules
 
class  debug
 

Functions

static string gui::add_message_at (string text, coord3d position)
 
static string gui::add_message (player_x text, string)
 
void player_x::book_cash (integer delta)
 
string load_language_file (string file)
 
static void rules::forbid_tool (integer player_nr, integer tool_id)
 
static void rules::forbid_way_tool (integer player_nr, integer tool_id, way_types wt, any_x default_paramter)
 
static void rules::forbid_way_tool_rect (integer player_nr, integer tool_id, way_types wt, coord default_paramter, coord pos_nw, string pos_se, any_x err)
 
static void rules::forbid_way_tool_cube (integer player_nr, integer tool_id, way_types wt, coord3d default_paramter, coord3d pos_nw, string pos_se, any_x err)
 
static void rules::clear_forbid_tool (any_x player_nr, any_x tool_id)
 
static void rules::clear_forbid_way_tool (any_x player_nr, any_x tool_id, any_x wt, any_x default_paramter)
 
static void rules::clear_way_tool_rect (any_x player_nr, any_x tool_id, any_x wt, any_x default_paramter, any_x pos_nw, any_x pos_se, any_x allow)
 
static void rules::clear_way_tool_cube (any_x player_nr, any_x tool_id, any_x wt, any_x default_paramter, any_x pos_nw, any_x pos_se, any_x allow)
 
static void rules::clear ()
 
static void rules::clear_player ()
 
static void rules::allow_way_tool_rect (integer player_nr, integer tool_id, way_types wt, coord default_paramter, coord pos_nw, any_x pos_se)
 
static void rules::allow_way_tool_cube (integer player_nr, integer tool_id, way_types wt, coord3d default_paramter, coord3d pos_nw, any_x pos_se)
 
static void rules::gui_needs_update ()
 
static string debug::get_forbidden_text ()
 
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()

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.

◆ allow_way_tool_cube()

static void rules::allow_way_tool_cube ( integer  player_nr,
integer  tool_id,
way_types  wt,
coord3d  default_paramter,
coord3d  pos_nw,
any_x  pos_se 
)
static

Allow tool with certain waytype within cubic region on the map.

Parameters
player_nrnumber of player this rule applies to, if this is set to player_all then this acts for all players except public player
tool_idid of tool
wtwaytype
default_paramterobject name or 0 (to catch all)
pos_nw3d-coordinate of north-western corner of cube
pos_se3d-coordinate of south-eastern corner of cube
See also
tool_ids way_types player_all
Note
Only available in scenario mode.

◆ allow_way_tool_rect()

static void rules::allow_way_tool_rect ( integer  player_nr,
integer  tool_id,
way_types  wt,
coord  default_paramter,
coord  pos_nw,
any_x  pos_se 
)
static

Allow tool with certain waytype within rectangular region on the map.

Parameters
player_nrnumber of player this rule applies to, if this is set to player_all then this acts for all players except public player
tool_idid of tool
wtwaytype
default_paramterobject name or 0 (to catch all)
pos_nwcoordinate of north-western corner of rectangle
pos_secoordinate of south-eastern corner of rectangle
See also
tool_ids way_types player_all
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

◆ clear()

static void rules::clear ( )
static

Clear all forbidding rules, effectively allowing all tools again that were forbidden using functions of the table rules.

Only effects tools forbidden by rules::forbid_tool, rules::forbid_way_tool, rules::forbid_way_tool_cube, rules::forbid_way_tool_rect. The result of is_tool_allowed and is_work_allowed_here is not influenced.

Note
Only available in scenario mode.

◆ clear_forbid_tool()

static void rules::clear_forbid_tool ( any_x  player_nr,
any_x  tool_id 
)
static

Allow again an internal tool.

Parameters
player_nrnumber of player this rule applies to, if this is set to player_all then this acts for all players except public player
tool_idid of tool
See also
tool_ids way_types player_all
Note
Only available in scenario mode.

◆ clear_forbid_way_tool()

static void rules::clear_forbid_way_tool ( any_x  player_nr,
any_x  tool_id,
any_x  wt,
any_x  default_paramter 
)
static

clear fule with certain waytype.

Parameters
player_nrnumber of player this rule applies to, if this is set to player_all then this acts for all players except public player
tool_idid of tool
wtwaytype
default_paramterobject name or 0 (to catch all)
See also
tool_ids way_types player_all
Note
Only available in scenario mode.

◆ clear_player()

static void rules::clear_player ( )
static

Clear all forbidding rules for a selec player

Only effects tools forbidden by rules::forbid_tool, rules::forbid_way_tool, rules::forbid_way_tool_cube, rules::forbid_way_tool_rect. The result of is_tool_allowed and is_work_allowed_here is not influenced.

Note
Only available in scenario mode.

◆ clear_way_tool_cube()

static void rules::clear_way_tool_cube ( any_x  player_nr,
any_x  tool_id,
any_x  wt,
any_x  default_paramter,
any_x  pos_nw,
any_x  pos_se,
any_x  allow 
)
static

clear rule with certain waytype within cubic region on the map.

Parameters
player_nrnumber of player this rule applies to, if this is set to player_all then this acts for all players except public player
tool_idid of tool
wtwaytype
default_paramterobject name or 0 (to catch all)
pos_nw3d-coordinate of north-western corner of cube
pos_se3d-coordinate of south-eastern corner of cube
allowclear either allo (true) or forbid (false) rule
See also
tool_ids way_types player_all
Note
Only available in scenario mode.

◆ clear_way_tool_rect()

static void rules::clear_way_tool_rect ( any_x  player_nr,
any_x  tool_id,
any_x  wt,
any_x  default_paramter,
any_x  pos_nw,
any_x  pos_se,
any_x  allow 
)
static

clear rule with certain waytype within rectangular region on the map.

Parameters
player_nrnumber of player this rule applies to, if this is set to player_all then this acts for all players except public player
tool_idid of tool
wtwaytype
default_paramterobject name or 0 (to catch all)
pos_nwcoordinate of north-western corner of rectangle
pos_secoordinate of south-eastern corner of rectangle
allowclear either allo (true) or forbid (false) rule
See also
tool_ids way_types player_all
Note
Only available in scenario mode.

◆ forbid_tool()

static void rules::forbid_tool ( integer  player_nr,
integer  tool_id 
)
static

Forbid an internal tool.

Parameters
player_nrnumber of player this rule applies to, if this is set to player_all then this acts for all players except public player
tool_idid of tool
See also
tool_ids way_types player_all
Note
Only available in scenario mode.

◆ forbid_way_tool()

static void rules::forbid_way_tool ( integer  player_nr,
integer  tool_id,
way_types  wt,
any_x  default_paramter 
)
static

Forbid an internal tool with certain waytype.

Parameters
player_nrnumber of player this rule applies to, if this is set to player_all then this acts for all players except public player
tool_idid of tool
wtwaytype
default_paramterobject name or null (to catch all)
See also
tool_ids way_types player_all
Note
Only available in scenario mode.

◆ forbid_way_tool_cube()

static void rules::forbid_way_tool_cube ( integer  player_nr,
integer  tool_id,
way_types  wt,
coord3d  default_paramter,
coord3d  pos_nw,
string  pos_se,
any_x  err 
)
static

Forbid an internal tool with certain waytype within cubic region on the map.

Parameters
player_nrnumber of player this rule applies to, if this is set to player_all then this acts for all players except public player
tool_idid of tool
wtwaytype
default_paramterobject name or null (to catch all)
pos_nw3d-coordinate of north-western corner of cube
pos_se3d-coordinate of south-eastern corner of cube
errerror message presented to user when trying to apply this tool, see also is_work_allowed_here
See also
tool_ids way_types player_all
Note
Only available in scenario mode.

◆ forbid_way_tool_rect()

static void rules::forbid_way_tool_rect ( integer  player_nr,
integer  tool_id,
way_types  wt,
coord  default_paramter,
coord  pos_nw,
string  pos_se,
any_x  err 
)
static

Forbid an internal tool with certain waytype within rectangular region on the map.

Parameters
player_nrnumber of player this rule applies to, if this is set to player_all then this acts for all players except public player
tool_idid of tool
wtwaytype
default_paramterobject name or null (to catch all)
pos_nwcoordinate of north-western corner of rectangle
pos_secoordinate of south-eastern corner of rectangle
errerror message presented to user when trying to apply this tool, see also is_work_allowed_here
See also
tool_ids way_types player_all
Note
Only available in scenario mode.

◆ 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)

◆ get_forbidden_text()

static string debug::get_forbidden_text ( )
static
Returns
text containing all active rules, can be used in get_debug_text
Note
Only available in scenario mode.

◆ gui_needs_update()

static void rules::gui_needs_update ( )
static

Signals that toolbars and active tools need to be checked against scenario rules again.

Note
Only available in scenario mode.

◆ 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