Functions Library – Arma 2
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\[\[Arma 3 ([^ACHJKLMTZ|])([^|]+)\]\]" to "Arma 3: $1$2") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ | {{TOC|side}} | ||
'''Function Library''' is pack of script functions available from anywhere in game. | '''Function Library''' is pack of script functions available from anywhere in game. | ||
{{Feature| | {{Feature|arma3|This page is mainly '''Arma 2''' related, for '''Arma 3''' visit [[Arma 3: Functions Library]]}} | ||
== Initialization == | |||
=== Paths === | === Paths === | ||
Editor: | Editor: | ||
Modules (F7) > Function Library | Modules (F7) > Function Library | ||
Line 16: | Line 18: | ||
=== Startup === | === Startup === | ||
Place Function manager on map. No additional synchronizing needed. | Place Function manager on map. No additional synchronizing needed. | ||
=== Usage === | === Usage === | ||
First, you need to check if Functions were already initialized: | First, you need to check if Functions were already initialized: | ||
<sqf>waitUntil { !isNil "BIS_fnc_init" };</sqf> | |||
{{Feature|important|Always check for 'BIS_fnc_init', not specific functions (e.g. 'BIS_fnc_setpitchbank')! | {{Feature|important|Always check for 'BIS_fnc_init', not specific functions (e.g. 'BIS_fnc_setpitchbank')! | ||
Line 26: | Line 30: | ||
After that, you can call any function using following syntax: | After that, you can call any function using following syntax: | ||
<sqf>_fnc = [params] call TAG_fnc_functionName;</sqf> | |||
== In-game functions viewer == | == In-game functions viewer == | ||
''See [[BIS_fnc_help]]'' | ''See [[BIS_fnc_help]]'' | ||
== Adding new functions == | == Adding new functions == | ||
List of functions is defined in config - CfgFunctions. New ones can be also added in [[Description.ext]] file of mission or campaign. | List of functions is defined in config - CfgFunctions. New ones can be also added in [[Description.ext]] file of mission or campaign. | ||
< | <syntaxhighlight lang="cpp"> | ||
class cfgFunctions | class cfgFunctions | ||
{ | { | ||
Line 40: | Line 48: | ||
class category1 | class category1 | ||
{ | { | ||
class Test1 {description="Testing file 1"}; | class Test1 { description = "Testing file 1" }; | ||
}; | }; | ||
}; | }; | ||
class | |||
class TAG | |||
{ | { | ||
class category1 | class category1 | ||
{ | { | ||
class Test2 | class Test2 | ||
{ | |||
description = "Testing file 2"; | |||
file = "test.sqf"; | |||
}; | |||
}; | }; | ||
}; | }; | ||
}; | }; | ||
</ | </syntaxhighlight> | ||
If 'file' path is not set, system will search for file 'functions\ | If 'file' path is not set, system will search for file 'functions\{{Color|green|category}}\fn_{{Color|green|function}}.sqf" (if CfgFunctions is defined in [[Description.ext]]) or 'ca\modules\functions\{{Color|green|category}}\fn_{{Color|green|function}}.sqf" (if CfgFunctions is defined in config.cpp). | ||
Result is: | Result is: | ||
* BIS_fnc_Test1 - will load script \functions\category1\test1.sqf from mission or campaign directory | * BIS_fnc_Test1 - will load script \functions\category1\test1.sqf from mission or campaign directory | ||
* | * TAG_fnc_Test2 - will load script test.sqf | ||
== List of official functions == | == List of official functions == | ||
[[:Category:Arma 2: | |||
* [[:Category:Arma 2: Functions]] | |||
[[Category: Functions Library]] | |||
{{GameCategory|arma2|Editing}} | |||
{{GameCategory|arma2|Editor Modules}} |
Latest revision as of 10:50, 22 July 2022
Function Library is pack of script functions available from anywhere in game.
Initialization
Paths
Editor:
Modules (F7) > Function Library
Data:
ca\modules\functions ca\modules_e\functions ca\modules_pmc\functions
Startup
Place Function manager on map. No additional synchronizing needed.
Usage
First, you need to check if Functions were already initialized:
After that, you can call any function using following syntax:
In-game functions viewer
See BIS_fnc_help
Adding new functions
List of functions is defined in config - CfgFunctions. New ones can be also added in Description.ext file of mission or campaign.
class cfgFunctions
{
class BIS
{
class category1
{
class Test1 { description = "Testing file 1" };
};
};
class TAG
{
class category1
{
class Test2
{
description = "Testing file 2";
file = "test.sqf";
};
};
};
};
If 'file' path is not set, system will search for file 'functions\category\fn_function.sqf" (if CfgFunctions is defined in Description.ext) or 'ca\modules\functions\category\fn_function.sqf" (if CfgFunctions is defined in config.cpp).
Result is:
- BIS_fnc_Test1 - will load script \functions\category1\test1.sqf from mission or campaign directory
- TAG_fnc_Test2 - will load script test.sqf