Difference between revisions of "Talk:Arma 3: Functions Library"

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Lou Montana moved page Talk:Arma 3 Functions Library to Talk:Arma 3: Functions Library: Text replacement - "^Arma 3 " to "Arma 3: ")
(Store Str's forb-hidden knowledge in a safe <spoiler> tag)
Line 17: Line 17:
 
Addon:  
 
Addon:  
 
Functions are compiled when addon is loaded
 
Functions are compiled when addon is loaded
 +
 +
 +
== Forbidden Knowledge ==
 +
 +
as per [[User:Str|Str]]'s note, let's not add to the confusion and store this data away from the main page.
 +
 +
<spoiler text="See at your own risk!">
 +
=== Header Type attribute ===
 +
 +
{| class="wikitable"
 +
| headerType
 +
| the <tt>headerType</tt> attribute can be set to declare the function's header type:
 +
* -1: no header
 +
* &nbsp;0: default header
 +
* &nbsp;1: system header
 +
|}
 +
 +
=== Header Types ===
 +
 +
The different header types add code to the begining of your functions that can..
 +
* Set up the [[#Meta Variables|Meta Variables]] _fnc_scriptParent and _fnc_scriptName
 +
* Name the current scope via the command [[scriptName]]
 +
* Adds debug information by saving the current execution order in the [[Array]] _fnc_scriptMap.
 +
 +
 +
==== No Header ====
 +
Adds nothing, literally adds a blank [[String]] to the begining of your function. The function will have no debug or [[#Meta Variables|Meta Variables]] assigned for it and the scope will not be named.
 +
 +
==== System Header ====
 +
Incorporates the [[#Meta Variables|Meta Variables]] _fnc_scriptParent. Also names the current scope.
 +
{|
 +
|
 +
private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'%1'} else {_fnc_scriptName};
 +
scriptName '%1';
 +
|}
 +
 +
==== Default Header ====
 +
The default header changes based on the current [[#Debug Mode:Debug Mode]]
 +
 +
===== Debug Mode 0 =====
 +
default - incorporates the [[#Meta Variables|Meta Variables]] _fnc_scriptParent and _fnc_scriptName and names the current scope.
 +
{|
 +
|
 +
private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'%1'} else {_fnc_scriptName};
 +
private _fnc_scriptName = '%1';
 +
scriptName _fnc_scriptName;
 +
|}
 +
 +
===== Debug Mode 1 =====
 +
As per ''Debug Mode 0'' and also saves the current execution order in the [[Array]] _fnc_scriptMap.
 +
{|
 +
|
 +
private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'%1'} else {_fnc_scriptName};
 +
private _fnc_scriptName = '%1';
 +
scriptName _fnc_scriptName;
 +
private _fnc_scriptMap = if (isNil '_fnc_scriptMap') then {[_fnc_scriptName]} else {_fnc_scriptMap + [_fnc_scriptName]};
 +
|}
 +
 +
===== Debug Mode 2 =====
 +
As per ''Debug Mode 1'' and also outputs execution order using [[textLogFormat]] ( textLogFormat is not available in the retail version of Arma3 ) is it available in Diagnostics exe?
 +
{|
 +
|
 +
private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'%1'} else {_fnc_scriptName};
 +
private _fnc_scriptName = '%1';
 +
scriptName _fnc_scriptName;
 +
private _fnc_scriptMap = if (isNil '_fnc_scriptMap') then {[_fnc_scriptName]} else {_fnc_scriptMap + [_fnc_scriptName]};
 +
textLogFormat ['%1 : %2', _fnc_scriptMap joinString ' >> ', _this];
 +
|}
 +
 +
=== Meta Variable ===
 +
 +
* '''_fnc_scriptMap''': ARRAY - List of all parent scripts (available only in debug mode 1 and higher, see [[#Debug_Mode|above]]).
 +
 +
=== 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.
 +
{{Feature|important|Function recompiling has to be allowed!}}
 +
</spoiler>

Revision as of 21:52, 4 August 2021

Looking across the CfgFunctions class, there are also those Attributes: headerType, cheatsEnabled that are not referenced here. -Floriangeyer

Those are system attributes and are used only in special cases. I didn't consider them significant enough to be descibed publicly. -Str (talk) 18:10, 28 March 2014 (CET)

Explain how and when functions are compiled

edit: i was going to post a reply but i guess this will do, also where are my line breaks

I've talked with plenty of rookies who didn't understand that functions are compiled BEFORE the mission starts / init fields are called, so they were calling their functions using preInit and just exiting if that was the params.

My suggestion is that someone who knows the exact compile steps for functions add that just above "init order".

From my understanding it's goes something like this;

Mission: In editor: cfgFunctions from description.ext are compiled when mission loaded/previewed/restarted (since you don't have to add recompile flag and don't have to save like with cfgSounds to be read when changed?) MP: Functions are compiled when "start" is pressed?

Addon: Functions are compiled when addon is loaded


Forbidden Knowledge

as per Str's note, let's not add to the confusion and store this data away from the main page.

See at your own risk!