A simple example script

Let us inspect a sample script file. We will have a look into the pak64 Millionaire scenario. The objective of this scenario is to get rich as fast as possible.

As first the savegame is specified:
map.file = "millionaire.sve"
Then we provide some meta-information about the scenario
scenario.short_description = "Millionaire" = "prissi (scripting by Dwachs)"
scenario.version = "0.1"
Rules and goals are not that special. The texts returned in this functions will be shown in the scenario info window. String constants with leading '@' can span multiple lines.
function get_rule_text(pl)
return ttext("No limits.")
function get_goal_text(pl)
return ttext("Become millionaire as fast as possible.")
function get_info_text(pl)
return ttext("You started a small transport company to become rich. Your grandparents did not have a glue, where all their money flows into.")
The method presenting the result text is a little bit more advanced. If the player has enough cash, he has won the scenario.
function get_result_text(pl)
local cash = get_cash(pl)
local text = ttext("Your bank account is worth {tcash}.")
The get_cash() method accesses the player's bank account via, which is equivalent to calling player_x.get_cash().
text.tcash = cash
local text2 = ""
if ( cash >= 1000000 )
text2 = ttext("<it>Congratulation!</it><br> <br> You won the scenario!")
text2 = ttext("You still have to work a little bit harder.")
return text + "<br> <br>" + text2
Last but not least, the function that computes the actual progress in the scenario. If it returns a negative value, the player has lost. If the return value is larger than 100, this is equivalent to winning the scenario.
function get_cash(pl)
return player_x(pl).cash[0]