Script File: Difference between revisions
Jump to navigation
Jump to search
m (link fix) |
Lou Montana (talk | contribs) (Page refresh) |
||
Line 1: | Line 1: | ||
{{ | {{SideTOC}} | ||
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]]. | |||
{{Informative | See [[:Category:Community Tools#Code Edition|Community Tools - Code Edition]] for recommended text editors.}} | |||
== Syntax == | |||
== | |||
In [[{{ofp}}]], scripts are limited to [[SQS syntax]]. | |||
* See [[exec]] | |||
The already existing (since OFP v1.85) [[SQF syntax]] was introduced for scripts in [[{{arma}}]]. [[SQS syntax]] is still usable but is considered deprecated since. | |||
* See [[execVM]], [[spawn]] | |||
[[Image: Script_Execution.png|frame|right||Script Execution Diagram<br>'''Executing Instance:''' script, [[Function|function]] or game engine]] | |||
== Execution == | == Execution == | ||
Scripts can be executed from several points in the game: | Scripts can be executed from several points in the game: | ||
Line 25: | Line 20: | ||
* Other scripts | * Other scripts | ||
* Other [[Function|functions]] | * Other [[Function|functions]] | ||
* | * Init fields and (de)actication triggers in the [[Mission Editor]] | ||
* [[:Category:Event Handlers|Event Handlers]] in addon config files | * [[:Category:Event Handlers|Event Handlers]] in addon config files | ||
Line 34: | Line 29: | ||
: [[exec]] starts a thread for a script in [[SQS syntax]]. | : [[exec]] starts a thread for a script in [[SQS syntax]]. | ||
; execVM | ; execVM | ||
: [[execVM]] [[ | : [[execVM]] [[preprocessFileLineNumbers|preprocesses]] and [[compile|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]]. | ||
{{Informative | | |||
* [[execVM]] is ''almost'' like using {{Inline code|[[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]]).}} | |||
== See also == | == See also == | ||
* [[Function|Functions]] | * [[Function|Functions]] | ||
* [[SQF syntax]] | * [[:Category:Syntax|Syntax]] | ||
* [[SQS syntax]] | ** [[SQF syntax]] | ||
** [[SQS syntax]] | |||
* [[Statement]] | * [[Statement]] | ||
[[Category:Scripting Topics]] | [[Category:Scripting Topics]] |
Revision as of 13:51, 14 March 2020
Template:SideTOC 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.
Syntax
In Operation Flashpoint, scripts are limited to SQS syntax.
- See exec
The already existing (since OFP v1.85) SQF syntax was introduced for scripts in Arma. SQS syntax is still usable but is considered deprecated since.
Execution
Scripts can be executed from several points in the game:
- Other scripts
- Other functions
- Init fields and (de)actication triggers in the Mission Editor
- Event Handlers in addon config files
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.