Functions Library – Arma 3

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Some wiki formatting)
(100 intermediate revisions by 15 users not shown)
Line 1: Line 1:
[[Category:Arma 3: Editing]]
{{TOC|side||3}}
{{arma3}}'s '''Functions Library''' is the way to declare mission, campaign or addon's [[Function]]s. The main difference from older [[:Category:Functions Library|Function Libraries]] is that it runs automatically and does not require a Functions module.


Arma 3 '''Functions Library''' is pack of routine script functions available from anywhere in game. Main difference from older [[Functions Library]] is that it runs automatically and doesn't require Functions manager to be present.
The advantages of using the Functions Library over e.g [[execVM]] an [[SQF Syntax|SQF]] file are as follow:
# '''Automatic compilation upon mission start''' into a global variable - no need to remember direct paths to files.
# '''Anti-hack protection''' using [[compileFinal]] (see {{HashLink|#Recompiling}})
# '''Listing in the [[Arma 3: Functions Viewer|Functions Viewer]]'''
# '''Advanced debugging options'''
# '''Optional immediate execution upon mission start''', without need for manual call
# '''Potential performance improvements'''


== Finding a Function ==
[[File:A3_functionwViewer.png|300px|thumb|right|Functions Viewer]]
Before you can use a function, you first need to find it. The easies way is to access the '''Functions Viewer''':


* In editor, click on [[File:icon editor functions.png|20px]] icon or press Ctrl + F
{{Feature|important|This page is about {{arma3}} Functions Library.
* In mission, access the [[Mission_Editor:_Debug_Console|debug console]] (automatically visible in pause menu of an editor mission) and click on '''FUNCTIONS''' button.
* For {{arma2}}/{{Name|arma2oa|short}}, see [[Arma 2: Functions Library]].
* For {{tkoh}}, see [[Take On Helicopters: Functions Library]].
}}


Once in the '''Functions Viewer''', you can filter all available functions by location, projects and categories.


When you find the desired function, look at the code preview on the right. Every function has a header where you can find basic description of its functionality including required arguments, returned values and sometimes examples of use.
== Function Declaration ==


{{note|Some functions, especially the older ones, may have missing or incomplete headers.<br />We do our best to update them, but if you find some issues, feel free to report them in the [http://feedback.arma3.com/ Feedback Tracker].}}
Functions are configured within the <tt>CfgFunctions</tt> class.


Mission and campaign specific functions can be configured in [[Description.ext]]/[[Campaign Description.ext]], while addon functions are defined in [[Config.cpp]].
Configuration structure is the same in both cases.


== Calling a Function ==
Functions can be launched in mission, intro and outro using this [[call]] or [[spawn]] commands:
_returnedValue = ''arguments'' [[call]] ''functionName'';
''arguments'' [[spawn]] ''functionName'';


=== Arguments ===
{{Feature|informative|The root directory (noted as '''&lt;ROOT&gt;''' on this page) is the origin from which the game will try to load function files. It depends on <tt>CfgFunctions</tt>' location:
Arguments are data sent into the function, affecting its behavior.
* if [[Description.ext]], '''&lt;ROOT&gt;''' means the [[Mission Editor: External#Mission Folder|mission' root]] directory
* if [[Campaign Description.ext]], '''&lt;ROOT&gt;''' means the campaign's root directory
* if in config, '''&lt;ROOT&gt;''' means the '''game'''<nowiki/>'s root directory. The addon path needs to be set manually.
}}


They can be '''mandatory''' or '''optional'''.
* Mandatory arguments are required for function to run. When missing, the function usually stops and throws an error.
* Optional arguments allows more detailed configuration. If you dont send them, the function will use pre-defined default values.


{{note|Within the function, '''arguments''' are called '''parameters''', or simply params.}}
See a basic example config:
 
class '''CfgFunctions'''
 
{
For example, let's take a look at [[BIS_fnc_endMission]], a function which ends a mission with animated closing shot. This is what the header says:
class {{Color|purple|TAG}}
/*
{
Author: Karel Moricky
class {{Color|darkorange|Category}}
{
  Description:
class {{Color|teal|functionName}} {};
Ends mission with specific ending.
};
   
  };
<span style="color:DarkCyan;">Parameter(s):
  };
0 (Optional):
* The function's name will be '''{{Color|purple|TAG}}'''_fnc_'''{{Color|teal|functionName}}'''
STRING - end name (default: "end1")
* The function will be loaded:
ARRAY in format [endName,ID], will be composed to "endName_ID" string
** from config: <tt>'''&lt;ROOT&gt;'''\{{Color|darkorange|Category}}\'''fn_'''{{Color|teal|functionName}}'''.sqf'''</tt>
1 (Optional): BOOL - true to end mission, false to fail mission (default: true)
** from description.ext: <tt>'''&lt;ROOT&gt;'''\'''Functions'''\{{Color|darkorange|Category}}\'''fn_'''{{Color|teal|functionName}}'''.sqf'''</tt>
2 (Optional):
BOOL - true for signature closing shot (default: true)
NUMBER - duration of a simple fade out to black</span>
Returns:
BOOL
*/
 
