Larrow – User

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Attributes ===
[[User:Larrow/CfgFunctionsAdvanced|Advanced CfgFunctions]]
Apart from already mentioned ''file'', function class can have additional attributes:
class CfgFunctions
{
class <span style="color:green;">myTag</span>
{
class myCategory
{
class <span style="color:teal;">myFunction</span>
{
preInit = 1; {{codecomment|//(formerly known as "forced") 1 to call the function upon mission start, <u>before</u> objects are initialized. Passed arguments are ["preInit"]}}
postInit = 1; {{codecomment|//1 to call the function upon mission start, <u>after</u> objects are initialized. Passed arguments are ["postInit", didJIP]}}
preStart = 1; {{codecomment|//1 to call the function upon game start, before title screen, but after all addons are loaded (config.cpp only)}}
ext = ".fsm"; {{codecomment|//Set file type, can be ".sqf" or ".fsm" (meaning scripted FSM). Default is ".sqf".}}
headerType = -1; {{codecomment|//Set function header type: -1 - no header; 0 - default header; 1 - system header.}}
recompile = 1; {{codecomment|//1 to recompile the function upon mission start (config.cpp only; functions in description.ext are compiled upon mission start already)}}
};
};
};
};
All of these attributes are case sensitive.<br />


==== Pre and Post Init ====
[[User:Larrow/BIScriptedEventHandlers|BI ScriptedEventHandlers]]
''preInit'' and ''postInit'' attributes are truly powerful ones, as they let you execute your function at the beginning of '''every''' mission. Use them with caution!.<br />
''preInit'' are '''called''' unscheduled so suspension is not allowed. Parameters passed are [ "preInit" ].<br />
''postInit'' are '''called''' scheduled so suspension is allowed but any long term suspension will halt the mission loading until suspension has finished. Parameters passed are [ "postInit", [[didJIP]] ].<br />


* Any scripting error will prevent the mission from being loaded correctly
[[User:Larrow/Bible|Bible]]
* Server admins might blacklist your addon if they find out you're using the function for hacking.
 
 
==== 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'''''<br />
: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'''''<br />
: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'''''<br />
:The default header changes based on the current [[#Debug Mode|Debug Mode]]
 
::''Debug Mode 0'' - default<br />
::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''<br />
::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''<br />
::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 Variables ===
System is adding header with basic meta data to all functions. Following local variables are declared there:
* '''_fnc_scriptName''': [[String]] - Function name (e.g., myTag_fnc_myFunction)
* '''_fnc_scriptNameParent''': [[String]] - Name of q function from which the 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 [[#Debug_Mode|above]]).-->
{{Important|Do not modify these values!}}
 
 
=== 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!}}

Latest revision as of 01:11, 10 February 2020