User Tools

Site Tools


arma2:scripting

Differences

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

Link to this comparison view

Next revision
Previous revision
arma2:scripting [2009-05-31 17:58]
snakeman created scripting initial page.
arma2:scripting [2015-06-08 03:24] (current)
Line 1: Line 1:
-====== Scripting ======+====== ​ArmA 2 Scripting ======
  
-**initJIPcompatible.sqf** is automatically started at unknown timebest guess would be when JIP player joins?+ArmA 2 will be largely compatible with Armed AssaultTo make porting of content from ArmA as simple as possiblethere are few important things:
  
 +  * using of undefined variable in scripts (nil value) will be in ArmA 2 strictly reported as an error. All variables used in any scripts must be initialized before first use.
  
-====== Scripting Commands ======+  * in ArmA 2 namespaces will be introduced for user scripts and variables. There are many low level reasons to do this and most of the content will be not be affected by this in any negative way. However, in order to be prepared, it is very important to separate UI related scripts and code as much as possible and not simply share global variables between UI and missions as UI namespace needs to be handled differently.
  
-There'​s a lot of cool scripts ​(functions) available ​in Modules.pbo - especially ​under "​Functions" ​and even an multiplayer Framework ​in "​MP"​.+  * in order to maintain smooth frame rate in real-time content, time limit for all scripts in each frame is enforced by the engine in ArmA 2Generally speaking, in case of more demanding scripts, be prepared that their result may come way later and also there probably can suffer from significant latency. It is under evaluation if and how possibly allow user scripts to change how much time they may take from the CPU in every frame.
  
-Since ArmA 2 you must first initialize a variable before you reference it in your scripts. In ArmA, it was not a problem, at least for conditions. +  * SQS script format will be fully supported in ArmA 2 (but they should never be used).
-<code cpp> +
-// this will error if myBoolean was not previously defined. +
-if (myBooleanthen { hint "​test"​ }; +
-</​code>​ +
-Usage of isNil is still valid.+
  
 +**initJIPcompatible.sqf** initJIPcompatible.sqf gets called from the MP mission framework (scripts in modules MP directory). A script waits until the player object is initialized and execs initJIPcompatible.sqf on clients (all clients, even those that were allready there at mission start as it is basically the same). Has nothing todo with init.sqf.
  
-===== BIS fnc locations =====+[[arma2:​scripting:​basics_of_sqf|Basics of SQF]]
  
-BIS fnc locations+Multiplayer [[arma2:​scripting:​dedicated_server_broadcasting|Dedicated server broadcasting]] to all clients.
  
-Description:​ Creates or registers location logics (used in various modules, like [[arma2:​editor_modules:​alice|Ambient Civilians]], ​[[arma2:editor_modules:silvie|Ambient Civilian Vehicles]] or Warfare 2).+Some [[arma2:scripting:code_optimization|Code optimization]] tips.
  
-Upon registering,​ function will set following variables into location logic'​s variable space:+[[arma2:scripting:​zone_markers|Zone Markers]] creating script for warning zones.
  
-  * "​class"​ - unique class of location (either BIS_loc_<​configname>​ or BIS_loc_custom_<​ID>​) +[[arma2:​scripting:​ied_usage|IED usage]] improvised explosive device usage through script.
-  * "​name"​ - name of location from config or setName commandIf none is defined, class is used +
-  * "​type"​ - config type +
-  * "​neighbors"​ - config defined neighbor locations ​+
  
-If you're registering currently existing object and some of variables above is already stored in it, it won't be replaced.+Few more [[arma2:​scripting:​comref|Scripting command reference]] items.
  
-Syntax+[[arma2:​scripting:​common_scripting_errors|Common scripting errors]] help you to debug your code.
  
-Syntax: ​[type(s),​area,​debugcall BIS_fnc_locations+[[arma2:​scripting:​group_in_vehicle|Group in Vehicle]check.
  
-Parameterstype(s)String or Array of strings\\ +[[arma2:scripting:bis_fnc_spawngroup|BIS_fnc_spawnGroup]] how to create whole groups from CfgGroups class.
-area: Array in format [center,​distance]\\ +
-debug: (Optional): Boolean+
  
-Return ValueArray - List of registered locations+[[arma2:scripting:​bis_fnc_findsafepos|BIS_fnc_findSafePos]] how to find safe position with open ground etc.
  
-Alternative Syntax+Global scripts dir or common scripts dir is very useful. This feature has been known since OFP, check out the details from [[arma:​scripting#​global_scripts_dir|ArmA:​ Scripting - Global scripts dir]], as same feature works in ArmA 2.
  
-Syntax: ​[objectscall BIS_fnc_locations+Howto create and use [[arma2:​scripting:​object-compositions|Object Compositions]in missions.
  
-ParametersobjectsArray of Objects or Locations - list of specific locations to be registered+[[arma2:scripting:addpublicvariableeventhandler|addPublicVariableEventhandler]] examples.
  
-Return ValueArray List of registered locations+[[arma2:scripting:​benchmark-cutscene|Benchmark Cutscene]]
  
-Examples +[[arma2:scripting:enablesaving|enableSaving]] and why its useful ​to disable.
- +
-Example 1: +
-<code cpp> +
-["​CityCenter",​[position player,​1000]] call bis_fnc_locations;​ +
-</​code>​ +
- +
-Example 2: +
-<code cpp> +
-[["​acityc_dolina"​]] call bis_fnc_locations;​ +
-</​code>​ +
- +
-Example 3: +
-<code cpp> +
-[[myLocation1,​myLocation2],[],true] call bis_fnc_locations;​ +
-</​code>​ +
- +
-See also: +
- +
-Functions Library (above hehe) +
- +
-===== allowDamage ===== +
- +
-Description:​ Allow an object to be damaged (or injured, or killed). +
- +
-Syntax: object allowDamage allow +
- +
-Parameters: object: Object - allow: Boolean - +
- +
-Example 1: +
-<code cpp> +
-player allowDamage false +
-</​code>​ +
- +
- +
-===== setVariable ===== +
- +
-setVariable now has a 3rd parameter: Global. +
- +
-If you set the 3rd parameter to true, the variable will broadcast ​its value to every machine. +
-<code cpp> +
-_myObject setVariable ["​myVariable",​ 1, true]; +
-</​code>​ +
- +
-setVariable is now usable on any object, like groups for instance. This was not the case in ArmA. +
- +
- +
-===== uiNameSpace ===== +
- +
-Working with UI related scripting commands, is not accepted in global or private variable space, and needs to be done inside uiNameSpace by using setVariable. +
- +
-example: +
-<code cpp> +
-// set it +
-uiNameSpace setVariable ["​myVariable",​ ctrl...]; +
-// use it +
-ctrl.... (uiNameSpace getVariable "​myVariable"​);​ +
-</​code>​ +
- +
- +
-===== createDiaryRecord ===== +
- +
-createDiaryRecord +
- +
-<code cpp> +
-_diary = player createDiaryRecord ["​Diary",​ ["​Technische Details",​ "​Keine"​]];​ +
-</​code>​ +
- +
- +
-===== createSimpleTask ===== +
- +
-createSimpleTask +
- +
-<code cpp> +
-task1 = player createSimpleTask ["​obj1"​];​ +
-</​code>​ +
- +
- +
-===== setSimpleTaskDescription ===== +
- +
-setSimpleTaskDescription +
- +
-<code cpp> +
-task1 setSimpleTaskDescription ["​Description <marker name=""​Start"">​Start</​marker>​ posit.","​more text","​more text"​];​ +
-</​code>​ +
- +
- +
-===== setSimpleTaskDestination ===== +
- +
-setSimpleTaskDestination +
- +
-<code cpp> +
-task1 setSimpleTaskDestination markerPos "​Start";​ +
-</​code>​ +
- +
- +
-===== setTaskState ===== +
- +
-setTaskState +
- +
-<code cpp> +
-task1 setTaskState "​Created";​ +
-</​code>​ +
- +
- +
-===== setCurrentTask ===== +
- +
-setCurrentTask +
- +
-<code cpp> +
-player setCurrentTask task1; +
-</​code>​ +
- +
- +
-===== attachTo ===== +
- +
-attachTo, see also detach. +
- +
-<code cpp> +
-// Make player float exactly 2m above center of car, automatically changing vectordir + relative position as car moves. +
-player attachTo [car, [0,0,2]]; +
-detach player; +
-</​code>​+
arma2/scripting.1243789119.txt.gz · Last modified: 2009-05-31 17:58 (external edit)