First of all this is fictitious function and is not part of ArmA 3, although I’m going to try to convince BIS devs to incorporate something like this into the default functions library. Why is this needed? Because compileFinal requires string, but when you code you write code. If you want to lock your code afterwards you have to convert it to string to use with compileFinal. I have already made compileFinal JavaScript converter to accomplish this, but this new method I’m talking about, could be much more convenient.

Anyway the idea is to convert code to string on the fly by passing the name of the variable containing your code to a function which will do the conversion and compiling. I think I’ll just post the whole code instead of trying to explain how it works so everyone can see for themselves:

BIS_fnc_compileFinal = { /* Author: Killzone_Kid Description: Recompiles existing code to final Parameter(s): _this select 0: STRING - name of the variable containing code - variables containing no code are ignored _this select 1: NAMESPACE (Optional) - namespace of the variable containing code - if no namespace provided missionNamespace is assumed Returns: BOOL - true on success - false on failure Example 1: myCode = { hint "This is my code!" }; //recompile myCode to final ["myCode"] call BIS_fnc_compileFinal; Example 2: with uiNamespace do { myCode2 = { hint "This is my code too!" } }; //recompile myCode2 to final and alert on success if (["myCode2",uiNamespace] call BIS_fnc_compileFinal) then { hint "Success!" }; */ private ["_var","_ns","_code","_arr"]; _var = [_this,0,"",[""]] call BIS_fnc_param; _ns = [_this,1,missionNamespace,[missionNamespace]] call BIS_fnc_param; _code = _ns getVariable [_var, 0]; if (typeName _code != typeName {}) exitWith {false}; _arr = toArray str _code; _arr set [0,32]; _arr set [count _arr - 1,32]; _code = compileFinal toString _arr; _ns setVariable [_var, _code]; true };

I’ve tested it and it works just fine. Now let’s let the world know 🙂

Enjoy,
KK