Introduction to Arma Scripting: Difference between revisions
Lou Montana (talk | contribs) m (Fix the fix ><) |
|||
(13 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{SideTOC}} | ||
{{wip}} | |||
== Introduction == | |||
This page should give beginners an overview of how to begin with scripting and where to find most of the information they need in the beginning. Some information might not be complete and can be found on other wiki pages. | |||
During [[ArmA: Mission Editing|mission editing]] and [[ArmA: Addon Editing|addon editing]] you may come across situations where actions or features you would like to have in your mission or addon cannot be accomplished using the basic (or even the more advanced) capabilities of the [[ArmA: Mission Editor|mission editor]] or within config files (in the case of addons). Some examples of this might be really cinematic cutscenes in missions or special animations for an addon. | During [[ArmA: Mission Editing|mission editing]] and [[ArmA: Addon Editing|addon editing]] you may come across situations where actions or features you would like to have in your mission or addon cannot be accomplished using the basic (or even the more advanced) capabilities of the [[ArmA: Mission Editor|mission editor]] or within config files (in the case of addons). Some examples of this might be really cinematic cutscenes in missions or special animations for an addon. | ||
The '''solution''' to this is to take advantage of the game-engines ability to call on an even more advanced feature known as [[Scripting|scripting]]. [[Armed Assault|Armed Assault's]] '''scripting language''' gives you more direct control of core game commands. With any combination of these '''[[:Category: Scripting Commands|commands]]''' and '''[[:Category: Functions|functions]]''' you can then create custom processes that meet the specific needs of your mission or addon. | |||
== Terms == | == Terms == | ||
Before getting started, you should understand the meaning of these terms. | Before getting started, you should understand the meaning of these terms. | ||
'''Data Types''': | |||
See [[Data Types]] | |||
'''Algorithm''': | |||
In mathematics and computer science, an algorithm is an explicit specification of how to solve a class of problems. Algorithms can perform calculation, data processing and automated reasoning tasks. | |||
'''Interpreter''': | |||
Reads your code from a script file and translates it into instructions for you to achieve your desired outcome/effect in the game. | |||
'''Control Structures''': | |||
See [[Control Structures]] | |||
'''Syntax''': | |||
* See [[SQF syntax]] | |||
* See [[SQS syntax]] (obsolete) | |||
'''Script''': | |||
When speaking about a [[Script (File)|script]], we usually mean a .sqs or .sqf file. | |||
'''Game Engine''': | |||
The core program of the game which reads and executes your scripting commands at run time. | |||
'''Function''': | |||
See [[Function]] | |||
'''Variables''': | |||
: | See [[Variables]] | ||
'''Operators''': | |||
See [[Operators]] | |||
<!-- | |||
= The things to ask yourself beforehand = | |||
{{note|Be careful: Scripting isn't a solution to everything. }} | {{note|Be careful: Scripting isn't a solution to everything. }} | ||
=== Is it not possible to do this in the editor? === | === Is it not possible to do this in the editor? === | ||
* [[Eden Editor]] is an incredible powerful tool and with it alone one can achive a lot of things, even without writing a single line of SQF. | * [[Eden Editor]] is an incredible powerful tool and with it alone one can achive a lot of things, even without writing a single line of SQF. | ||
Line 29: | Line 57: | ||
=== Can it be scripted by using SQF? === | === Can it be scripted by using SQF? === | ||
* This might be hard to answer, especially for beginners. Try to get as much information about what you want to do and what commands there are before spending time on writing a script, just to find out it’s #not possible in the end. | * This might be hard to answer, especially for beginners. Try to get as much information about what you want to do and what commands there are before spending time on writing a script, just to find out it’s #not possible in the end. | ||
*Should any question above be answered with ‘’’Yes’’’, then you should rethink your approach. | |||
--> | |||
== Recommended programs == | |||
The following programms are recommended when working with sqf, sqs, cpp or many other file types. Most of them offer syntax highlighting and other useful features. Check them out and select the one you like the most. | |||
* [https://code.visualstudio.com/download Visual Studio Code] (with SQF plugin) | |||
* [https://notepad-plus-plus.org/ Notepad++] | |||
* [http://www.geany.org/ Geany] | |||
* [https://atom.io/ Atom] | |||
* [[Poseidon Tools]] | |||
* [https://www.eclipse.org/ Eclipse] with [https://forums.bohemia.net/forums/topic/202181-sqdev-sqf-developing-in-eclipse/ SQDev] | |||
<!-- | |||
== The Concept == | == The Concept == | ||
Scripts are an essential part of making missions. They allow you to create amazing cutscenes, create effects and customize almost every aspect of your mission. Some diverse examples of what could be scripted are: a simulation of artillery fire, a poisonous gas cloud, or a money system for purchasing equipment. | Scripts are an essential part of making missions. They allow you to create amazing cutscenes, create effects and customize almost every aspect of your mission. Some diverse examples of what could be scripted are: a simulation of artillery fire, a poisonous gas cloud, or a money system for purchasing equipment. | ||
--><!-- | |||
===Let's start=== | ===Let's start=== | ||
Line 106: | Line 93: | ||
If you want to try our 'script', create a mission in the mission editor, save it as ''testingmission'', open your favorite text edtior (eg. Notepad), write <code>[[titleText]]["Good morning, captain", "PLAIN DOWN"];</code>and save it as ''hello.sqf'' to gamefolder/user/yourname/missions/testingmission. Then add a soldier in the mission editor and type <code>nul = [] [[execVM]] "hello.sqf"</code> to his initialization line. When you run this mission, you should see output of your first script. Well done, soldier! (If you are confused from this quantum of informations, don't panic, more continuously explanation follows.) | If you want to try our 'script', create a mission in the mission editor, save it as ''testingmission'', open your favorite text edtior (eg. Notepad), write <code>[[titleText]]["Good morning, captain", "PLAIN DOWN"];</code>and save it as ''hello.sqf'' to gamefolder/user/yourname/missions/testingmission. Then add a soldier in the mission editor and type <code>nul = [] [[execVM]] "hello.sqf"</code> to his initialization line. When you run this mission, you should see output of your first script. Well done, soldier! (If you are confused from this quantum of informations, don't panic, more continuously explanation follows.) | ||
== Scripting Code == | == Scripting Code == | ||
The core of scripting is '''scripting code'''. The code consists of [[:Category | The core of scripting is '''scripting code'''. The code consists of [[:Category:Scripting Commands|scripting commands]] that tell the game engine what to do. These commands are executed one after another. | ||
The code is written into special fields of the [[ArmA: Mission Editor|mission editor]] (see below) or into separate files that are executed at some defined point (i.e. through [[Triggers|triggers]]) during the running mission. | The code is written into special fields of the [[ArmA: Mission Editor|mission editor]] (see below) or into separate files that are executed at some defined point (i.e. through [[Triggers|triggers]]) during the running mission. | ||
=== Layout === | === Layout === | ||
Line 210: | Line 174: | ||
Writing the code | Writing the code | ||
--> | |||
== Debugging == | |||
* [[Debugging Techniques]] | |||
* [[ | == Optimisation == | ||
* [[ | |||
* [[ | * [[Code Optimisation]] | ||
* [[Mission Optimisation]] | |||
== Useful Links == | |||
These links offer a great deal of information about [[Scripting]]: | |||
* [[:Category:Example Code|Example Code]] | |||
* [[Control Structures]] | * [[Control Structures]] | ||
* [[Multiplayer Scripting]] | |||
* [[Exception handling]] | * [[Exception handling]] | ||
* [[Script (File)]] | * [[Script (File)]] | ||
* [[Function]] | * [[Function]] | ||
* [[SQS to SQF conversion]] | * [[SQS to SQF conversion]] | ||
[[ | Additionally, the following are more resources for more general learning: | ||
* [[6thSense.eu:EG]] | |||
* [http://www.armaholic.com/page.php?id=20465 Fockers Arma 3 Scripting Guide] | |||
* [http://www.armaholic.com/page.php?id=4847 Mr-Murray's Armed Assault Editing Guide - Deluxe Edition] | |||
* [https://www.youtube.com/watch?v=WmEBN-RbK44 Excellent German SQF tutorial] | |||
[[Category:Scripting Topics]] | |||
[[Category:Operation Flashpoint: Editing]] | |||
[[Category:ArmA: Editing]] | |||
[[Category:ArmA 2: Editing]] | |||
[[Category:Arma 3: Editing]] |
Revision as of 20:11, 17 August 2019
Introduction
This page should give beginners an overview of how to begin with scripting and where to find most of the information they need in the beginning. Some information might not be complete and can be found on other wiki pages.
During mission editing and addon editing you may come across situations where actions or features you would like to have in your mission or addon cannot be accomplished using the basic (or even the more advanced) capabilities of the mission editor or within config files (in the case of addons). Some examples of this might be really cinematic cutscenes in missions or special animations for an addon.
The solution to this is to take advantage of the game-engines ability to call on an even more advanced feature known as scripting. Armed Assault's scripting language gives you more direct control of core game commands. With any combination of these commands and functions you can then create custom processes that meet the specific needs of your mission or addon.
Terms
Before getting started, you should understand the meaning of these terms.
Data Types: See Data Types
Algorithm: In mathematics and computer science, an algorithm is an explicit specification of how to solve a class of problems. Algorithms can perform calculation, data processing and automated reasoning tasks.
Interpreter: Reads your code from a script file and translates it into instructions for you to achieve your desired outcome/effect in the game.
Control Structures: See Control Structures
Syntax:
- See SQF syntax
- See SQS syntax (obsolete)
Script: When speaking about a script, we usually mean a .sqs or .sqf file.
Game Engine: The core program of the game which reads and executes your scripting commands at run time.
Function: See Function
Variables: See Variables
Operators: See Operators
Recommended programs
The following programms are recommended when working with sqf, sqs, cpp or many other file types. Most of them offer syntax highlighting and other useful features. Check them out and select the one you like the most.
- Visual Studio Code (with SQF plugin)
- Notepad++
- Geany
- Atom
- Poseidon Tools
- Eclipse with SQDev
Debugging
Optimisation
Useful Links
These links offer a great deal of information about Scripting:
- Example Code
- Control Structures
- Multiplayer Scripting
- Exception handling
- Script (File)
- Function
- SQS to SQF conversion
Additionally, the following are more resources for more general learning: