Functions Library – Take On Helicopters
Lou Montana (talk | contribs) m (Text replacement - "{{Link|Initialization Order" to "{{Link|Initialisation Order") |
Lou Montana (talk | contribs) m (Text replacement - " to to " to " to ") |
||
(One intermediate revision by the same user not shown) | |||
Line 22: | Line 22: | ||
Functions replaces the obsolete [[Arma 2: Multiplayer Framework]]. | Functions replaces the obsolete [[Arma 2: Multiplayer Framework]]. | ||
[[BIS_fnc_MP]] can be used | [[BIS_fnc_MP]] can be used to remotely execute functions on specific clients and set them to be persistent, so they will be executed automatically for client upon JIP. | ||
=== GUI === | === GUI === | ||
Line 34: | Line 34: | ||
== In-Game Functions Viewer == | == In-Game Functions Viewer == | ||
[[ | [[File:Take_On_Helicopters_Functions_Viewer.jpg|300px|thumb|right]] | ||
Use the following code to display function library anywhere in game: | Use the following code to display function library anywhere in game: | ||
<sqf>[] call BIS_fnc_help;</sqf> | <sqf>[] call BIS_fnc_help;</sqf> |
Latest revision as of 18:23, 25 May 2024
Functions Library 2.0 is pack of routine script functions available from anywhere in game. The main difference from the older Functions Library is that it runs automatically and does not require Functions manager to be present.
Usage
params are parameters required by given function. If you wish to skip a param (e.g. leave it is default value), use nil on its index (valid only if BIS_fnc_param is used by the function).
Singleplayer
Functions can be launched in mission, intro and outro using this syntax:
or
Multiplayer
Functions replaces the obsolete Arma 2: Multiplayer Framework. BIS_fnc_MP can be used to remotely execute functions on specific clients and set them to be persistent, so they will be executed automatically for client upon JIP.
GUI
Anywhere outside running mission (user interface), refer to functions stored in UInamespace
or
In-Game Functions Viewer
Use the following code to display function library anywhere in game:
In the 3D Editor, you can find the Function Viewer in the Tools category of the menustrip
Features:
- Listing through all functions from config or description.ext files.
- Displaying name, path, description and code of selected functions.
- Code can be easily copied to clipboard.
Add Functions
The list of functions is defined in config under the CfgFunctions container. New ones can be also added in description.ext mission's or campaign's file.
class CfgFunctions
{
file = "hsim\ModulesCore_H\modules\functions";
class BIS { class category1 { class Test1 { description = "Testing file 1" }; }; };
class HSim
{
tag = "BIS";
class category2 { file = "hsim\modules_h\functions"; class Test2 { description = "Testing file 2"; }; class Test3 { description = "Testing file 3"; file = "test.sqf" }; class Test4 { description = "Testing file 4 (FSM)"; ext = ".fsm" }; }; }; };
- If 'file' path is not set for the given function, system will search for file in
- 'file\category\fn_function.sqf" (if functions is defined in description.ext)
- When file = parameter is defined in category root, all functions in given category will be searched for in this directory.
- Default ext = is .sqf. You can optionally use .fsm, but no other extensions are compatible. Define .fsm even when you're settings file = leading directly to the file.
Result is:
- BIS_fnc_Test1 - will load script hsim\ModulesCore_H\modules\functions\category1\test1.sqf from functions directory (see above)
- BIS_fnc_Test2 - will load script hsim\modules_h\functions\category2\Test2.sqf
- BIS_fnc_Test3 - will load script test.sqf from mission directory
- BIS_fnc_Test4 - will load FSM hsim\modules_h\functions\category2\Test4.fsm
Debugging
Debug Functions
Use debug functions/commands to register params, display errors and log messages. Printed output of these functions automatically contains name of function from which it was called.
Examples of debug outputs:
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 is printed to debug log.
Debug Variables
Store following variables into profileNameSpace to toggle various debug options:
- BIS_fnc_initRecompileEditor - recompiles functions every time you click on 'Preview' button in editor ensuring changes made in functions are present on mission start.
Meta Variables
System is adding header with basic meta data to all functions. Following local variables are defined there:
- _fnc_scriptName: STRING - Function name (<tag>_fnc_<name>)
- _fnc_scriptNameParent: STRING - Name of function from which current one was called (_fnc_scriptName used when not defined)
- _fnc_scriptMap: ARRAY - List of all parent scripts (available only in debug mode 1 and higher, see above).
Initialization Order
- Functions
- Init Event Handlers
- Mission.sqm
- Init.sqf
- Init.sqs
- Triggers