As you can see, all arguments are marked optional and you can call the function without them.
 
[] call BIS_fnc_endMission;
:This will result in successfull ending of type "end1", preceeded with the signature [[Debriefing|closing shot]].


["end2"] call BIS_fnc_endMission;
{{Feature|informative|'''config.cpp only''': Anywhere outside of running mission, refer to the functions stored in [[uiNamespace]]. e.g:
:Set the ending type to "end2", while keeping the other arguments intact.
<code>''arguments'' [[call]] ([[uiNamespace]] [[getVariable]] ''"functionName"'');</code>}}


["end2",false,false] call BIS_fnc_endMission;
=== Config Levels ===
:Fail the mission without any effect, using "end2" type.


A '''CfgFunctions''' config is made of three levels: Tag, Category, and Function.


However, what should you do if you want to set the '''only''' last argument without affecting the previous ones? The solution is simple - put an empty variable [[nil]] on their place.
==== Tag ====
 
To prevent duplicates, every author must create a subclass with a unique {{Color|purple|[[OFPEC tags|tag]]}} and create functions under it.
<nowiki>[</nowiki>[[nil]],[[nil]],false] call BIS_fnc_endMission;
The tag name will be used when composing a function name (e.g [[BIS_fnc_spawnGroup|'''BIS'''_fnc_spawnGroup]]).
:Disable the closing effects, but keep the other aguments intact (successful "end1").
 
{{note|Some older functions are incompatible with this syntax and using nil would break them. See their header for more information.}}
 
=== Returned Value ===
Functions executed by [[call]] command can return back a value. Let's take a look at [[BIS_fnc_sideName]]:
 
/*
Author: Karel Moricky
Description:
Returns side name
Parameter(s):
0: SIDE or NUMBER - either side or side ID
<span style="color:DarkCyan;">Returns:
STRING</span>
*/
The function returns a [[String]] - localized name of a side.
_westName = [[west]] call BIS_fnc_sideName;
:Variable _westName will now be "BLUFOR" (or other name, based on selected language)
 
=== Multiplayer ===
Functions executed using [[call]] or [[spawn]] command will run only on the computer which triggered them. If you'd wish to execute a function remotely on specific clients, use [[BIS_fnc_MP]] function.
[arguments,''"functionName"'',''target'',''isPersistent''] call [[BIS_fnc_MP]];
 
=== User Interface ===
Anywhere outside of running mission, refer to the functions stored in [[uiNamespace]].
''arguments'' [[call]] ([[uiNamespace]] [[getVariable]] ''"functionName"'');
 
== Adding a Function ==
When writing a script, consider registering it into the Functions Library.
 
Main benefits uncludes:
# '''Automatic compilation upon mission start''' into a global variable - no need to remember direct paths to files.
# '''Anti-hack protection''' using [[compileFinal]]
# '''Listing in the Functions Viewer'''
# '''Advanced debugging options'''
# '''Optional immediate execution upon mission start''', without need for manual call
 
=== Mission ===
Mission specific functions can be configured in [[Description.ext]].
 
==== Default Path ====
  class CfgFunctions
  class CfgFunctions
  {
  {
  class <span style="color:green;">myTag</span>
  class {{Color|purple|TAG}}
  {
  {
  class <span style="color:crimson;">myCategory</span>
  class Category
  {
  {
  class <span style="color:teal;">myFunction</span> {};
  class myFunction {};
  };
  };
  };
  };
  };
   
This will try to compile the function '''<span style="color:green;">myTag</span>_fnc_<span style="color:teal;">myFunction</span>''' from the following file:
  class TAG_WeaponManagement
''%MISSION_ROOT%''\functions\<span style="color:crimson;">myCategory</span>\fn_<span style="color:teal;">myFunction</span>.sqf
 
==== Customized Folder ====
You can customize the folder from which the functions will be loaded:
class CfgFunctions
{
  class <span style="color:green;">myTag</span>
  {
  {
  class myCategory
'''tag''' = {{Color|purple|"TAG"}}; {{cc|the function will be named '''{{Color|purple|TAG}}_fnc_myOtherFunction'''}}
  class Category
  {
  {
file = "<span style="color:DarkOrange;">myFolder</span>";
  class myOtherFunction {};
  class <span style="color:teal;">myFunction</span> {};
  };
  };
  };
  };
  };
  };
