Skip to content

Instantly share code, notes, and snippets.

@OverlordZorn
Last active March 30, 2024 19:29
Show Gist options
  • Save OverlordZorn/5376fe25ee1ac86fbfb6cd99bde38b42 to your computer and use it in GitHub Desktop.
Save OverlordZorn/5376fe25ee1ac86fbfb6cd99bde38b42 to your computer and use it in GitHub Desktop.
Zorns A3 Snippets - collection of snippets used for Arma 3
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"CBA_waitAndExecute_short": {
"prefix": "CBA_waitAndExecute_oneLiner",
"body": [
"[ { ${1:_this#0;} } , [${2:Parameters}], ${3:timeToWaitinSecounds}] call CBA_fnc_waitAndExecute;"
],
"description": "CBA_waitAndExecute as a one liner"
},
"CBA_waitAndExecute": {
"prefix": "CBA_waitAndExecute",
"body": [
"_code = {",
" ${1:_this#0;}",
"};",
"",
"[_code, [${2:Parameters}], ${3:timeToWaitinSecounds}] call CBA_fnc_waitAndExecute;"
],
"description": "CBA_waitAndExecute"
},
"cba_fnc_WaitUntilAndExecute": {
"prefix": "[cbaWaitUntil, CBA_FNC_WaitUntilAndExecute]",
"body": [
"_condition = {}; // condition - Needs to return bool",
"_statement = {}; // Code to be executed once condition true",
"_parameter = []; // arguments to be passed on -> _this",
"_timeout = -1; // if condition isnt true within this time in S, _timecode will be executed.",
"_timeoutCode = {}; // code to be executed if timeout",
"[_condition, _statement, _parameter, _timeout,_timeoutCode] call CBA_fnc_waitUntilAndExecute;"
],
"description": "cba_fnc_WaitUntilAndExecute"
},
"CBA_pfEH" : {
"prefix": ["CBA_pfEH", "pfeh","CBA_perFrameEventHandler"],
"body": [
"/*",
"_codeToRun - <CODE> code to Run stated between {}",
"_parameters - <ANY> OPTIONAL parameters, will be passed to code to run, exit code and condition",
"_exitCode - <CODE> OPTIONAL exit code between {} code that will be executed upon ending PFEH default is {}",
"_condition - <CODE THAT RETURNS BOOLEAN> - OPTIONAL conditions during which PFEH will run default {true}",
"_delay - <NUMBER> (optional) delay between each execution in seconds, PFEH executes at most once per frame",
"*/",
"",
"private _codeToRun = { ${1: /*_statement */ } };",
"private _parameters = [ ${2: /*parameters*/ } ];",
"private _exitCode = { ${3:/* exit code */} };",
"private _condition = { ${4:/*condition (false will lead to exit}*/ };",
"private _delay = 2;",
"",
"[{",
" params [\"_args\", \"_handle\"];",
" _args params [\"_codeToRun\", \"_parameters\", \"_exitCode\", \"_condition\"];",
"",
" if (_parameters call _condition) then {",
" _parameters call _codeToRun;",
" } else {",
" _handle call CBA_fnc_removePerFrameHandler;",
" _parameters call _exitCode;",
" };",
"}, _delay, [_codeToRun, _parameters, _exitCode, _condition]] call CBA_fnc_addPerFrameHandler;"
],
"description": "creates a quick perFrameEventHandler Template with condition check and self-destruction upon a failed condition check"
},
"CBA_pfEH_time" : {
"prefix": ["CBA_pfEH_timeBased", "pfeh_time","CBA_perFrameEventHandler_based_onTime"],
"body": [
"/*",
"_codeToRun - <CODE> code to Run stated between {}",
"_parameters - <ANY> OPTIONAL parameters, will be passed to code to run, exit code and condition",
"_exitCode - <CODE> OPTIONAL exit code between {} code that will be executed upon ending PFEH default is {}",
"_condition - <CODE THAT RETURNS BOOLEAN> - OPTIONAL conditions during which PFEH will run default {true}",
"_delay - <NUMBER> (optional) delay between each execution in seconds, PFEH executes at most once per frame",
"*/",
"",
"private _startTime = time;",
"private _endTime = time + _duration;",
"private _parameters = [_startTime, _endTime];",
"private _condition = { _this#1 > time };",
"",
"private _codeToRun = { /*_statement */ };",
"private _exitCode = { /* exit code */ };",
"private _delay = 2;",
"",
"[{",
" params [\"_args\", \"_handle\"];",
" _args params [\"_codeToRun\", \"_parameters\", \"_exitCode\", \"_condition\"];",
"",
" if (_parameters call _condition) then {",
" _parameters call _codeToRun;",
" } else {",
" _handle call CBA_fnc_removePerFrameHandler;",
" _parameters call _exitCode;",
" };",
"}, _delay, [_codeToRun, _parameters, _exitCode, _condition]] call CBA_fnc_addPerFrameHandler;"
],
"description": "creates a quick perFrameEventHandler Template with condition check and self-destruction upon a failed condition check"
},
"cba_nextFrame" : {
"prefix": ["cba_nextFrame", "execNextFrame"],
"description": "template for cba_fnc_execNextFrame",
"body": [
"_statement = {};",
"_parameters = [];",
"[_statement, _parameters] call CBA_fnc_execNextFrame;"
]
}
}
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"comment-line": {
"prefix": ["//", "CommentLine", "CLine"],
"body": [
"///////////////////////////////////////////////////",
""
],
"description": "///////////////////////////////////////////////////"
},
"Comment-Block": {
"prefix": ["// ##", "CommentBlock", "CBlock"],
"body": [
"//////////////////////////////////////////////////",
"///////////// ${1:TO DO} /////////////",
"//////////////////////////////////////////////////",
"/*",
"",
"${2:Code Here}",
"",
"*/",
"//////////////////////////////////////////////////"
],
"description": "Quick Comment Seperation of Sections"
},
"ACE_createAction": {
"prefix": ["ACE_createAction", "ace_interact_menu_fnc_createAction"],
"body": [
"_code = {",
" {${1:systemChat \"yolo\";}},",
"};",
"",
"_aceAction = [",
" \"${2:My_Action_ID_Name}\", // * 0: Action name <STRING>",
" \"${3:Display String}\", // * 1: Name of the action shown in the menu <STRING>",
" ${4:\"\"}, // * 2: Icon <STRING> \"\\A3\\ui_f\\data\\igui\\cfg\\simpleTasks\\types\\backpack_ca.paa\"",
" _code, // * 3: Statement <CODE>",
" {${5:true}}, // * 4: Condition <CODE>",
" {${6:}}, // * 5: Insert children code <CODE> (Optional)",
" ${7:[]}, // * 6: Action parameters <ANY> (Optional)",
" ${8:[0,0,0]}, // * 7: Position (Position array, Position code or Selection Name) <ARRAY>, <CODE> or <STRING> (Optional)",
" ${9:20}, // * 8: Distance <NUMBER> (Optional)",
" [${10:}], // * 9: Other parameters [showDisabled,enableInside,canCollapse,runOnHover,doNotCheckLOS] <ARRAY> (Optional)",
" {${11:}} // * 10: Modifier function <CODE> (Optional)",
"] call ace_interact_menu_fnc_createAction;"
],
"description": "ACE_createAction"
},
"ACE_addActiontoObject": {
"prefix": ["ACE_addActiontoObject", "ace_interact_menu_fnc_addActionToObject"],
"body": [
"[",
" ${1:myOnlyObject}, // * 0: Object the action should be assigned to <OBJECT>",
" ${2:0}, // * 1: Type of action, 0 for actions, 1 for self-actions <NUMBER>",
" ${3:[\"ACE_MainActions\"]}, // * 2: Parent path of the new action <ARRAY> (Example: `[\"ACE_SelfActions\", \"ACE_Equipment\"]`)",
" ${4:_aceAction} // * 3: Action <ARRAY> ",
"] call ace_interact_menu_fnc_addActionToObject;"
],
"description": "ACE_addActiontoObject"
},
"Function_Header" : {
"prefix": ["head","header", "fnc_header"],
"body": [
"/*",
"* Author: Zorn",
"* ${1:[Description]}",
"*",
"* Arguments:",
"*",
"* Return Value:",
"* ${2:None}",
"*",
"* Example:",
"* ['something', player] call cvo_fnc_sth",
"*",
"* Public: ${3|Yes,No|}",
"*/"
],
"description": "creates a template for a function header"
},
"Diag_Log_array_8" : {
"prefix": ["diag_log_array_8"],
"body": [
"diag_log format ['[CVO](debug)($TM_FILENAME_BASE) ${1:\"\"}: %1 - ${2:\"\"}: %2 - ${3:\"\"}: %3 - ${4:\"\"}: %4 - ${5:\"\"}: %5 - ${6:\"\"}: %6 - ${7:\"\"}: %7 - ${8:\"\"}: %8', ${1:\"\"} , ${2:\"\"} ,${3:\"\"} , ${4:\"\"} , ${5:\"\"} , ${6:\"\"} , ${7:\"\"} , ${8:\"\"} ];"
],
"description": "Creates a quick template for diag_log format"
},
"Diag_Log_array_3" : {
"prefix": ["diag_log_array_3"],
"body": [
"diag_log format ['[CVO](debug)($TM_FILENAME_BASE) ${1:\"\"}: %1 - ${2:\"\"}: %2 - ${3:\"\"}: %3', ${1:\"\"} , ${2:\"\"} ,${3:\"\"}];"
],
"description": "Creates a quick template for diag_log format"
},
"Diag_Log_array_2" : {
"prefix": ["diag_log_array_2"],
"body": [
"diag_log format ['[CVO](debug)($TM_FILENAME_BASE) ${1:\"\"}: %1 - ${2:\"\"}: %2', ${1:\"\"} , ${2:\"\"}];"
],
"description": "Creates a quick template for diag_log format"
},
"Diag_Log_array_1" : {
"prefix": ["diag_log_array_1"],
"body": [
"diag_log format ['[CVO](debug)($TM_FILENAME_BASE) ${1:\"\"}: %1', ${1:\"\"}];"
],
"description": "Creates a quick template for diag_log format"
},
"Diag_Log_short" : {
"prefix": ["diag_log_short"],
"body": [
"diag_log \"[CVO](debug)($TM_FILENAME_BASE) $1 \";"
],
"description": "Creates a quick template for diag_log format"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment