This chapter will teach you have to call other scripts from another script. This way you can chain different script, I will also show you a way to use vectors as argument passing. It will also cover some new keywords such as format that will let you show variables!

Chaining scripts

Sometimes you might want a script to kick in when another script is done, this is very easy to implement since you can use the exec keyword in scripts as well.
I will show you an example:

The script is called countdown.sqs and will show a countdown timer.
When the timer reaches zero it will call another script that takes no parameters.


; Get the different passed data
_timeleft = _this select 0
_caption = _this select 1
_location = _this select 2
_script = _this select 3

; Wait 1 second

; Decrease the timer
_timeleft = _timeleft - 1
; Check whether the time is 0
? (_timeleft == 0) : goto "Done"
; Show the time left
TitleText [format [_caption + " %1", _timeleft], _location]
goto "Update"

; Execute the script
[] exec _script

The main part I want you to focus on is the second last line and the TitleText line.
The TitleText command looks really awful and is quite messy, this is because of the other keyword in it which name is format.
This is a really important keyword that will let you to convert variables (numbers) to strings (text). The syntax is as follows.

Format [