User Tools

Site Tools


arma:scripting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
arma:scripting [2009-04-01 00:27]
snakeman fixed code formatting. added live execVM tip.
arma:scripting [2011-08-15 09:30]
snakeman added global scripts dir header.
Line 6: Line 6:
  
 In a nutshell you never ever should create ArmA SQS content anymore, always create only SQF scripts. In a nutshell you never ever should create ArmA SQS content anymore, always create only SQF scripts.
 +
 +
 +====== Introduction to ArmA scripting ======
 +
 +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 scripting commands 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 some of these terms.
 +
 +**Script**
 +
 +When speaking about a script, it is generally considered a .sqs file, the same can be said for functions, since functions are a kind of script as well, the file ends with a .sqf. Both file types can be edited as a plain text file. 
 +
 +**Game Engine**
 +
 +The core program of the game which reads and executes your scripting commands at run time. 
  
  
Line 42: Line 62:
 {if (condition) then {DoSomething1;​ DoSomething2;​ DoSomething3;​ DoSomething4;​ DoSomething5;​};​} foreach array; {if (condition) then {DoSomething1;​ DoSomething2;​ DoSomething3;​ DoSomething4;​ DoSomething5;​};​} foreach array;
 </​code>​ </​code>​
 +
  
 ====== Comments ====== ====== Comments ======
Line 67: Line 88:
  
 Quotes are no longer a valid substitute for braces. Quotes are no longer a valid substitute for braces.
 +
  
 ====== Some SQF things ====== ====== Some SQF things ======
Line 99: Line 121:
 // valid, but RETURN_VALUE is not saved anywhere // valid, but RETURN_VALUE is not saved anywhere
 </​code>​ </​code>​
 +
  
 ====== Private ====== ====== Private ======
Line 108: Line 131:
 </​code>​ </​code>​
 Is to make the _local variables really a private ones in the SQF script. Is to make the _local variables really a private ones in the SQF script.
 +
  
 ====== Exit while loop ====== ====== Exit while loop ======
Line 127: Line 151:
 player sideChat "​Complete";​ player sideChat "​Complete";​
 </​code>​ </​code>​
 +
  
 ====== Switch ====== ====== Switch ======
Line 188: Line 213:
 }; };
 </​code>​ </​code>​
 +
  
 ====== Script to nil ====== ====== Script to nil ======
Line 201: Line 227:
 MyScript = nil; MyScript = nil;
 </​code>​ </​code>​
 +
  
 ====== Dynamic Variables ====== ====== Dynamic Variables ======
Line 219: Line 246:
 call compile format ["%1 = createTrigger [....]",​ _name]; call compile format ["%1 = createTrigger [....]",​ _name];
 </​code>​ </​code>​
 +
  
 ====== Misc PMC Example Scripts ====== ====== Misc PMC Example Scripts ======
Line 232: Line 260:
  
 You can now run a long mission and always bring new scripts into the play and so on. Imagine how many times have you play tested a mission and had to wrote down notes that "in this and that part you need to add XYZ", but now... you can just write a quick script (or use existing one) and add that to the runme.sqf and just call it up... script is run and you can proceed with the mission. Great. You can now run a long mission and always bring new scripts into the play and so on. Imagine how many times have you play tested a mission and had to wrote down notes that "in this and that part you need to add XYZ", but now... you can just write a quick script (or use existing one) and add that to the runme.sqf and just call it up... script is run and you can proceed with the mission. Great.
 +
 +
 +====== Global Scripts Dir ======
 +
 +Global scripts dir means that you can place your scripts under one single directory which all mission editor missions can read.
 +
 +In OFP you could place a directory in your OFP root dir called "​Scripts",​ ie d:​\ofp\scripts\ and when you ran a mission, if you called a script it would be first searched from the mission dir and if not found then in this directory. The usefulness of this is that if you have a campaign or similar where you use same script over and over again, its very cool to place it on this one "​common"​ dir instead of each and every mission dir. In campaigns it worked from <​campaign>​\scripts\ the same way.
 +
 +However in ArmA it appears it will not work from d:​\arma\Scripts\ anymore, BIS changed it a bit and now it can be found on:
 +<​code>​
 +<​your_profile_path>​\Users\<​your_nickname>​\Scripts\
 +</​code>​
arma/scripting.txt ยท Last modified: 2011-08-15 09:30 by snakeman