This will try to compile the function '''<span style="color:green;">myTag</span>_fnc_<span style="color:teal;">myFunction</span>''' from the following file:
''%MISSION_ROOT%''\<span style="color:DarkOrange;">myFolder</span>\fn_<span style="color:teal;">myFunction</span>.sqf


==== Customized File ====
===== Attributes =====
Furthemore, you can set a specific file to be loaded:
====== tag ======
The <tt>tag</tt> attribute can override the config {{Color|green|tag}} set differently.
 
=== Category ===
 
The category name changes the function's category in the [[Arma 3: Functions Viewer|Functions Viewer]]. It does not change the function's name, only the loading path.
  class CfgFunctions
  class CfgFunctions
  {
  {
  class <span style="color:green;">myTag</span>
  class TAG
  {
  {
  class myCategory
  class {{Color|darkorange|Category}}
  {
  {
  class <span style="color:teal;">myFunction</span> {file = "<span style="color:DarkOrange;">myFile.sqf</span>";};
  class myFunction {};
};
class OtherCategory
{
'''file''' = "{{Color|darkorange|My}}\{{Color|darkorange|Category}}\{{Color|darkorange|Path}}";
class myFunction {}; {{cc|file path will be '''&lt;ROOT&gt;'''\{{Color|darkorange|My}}\{{Color|darkorange|Category}}\{{Color|darkorange|Path}}\fn_myFunction.sqf";}}
};
class DataCategory
{
'''requiredAddons[]''' = {{Color|darkorange|{ "A3_Data_F" }<nowiki/>}}; {{cc|Optional requirements of [[CfgPatches]] classes. If some addons are missing, category functions will not be compiled.}}
class myDataFunction {};
  };
  };
  };
  };
  };
  };
This will try to compile the function '''<span style="color:green;">myTag</span>_fnc_<span style="color:teal;">myFunction</span>''' from the following file:
''%MISSION_ROOT%''\<span style="color:DarkOrange;">myFile.sqf</span>


=== Addon ===
===== Attributes =====


====== file ======
The <tt>file</tt> attribute can override the category's loading path segment.


== Writing a Function ==
====== requiredAddons ======
''WIP''
The category can skip loading if a required addon is missing by setting its dependency with the <tt>requiredAddons</tt> attribute.


<!--
=== Function ===
== Configuration ==
List of functions is defined in config under CfgFunctions container. New ones can be also added in description.ext file of mission or campaign.


{{Feature|informative|By convention, the function class should be named in '''camelCase''' and not have its first letter capitalised (e.g PascalCase):
* {{Icon|checked}} TAG_fnc_{{Color|teal|myFunction}}
* {{Icon|unchecked}} TAG_fnc_{{Color|teal|MyFunction}}
* {{Icon|checked}} TAG_fnc_{{Color|teal|POWRescue}}
}}
  class CfgFunctions
  class CfgFunctions
  {
  {
  class A3
  class TAG
  {
  {
tag = "<span style="color:green;">BIS</span>";
  class Category1
requiredAddons[] = {"A3_Data_F"}; {{codecomment|// Optional requirements of CfgPatches classes}}
  class <span style="color:crimson;">category</span>
  {
  {
  file = "<span style="color:DarkOrange;">A3\functions_f\Misc</span>";
class {{Color|teal|myFunction}} {};
  class <span style="color:teal;">Test1</span> {description="Testing file 2";};
};
class <span style="color:teal;">Test2</span> {description="Testing file 3"; file="<span style="color:DarkOrange;">test.sqf</span>"};
  class <span style="color:teal;">Test3</span> {description="Testing file 4 (FSM)"; ext="<span style="color:fuchsia;">.fsm</span>"};
class Category2
{
  file = "Path\To\Category";
  class myFunction
{
'''file''' = "{{Color|teal|My}}\{{Color|teal|Function}}\{{Color|teal|Filepath.sqf}}"; {{cc|file path will be '''&lt;ROOT&gt;'''\{{Color|teal|My}}\{{Color|teal|Function}}\{{Color|teal|Filepath.sqf}}", ignoring "Path\To\Category"}}
};
  class {{Color|teal|myFSMFunction}}
{
'''preInit''' = 1;
'''postInit''' = 1;
'''ext''' = ".fsm";
'''preStart''' = 1;
'''recompile''' = 1;
};
  };
  };
  };
  };
  };
  };


* If ''file'' path is not set for the given function, system will search for file in
===== Attributes =====
**<code>'<span style="color:DarkOrange;">file</span>\<span style="color:crimson">category</span>\fn_<span style="color:teal">function</span>.sqf"</code> (if functions is defined in description.ext)
{| class="wikitable sortable"
* When ''file'' parameter is defined in category root, all functions in given category will be searched for in this directory.
! rowspan="2" | Attribute
 
! rowspan="2" | Description
Result of example code above is:
! colspan="2" | Available in
* '''<span style="color:green;">BIS</span>_fnc_<span style="color:teal;">Test1</span>''' - will load script <code><span style="color:DarkOrange;">A3\functions_f\Misc</span>\<span style="color:crimson;">category</span>\fn_<span style="color:teal;">Test1</span>.sqf</code>
|- style="font-size: 0.9em"
* '''<span style="color:green;">BIS</span>_fnc_<span style="color:teal;">Test2</span>''' - will load script <code><span style="color:DarkOrange;">test.sqf</span></code> from mission directory
! [[Description.ext]]
* '''<span style="color:green;">BIS</span>_fnc_<span style="color:teal;">Test3</span>''' - will load FSM <code><span style="color:DarkOrange;">A3\functions_f\Misc</span>\<span style="color:crimson;">category</span>\<span style="color:teal;">Test4</span><span style="color:fuchsia;">.fsm</span></code>
! [[config.cpp]]
 
|-
Optional function class params:
| file
* '''description''' - Short function description. Will be rendered obsolete in further revisions, with script headers serving as the main source of documentation.
| the <tt>file</tt> attribute can be used to manually set the file path.
* '''ext''' - file type, can be ".sqf" or ".fsm" (meaning scripted FSM). Default is ".sqf".
{{Feature|important|The '''file''' entry '''overrides''' Category's set path and ignores it entirely (they are not merged).}}
* '''file''' - optional direct path to the file.
| style="text-align: center" | {{Icon|checked}}
* '''recompile''' (new in Arma 3) - function will be recompile upon mission start.
| style="text-align: center" | {{Icon|checked}}
* '''preInit''' (new in Arma 3) - function will be executed automatically upon mission start, before objects are loaded.
|-
* '''postInit''' (new in Arma 3) - function will be executed automatically upon mission start, after objects are loaded.
| preInit
 
| the <tt>preInit</tt> attribute (formerly known as "forced") can be set to 1 to call the function upon mission start, before objects are initialized.<br>Passed arguments are {{ic|["preInit"]}}. The function is run in an '''[[Scheduler#Unscheduled Environment|unscheduled environment]]'''.
== Debugging ==
| style="text-align: center" | {{Icon|checked}}
 
| style="text-align: center" | {{Icon|checked}}
=== Debug Functions ===
|-
Use debug functions to register params, display errors and log messages to [[RPT]] file. Printed output of these functions automatically contains name of function from which it was called.
| postInit
 
| the <tt>postInit</tt> attribute can be set to 1 to call the function upon mission start, after objects are initialized.<br>Passed arguments are {{ic|["postInit", [[didJIP]]]}}. The function is run in a '''[[Scheduler#Scheduled Environment|scheduled environment]]''' so suspension is allowed, but '''any long term suspension will halt the mission loading until suspension is done'''.
To prevent RPT spam, logging is disabled by default. Enable it by placing the following parameter to your mission [[Description.ext]]:
| style="text-align: center" | {{Icon|checked}}
allowFunctionsLog = 1;
| style="text-align: center" | {{Icon|checked}}
|-
| ext
| the <tt>ext</tt> attribute can be used to set function file's type; it can be one of:
* ".sqf" (default)
* ".fsm" (see [[FSM]])
| style="text-align: center" | {{Icon|checked}}
| style="text-align: center" | {{Icon|checked}}
|-
| preStart
| the <tt>preStart</tt> attribute can be set to 1 to call the function upon game start, before title screen, but after all addons are loaded.
| style="text-align: center" | {{Icon|unchecked}}
| style="text-align: center" | {{Icon|checked}}
|-
| recompile
| the <tt>recompile</tt> attribute can be set to 1 to recompile the function upon mission start (functions in [[Description.ext]] are always compiled upon mission (re)start)
| style="text-align: center" | {{Icon|unchecked}}
| style="text-align: center" | {{Icon|checked}}
|}


{{Important|Usage of following functions is strongly recommended:
{{Feature|important|Notes about <tt>preInit</tt> and <tt>postInit</tt> defined in '''config.cpp''':
* [[BIS_fnc_param]]
* these attributes will make the function run '''on each, every and any mission start'''
* [[BIS_fnc_log]]
* Any scripting error will prevent the mission from being loaded correctly
* [[BIS_fnc_error]]
* Server admins might blacklist the whole addon if they find out the function is used for hacking
* [[BIS_fnc_halt]]
}}
}}


Examples of debug outputs:
{{codecomment|"Config param 'splendid' not defined in CfgArma." call BIS_fnc_halt;}}
"Log: HALT: [BIS_fnc_isSplendid] Config param 'splendid' not defined in CfgArma."
{{codecomment|_mission <nowiki>=</nowiki> [BIS_Player] call [[BIS_fnc_endMission]];}}
"Log: ERROR: [BIS_fnc_endMission] 0: BIS_Player is type OBJECT, must be STRING. "end1" used instead."
{{codecomment|["Persistent execution is not allowed when target is %1. Use %2 or %3 instead.",typename 0,typename objnull,typename false] call BIS_fnc_error;}}
"Log: ERROR: Persistent execution is not allowed when target is SCALAR. Use OBJECT or BOOL instead."
{{codecomment|42 call BIS_fnc_log;}}
"BIS_fnc_log: [BIS_fnc_myFunction]: 42"
{{codecomment|["Random number is %1",random 999] call BIS_fnc_log;}}
"BIS_fnc_log: [BIS_fnc_myFunction] Random number is 808.768"
=== Allow Recompile ===
For security reasons, all functions are compiled using [[compileFinal]] and cannot be rewritten afterwards). When writing and testing a function, this would require game restart after every single change.
To allow recompiling [[missionNamespace]] functions, place following param into mission [[Description.ext]]:
allowFunctionsRecompile = 1;
''Note: Unavailable in the 0.56.104778 default build, planned for the next one. Dev builds might receive the feature sooner. Use '''recompile = 1;''' function param for debugging your own functions meanwhile.''
=== Debug Mode ===
Developers can access several debug modes using ''[[BIS_fnc_functionsDebug]]'' function.
# '''No debug'''
#* Default
# '''Save script map'''
#* Variable ''_fnc_scriptMap'' tracking script execution progress is stored in function header
# '''Save and log script map'''
#* Variable ''_fnc_scriptMap'' tracking script execution progress is stored in functions header and it's printed to debug log.
{{Important|Function recompiling has to be allowed!}}


== See Also ==


=== Meta Variables ===
* [[Initialization Order]]
System is adding header with basic meta data to all functions. Following local variables are defined there:
* [[Arma 3: Functions Viewer]]
* '''_fnc_scriptName''': STRING - Function name (<tag>_fnc_<name>)
* [[:Category:Arma 3: Functions|Arma 3 Functions]]
* '''_fnc_scriptNameParent''': STRING - Name of function from which current one was called (_fnc_scriptName used when not defined)
* [[Arma 3: Writing a Function|Writing a Function Tutorial]]
* '''_fnc_scriptMap''': ARRAY - List of all parent scripts (available only in debug mode 1 and higher, see [[#Debug_Mode|above]]).
{{Important|Please do not modify these values!}}




=== Initialization Order ===
{{GameCategory|arma3|Editing}}
# '''Functions'''
[[Category: Functions Library]]
# Init [[ArmA_2:_Event_Handlers|Event Handlers]]
# [[Mission.sqm]]
# [[Event_Scripts|Init.sqf]]
# [[Event_Scripts|Init.sqs]]
# [[Triggers]]
-->

Revision as of 01:28, 5 August 2021

Arma 3's Functions Library is the way to declare mission, campaign or addon's Functions. The main difference from older Function Libraries is that it runs automatically and does not require a Functions module.

The advantages of using the Functions Library over e.g execVM an SQF file are as follow:

  1. Automatic compilation upon mission start into a global variable - no need to remember direct paths to files.
  2. Anti-hack protection using compileFinal (see Recompiling)
  3. Listing in the Functions Viewer
  4. Advanced debugging options
  5. Optional immediate execution upon mission start, without need for manual call
  6. Potential performance improvements


This page is about Arma 3 Functions Library.


Function Declaration

Functions are configured within the CfgFunctions class.

Mission and campaign specific functions can be configured in Description.ext/Campaign Description.ext, while addon functions are defined in Config.cpp. Configuration structure is the same in both cases.


The root directory (noted as <ROOT> on this page) is the origin from which the game will try to load function files. It depends on CfgFunctions' location:


See a basic example config:

class CfgFunctions
{
	class TAG
	{
		class Category
		{
			class functionName {};
		};
	};
};
  • The function's name will be TAG_fnc_functionName
  • The function will be loaded:
    • from config: <ROOT>\Category\fn_functionName.sqf
    • from description.ext: <ROOT>\Functions\Category\fn_functionName.sqf
config.cpp only: Anywhere outside of running mission, refer to the functions stored in uiNamespace. e.g: arguments call (uiNamespace getVariable "functionName");

Config Levels

A CfgFunctions config is made of three levels: Tag, Category, and Function.

Tag

To prevent duplicates, every author must create a subclass with a unique tag and create functions under it. The tag name will be used when composing a function name (e.g BIS_fnc_spawnGroup).

class CfgFunctions
{
	class TAG
	{
		class Category
		{
			class myFunction {};
		};
	};

	class TAG_WeaponManagement
	{
		tag = "TAG"; // the function will be named TAG_fnc_myOtherFunction
		class Category
		{
			class myOtherFunction {};
		};
	};
};
Attributes
tag

The tag attribute can override the config tag set differently.

Category

The category name changes the function's category in the Functions Viewer. It does not change the function's name, only the loading path.

class CfgFunctions
{
	class TAG
	{
		class Category
		{
			class myFunction {};
		};

		class OtherCategory
		{
			file = "My\Category\Path";
			class myFunction {}; // file path will be <ROOT>\My\Category\Path\fn_myFunction.sqf";
		};

		class DataCategory
		{
			requiredAddons[] = { "A3_Data_F" }; // Optional requirements of CfgPatches classes. If some addons are missing, category functions will not be compiled.
			class myDataFunction {};
		};
	};
};
Attributes
file

The file attribute can override the category's loading path segment.

requiredAddons

The category can skip loading if a required addon is missing by setting its dependency with the requiredAddons attribute.

Function

By convention, the function class should be named in camelCase and not have its first letter capitalised (e.g PascalCase):
  • Checked TAG_fnc_myFunction
  • Unchecked TAG_fnc_MyFunction
  • Checked TAG_fnc_POWRescue
class CfgFunctions
{
	class TAG
	{
		class Category1
		{
			class myFunction {};
		};

		class Category2
		{
			file = "Path\To\Category";
			class myFunction
			{
				file = "My\Function\Filepath.sqf"; // file path will be <ROOT>\My\Function\Filepath.sqf", ignoring "Path\To\Category"
			};

			class myFSMFunction
			{
				preInit		= 1;
				postInit	= 1;
				ext			= ".fsm";
				preStart	= 1;
				recompile	= 1;
			};
		};
	};
};
Attributes
Attribute Description Available in
Description.ext config.cpp
file the file attribute can be used to manually set the file path.
The file entry overrides Category's set path and ignores it entirely (they are not merged).
Checked Checked
preInit the preInit attribute (formerly known as "forced") can be set to 1 to call the function upon mission start, before objects are initialized.
Passed arguments are ["preInit"]. The function is run in an unscheduled environment.
Checked Checked
postInit the postInit attribute can be set to 1 to call the function upon mission start, after objects are initialized.
Passed arguments are ["postInit", didJIP]. The function is run in a scheduled environment so suspension is allowed, but any long term suspension will halt the mission loading until suspension is done.
Checked Checked
ext the ext attribute can be used to set function file's type; it can be one of:
  • ".sqf" (default)
  • ".fsm" (see FSM)
Checked Checked
preStart the preStart attribute can be set to 1 to call the function upon game start, before title screen, but after all addons are loaded. Unchecked Checked
recompile the recompile attribute can be set to 1 to recompile the function upon mission start (functions in Description.ext are always compiled upon mission (re)start) Unchecked Checked
Notes about preInit and postInit defined in config.cpp:
  • these attributes will make the function run on each, every and any mission start
  • Any scripting error will prevent the mission from being loaded correctly
  • Server admins might blacklist the whole addon if they find out the function is used for hacking


See Also