User Tools

Site Tools


arma2:scripting

This is an old revision of the document!


Scripting

initJIPcompatible.sqf is automatically started at unknown time, best guess would be when JIP player joins?

Scripting Commands

There's a lot of cool scripts (functions) available in Modules.pbo - especially under “Functions” and even an multiplayer Framework in “MP”.

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.

// this will error if myBoolean was not previously defined.
if (myBoolean) then { hint "test" };

Usage of isNil is still valid.

BIS fnc locations

BIS fnc locations

Description: Creates or registers location logics (used in various modules, like Ambient Civilians, Ambient Civilian Vehicles or Warfare 2).

Upon registering, function will set following variables into location logic's variable space:

  • “class” - unique class of location (either BIS_loc_<configname> or BIS_loc_custom_<ID>)
  • “name” - name of location from config or setName command. If 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.

Syntax

Syntax: [type(s),area,debug] call BIS_fnc_locations

Parameters: type(s): String or Array of strings
area: Array in format [center,distance]
debug: (Optional): Boolean

Return Value: Array - List of registered locations

Alternative Syntax

Syntax: [objects] call BIS_fnc_locations

Parameters: objects: Array of Objects or Locations - list of specific locations to be registered

Return Value: Array - List of registered locations

Examples

Example 1:

["CityCenter",[position player,1000]] call bis_fnc_locations;

Example 2:

[["acityc_dolina"]] call bis_fnc_locations;

Example 3:

[[myLocation1,myLocation2],[],true] call bis_fnc_locations;

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:

player allowDamage false

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.

_myObject setVariable ["myVariable", 1, true];

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:

// set it
uiNameSpace setVariable ["myVariable", ctrl...];
// use it
ctrl.... (uiNameSpace getVariable "myVariable");

createDiaryRecord

createDiaryRecord

_diary = player createDiaryRecord ["Diary", ["Technische Details", "Keine"]];

createSimpleTask

createSimpleTask

task1 = player createSimpleTask ["obj1"];

setSimpleTaskDescription

setSimpleTaskDescription

task1 setSimpleTaskDescription ["Description <marker name=""Start"">Start</marker> posit.","more text","more text"];

setSimpleTaskDestination

setSimpleTaskDestination

task1 setSimpleTaskDestination markerPos "Start";

setTaskState

setTaskState

task1 setTaskState "Created";

setCurrentTask

setCurrentTask

player setCurrentTask task1;

attachTo

attachTo, see also detach.

// 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;

diag_log

diag_log writes any variable ([_fish, _frog] or “Hello, I'm starting to initialize myself”) directly to the log, without needing to pass it via format/str and without any extra text.

Changing nameSpace

You can change namespace inside another namespace. Note that 1 misionNamespace refers to the normal global scope and 1 uiNamespace is the one where you are forced to store any control/display handles:

fish = "Frog!";
 
with uiNamespace do
{
	// Do some stuff with dialogs here.
 
	with missionNamespace do
	{
		hint fish; // This sees the "regular" mission namespace.
	};
	// Do some more stuff with dialogs here.
};

I have no idea what the purpose of 1 parsingNamespace is.

Access nameSpace

The command 1 with gives you a much nicer way to access namespaces and is especially cleaner when making multiple accesses:

with uiNameSpace do
{
	// Any globals in this block are taken from uiNameSpace.
	// Any locals are normal locals from current scope.
	(fishDisplay displayCtrl 102) ctrlSetText _frog;
	piesControl ctrlSetText _pies;
	cheeseControl ctrlSetText _cheese;
};

Rather than:

((uiNameSpace getVariable "fishDisplay") displayCtrl 102) ctrlSetText _frog;
(uiNameSpace getVariable "piesControl") ctrlSetText _pies;
(uiNameSpace getVariable "cheeseControl") ctrlSetText _cheese;
arma2/scripting.1244040167.txt.gz · Last modified: 2009-06-03 15:42 (external edit)