Script File: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\{\{( *)Informative( *)\|" to "{{$1Feature$2|$2Informative$2|")
m (Lou Montana moved page Script (File) to Script File: name standard)
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{TOC|side}}
{{TOC|side}}
A [[{{PAGENAME}}|script file]] is multiple commands and arguments defining wanted behaviour from the game, all grouped together in a textfile. This code does a specific task handled by the game engine. The common extensions for Arma scripts are '''.sqf''' and '''.sqs''', depending on the used syntax: [[SQF syntax|SQF]] or (deprecated) [[SQS syntax]].
A [[{{PAGENAME}}|script file]] is multiple commands and arguments defining wanted behaviour from the game, all grouped together in a textfile. This code does a specific task handled by the game engine. The common extensions for Arma scripts are '''.sqf''' and '''.sqs''', depending on the used syntax: [[SQF Syntax|SQF]] or (deprecated) [[SQS Syntax]].
{{Feature | Informative | See [[:Category:Community Tools#Code Edition|Community Tools - Code Edition]] for recommended text editors.}}
{{Feature | Informative | See [[:Category:Community Tools#Code Edition|Community Tools - Code Edition]] for recommended text editors.}}


Line 6: Line 6:
== Syntax ==
== Syntax ==


In [[:Category:Operation Flashpoint|{{ofp}}]], scripts are limited to [[SQS syntax]].
In [[:Category:Operation Flashpoint|{{ofp}}]], scripts are limited to [[SQS Syntax]].
* See [[exec]]
* See [[exec]]


The already existing (since OFP v1.85) [[SQF syntax]] was introduced for scripts in [[{{arma1}}]]. [[SQS syntax]] is still usable but is considered deprecated since.
The already existing (since {{ofp}} v1.85) [[SQF Syntax]] was introduced for scripts in [[:Category:ArmA: Armed Assault|{{arma1}}]]. [[SQS Syntax]] is still usable but is considered deprecated since.
* See [[execVM]], [[spawn]]
* See [[execVM]], [[spawn]]




[[Image: Script_Execution.png|frame|right||Script Execution Diagram<br>'''Executing Instance:''' script, [[Function|function]] or game engine]]
[[Image: Script_Execution.png|frame|right||Script Execution Diagram<br>'''Executing Instance:''' script, [[Function|function]] or game engine]]
== Execution ==
== Execution ==


Line 27: Line 28:


; exec
; exec
: [[exec]] starts a thread for a script in [[SQS syntax]].
: [[exec]] starts a thread for a script in [[SQS Syntax]].


; execVM
; execVM
: [[execVM]] [[preprocessFileLineNumbers|preprocesses]] and [[compile|compiles]] a [[SQF syntax]] script file and starts a thread for it.
: [[execVM]] [[preprocessFileLineNumbers|preprocesses]] and [[compile|compiles]] a [[SQF Syntax]] script file and starts a thread for it.


; call
; call
Line 39: Line 40:


{{Feature | Informative |
{{Feature | Informative |
* [[execVM]] is almost like using {{Inline code|[[spawn]] [[compile]] [[preprocessFile]]}}.
* [[execVM]] is almost like using {{ic|[[spawn]] [[compile]] [[preprocessFile]]}}.
* [[spawn]] and [[execVM]] both add the thread to the [[Scheduler]] and provide a [[Script (Handle)|script handle]] which allows you to check if the spawned script is done (using [[scriptDone]]).}}
* [[spawn]] and [[execVM]] both add the thread to the [[Scheduler]] and provide a [[Script Handle|script handle]] which allows you to check if the spawned script is done (using [[scriptDone]]).}}




Line 47: Line 48:
* [[Function|Functions]]
* [[Function|Functions]]
* [[:Category:Syntax|Syntax]]
* [[:Category:Syntax|Syntax]]
** [[SQF syntax]]
** [[SQF Syntax]]
** [[SQS syntax]]
** [[SQS Syntax]]
* [[Statement]]
* [[Statement]]




[[Category:Scripting Topics]]
[[Category:Scripting Topics]]

Revision as of 19:18, 28 August 2021

A script file is multiple commands and arguments defining wanted behaviour from the game, all grouped together in a textfile. This code does a specific task handled by the game engine. The common extensions for Arma scripts are .sqf and .sqs, depending on the used syntax: SQF or (deprecated) SQS Syntax.

See Community Tools - Code Edition for recommended text editors.


Syntax

In Operation Flashpoint, scripts are limited to SQS Syntax.

The already existing (since Operation Flashpoint v1.85) SQF Syntax was introduced for scripts in Armed Assault. SQS Syntax is still usable but is considered deprecated since.


Script Execution Diagram
Executing Instance: script, function or game engine

Execution

Scripts can be executed from several points in the game:


The commands to execute scripts are:

exec
exec starts a thread for a script in SQS Syntax.
execVM
execVM preprocesses and compiles a SQF Syntax script file and starts a thread for it.
call
call adds provided Code to the stack and wait for it to execute, then returns the code's last returned value.
spawn
spawn starts a thread for provided Code.


See also