arma:scripting
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
arma:scripting [2008/04/30 15:24] – added bunch of info to the scripting. snakeman | arma:scripting [2009/04/01 00:27] – fixed code formatting. added live execVM tip. snakeman | ||
---|---|---|---|
Line 15: | Line 15: | ||
Example: | Example: | ||
- | < | + | < |
var = [player] execVM " | var = [player] execVM " | ||
</ | </ | ||
Line 24: | Line 24: | ||
ArmA has "" | ArmA has "" | ||
- | < | + | < |
{ | { | ||
if (condition) then | if (condition) then | ||
Line 39: | Line 39: | ||
Instead of the terrible ofp classic | Instead of the terrible ofp classic | ||
- | < | + | < |
{if (condition) then {DoSomething1; | {if (condition) then {DoSomething1; | ||
</ | </ | ||
Line 47: | Line 47: | ||
Comments are no longer the same character as the end of command character. | Comments are no longer the same character as the end of command character. | ||
- | < | + | < |
// my comment | // my comment | ||
instead of | instead of | ||
Line 55: | Line 55: | ||
You can use block comments now. | You can use block comments now. | ||
- | < | + | < |
/* | /* | ||
Comment line 1 | Comment line 1 | ||
Line 72: | Line 72: | ||
Some misc SQF things here ;) | Some misc SQF things here ;) | ||
- | < | + | < |
_resultArray = [0,"" | _resultArray = [0,"" | ||
_handle = [_resultArray] execVM " | _handle = [_resultArray] execVM " | ||
Line 82: | Line 82: | ||
And | And | ||
- | < | + | < |
myFunction1 = compile loadFile " | myFunction1 = compile loadFile " | ||
myFunction2 = compile preprocessFile " | myFunction2 = compile preprocessFile " | ||
Line 92: | Line 92: | ||
Return value? | Return value? | ||
- | < | + | < |
value = call compile preprocessFile " | value = call compile preprocessFile " | ||
// value is now RETURN_VALUE | // value is now RETURN_VALUE | ||
Line 104: | Line 104: | ||
Using the private list. | Using the private list. | ||
- | < | + | < |
- | private [" | + | private [" |
</ | </ | ||
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. | ||
Line 111: | Line 111: | ||
====== Exit while loop ====== | ====== Exit while loop ====== | ||
- | < | + | < |
if (condition) exitWith {Code} | if (condition) exitWith {Code} | ||
Line 117: | Line 117: | ||
</ | </ | ||
- | and | + | And |
- | < | + | < |
for " | for " | ||
{ | { | ||
Line 133: | Line 133: | ||
Example 1 | Example 1 | ||
- | < | + | < |
switch (_a) do | switch (_a) do | ||
{ | { | ||
Line 152: | Line 152: | ||
Example 2 | Example 2 | ||
- | < | + | < |
switch (_a) do | switch (_a) do | ||
{ | { | ||
Line 171: | Line 171: | ||
Example 3 | Example 3 | ||
- | < | + | < |
switch (_a) do | switch (_a) do | ||
{ | { | ||
Line 192: | Line 192: | ||
When you have script like this | When you have script like this | ||
- | < | + | < |
MyScript = compile preProcessFile " | MyScript = compile preProcessFile " | ||
</ | </ | ||
Line 198: | Line 198: | ||
When you want to unload the script, set MyScript equal to nil. | When you want to unload the script, set MyScript equal to nil. | ||
- | < | + | < |
MyScript = nil; | MyScript = nil; | ||
</ | </ | ||
Line 204: | Line 204: | ||
====== Dynamic Variables ====== | ====== Dynamic Variables ====== | ||
- | Dynamic variables are very cool, sometimes on those random/comples | + | Dynamic variables are very cool, sometimes on those random / complex |
- | < | + | < |
_MyVariable = 20; | _MyVariable = 20; | ||
_MyVariableContent = " | _MyVariableContent = " | ||
Line 215: | Line 215: | ||
Another example | Another example | ||
- | < | + | < |
_name = format [" | _name = format [" | ||
call compile format ["%1 = createTrigger [....]", | call compile format ["%1 = createTrigger [....]", | ||
Line 223: | Line 223: | ||
Place random vehicles + some units on all found **pmc_** gamelogics script, [[arma: | Place random vehicles + some units on all found **pmc_** gamelogics script, [[arma: | ||
+ | |||
+ | |||
+ | ====== Running Scripts " | ||
+ | |||
+ | When you start your mission in mission editor, you can go and edit your scripts and then they are called the next time, they will be reloaded at the same time so your edits to them will be usable. | ||
+ | |||
+ | This is very nice feature to have, just run ArmA in window mode as you should always do when mission editing, then edit away and for example keep a " | ||
+ | |||
+ | 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. |
arma/scripting.txt · Last modified: 2024/08/01 10:46 by snakeman