Simutrans-Squirrel-API
Functions
Scenario interface

Functions

string get_about_text (integer pl)
 
string get_debug_text (integer pl)
 
string get_goal_text (integer pl)
 
string get_info_text (integer pl)
 
string get_result_text (integer pl)
 
string get_rule_text (integer pl)
 
integer is_scenario_completed (integer pl)
 
void start ()
 

Detailed Description

The following methods are vital for the functioning of a scripted scenario. They will be called from simutrans to interact with the script. You should consider implementing them.

Function Documentation

◆ get_about_text()

string get_about_text ( integer  pl)

Text shown in the 'About' tab in the scenario info window.

There is a default implementation, which returns concatenation of scenario author, version, short_description. Html-like tags can be used, see get_rule_text.

Parameters
plplayer number of active player

◆ get_debug_text()

string get_debug_text ( integer  pl)

Text shown in the 'Debug' tab in the scenario info window. If the method returns null then the 'Debug'-tab will not be shown.

Html-like tags can be used, see get_rule_text.

Parameters
plplayer number of active player

◆ get_goal_text()

string get_goal_text ( integer  pl)

Text shown in the 'Goal' tab in the scenario info window.

Html-like tags can be used, see get_rule_text.

Parameters
plplayer number of active player

◆ get_info_text()

string get_info_text ( integer  pl)

Text shown in the 'Info' tab in the scenario info window.

Html-like tags can be used, see get_rule_text.

Parameters
plplayer number of active player

◆ get_result_text()

string get_result_text ( integer  pl)

Text shown in the 'Result' tab in the scenario info window.

Html-like tags can be used, see get_rule_text.

Parameters
plplayer number of active player

◆ get_rule_text()

string get_rule_text ( integer  pl)

Text shown in the 'Rules' tab in the scenario info window.

Text can contain several html-like tags:

  • <p>, <br>: line break
  • <h1>, <em>, <it>, <st>: text between start and end tag will be colored. It's a matter of taste, of course.
  • <a href="...">: insert hyper link, text between start and end tag will be colored blue.
    • link to another tab of scenario info window: href="tabname", where tabname is one of: info, goal, rules, result, about
    • link to position on the map: href="(x,y)" or href="(x,y,z)", click on link will jump to the map position
    • call scripted method: href="script:bla(1)" will call bla(1). The characters >, ', " are not allowed in the string and will produce weird results. The called method should return quickly.
<h1>Here is an example.</h1>
<br>
Do not build anything at the position <a href='(47,11)'>near Cologne</a>.
The mayor of <a href='(8,15)'>Berlin</a> seems to be frustrated with your airport building capabilities.
<br>
Your results can be found in the <a href='result'>results</a> tab.
Parameters
plplayer number of active player

◆ is_scenario_completed()

integer is_scenario_completed ( integer  pl)

Core function of a scenario: It returns the completion percentage for the specified player.

If it returns a negative value the respective player has lost. This state will not be changed even if the function later returns positive values again.

If it returns a value >= 100 then the respective player has won. This state will not be changed even if the function later returns lower values again.

Parameters
plplayer number of active player

◆ start()

void start ( )

This function is called when the scenario starts. Do all the initializations here, as you cannot initialize global variables with non-built-in squirrel types.