{"name":"Script File","title":"Script File","type":"topic","url":"https://community.bistudio.com/wiki/Script_File","revid":364510,"updated":"2024-05-16T20:42:07Z","aliases":["Script (File)"],"markdown":"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.\n\n> [!NOTE]\n> See Community Tools - Code Edition for recommended text editors.\n\n### Syntax\n\nIn Operation Flashpoint, scripts are limited to SQS Syntax.\n\n- See exec\n\nThe 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.\n\n- See execVM, spawn\n\n### Execution\n\nScripts can be executed from several points in the game:\n\n- Other scripts\n- Other functions\n- Init fields and (de)activation triggers in the Mission Editor\n- Event Handlers in addon config files\n\nThe commands to execute scripts are:\n\n**exec:** exec starts a thread for a script in SQS Syntax.\n\n**execVM:** execVM preprocesses and compiles a SQF Syntax script file and starts a thread for it.\n\n**call:** call adds provided Code to the stack and wait for it to execute, then returns the code's last returned value.\n\n**spawn:** spawn starts a thread for provided Code.\n\n> [!NOTE]\n> - execVM is almost like using `[] spawn compile preprocessFile`.\n> - spawn and execVM both add the thread to the Scheduler and provide a script handle which allows you to check if the spawned script is done (using scriptDone).\n\n### See also\n\n- Functions\n- Syntax\n  - SQF Syntax\n  - SQS Syntax\n- Statement","sections":[{"heading":null,"level":1,"markdown":"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.\n\n> [!NOTE]\n> See Community Tools - Code Edition for recommended text editors."},{"heading":"Syntax","level":3,"markdown":"In Operation Flashpoint, scripts are limited to SQS Syntax.\n\n- See exec\n\nThe 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.\n\n- See execVM, spawn"},{"heading":"Execution","level":3,"markdown":"Scripts can be executed from several points in the game:\n\n- Other scripts\n- Other functions\n- Init fields and (de)activation triggers in the Mission Editor\n- Event Handlers in addon config files\n\nThe commands to execute scripts are:\n\n**exec:** exec starts a thread for a script in SQS Syntax.\n\n**execVM:** execVM preprocesses and compiles a SQF Syntax script file and starts a thread for it.\n\n**call:** call adds provided Code to the stack and wait for it to execute, then returns the code's last returned value.\n\n**spawn:** spawn starts a thread for provided Code.\n\n> [!NOTE]\n> - execVM is almost like using `[] spawn compile preprocessFile`.\n> - spawn and execVM both add the thread to the Scheduler and provide a script handle which allows you to check if the spawned script is done (using scriptDone)."},{"heading":"See also","level":3,"markdown":"- Functions\n- Syntax\n  - SQF Syntax\n  - SQS Syntax\n- Statement"}],"categories":["Scripting Topics"],"groups":["Scripting"]}