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" scenario.author =
"prissi (scripting by Dwachs)" 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.
{
return ttext(
"No limits.")
}
{
return ttext(
"Become millionaire as fast as possible.")
}
{
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.
{
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 player_x.cash, 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!")
else
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.