Luft08 27 Posted March 17, 2020 I've watched several videos and read many posts about functions but I can't seem to get mine to work. description.ext: class CfgFunctions { #include "functions\cfgFunctions.hpp" }; cfgFunctions.hpp (inside a folder called functions): class cfgFunctions { class LFT { tag = "LFT"; class functions { file = "functions\functions.sqf"; class GetDistance {}; }; }; }; functions.sqf (inside the folder called functions): GetDistance = { params ["_object1", "_object2"]; private _distance = _object1 distance _object2; _distance }; inside the calling script: private _distance = [officer_01, weaponsCache] call getDistance; hint str _distance; The officer_01 and weaponsCache are both objects. When called I get an "undefined variable getDistance" error. I've tried calling LFT_getDistance, LFT_fn_getDistance and LFT_fnc_getDistance but no joy. I need a slow thinker's tutorial I guess. 😞 Share this post Link to post Share on other sites
Larrow 2801 Posted March 18, 2020 Description.ext class CfgFunctions { #include "functions\cfgFunctions.hpp" }; functions\cfgFunctions.hpp class LFT { //Project tag = "LFT"; //TAG class functions { //Category file = "functions"; //Folder path the following functions are found in class GetDistance {}; //function .sqf file name, minus proceeding fn_ }; }; functions\fn_GetDistance.sqf params ["_object1", "_object2"]; //Last evaluation is the returned value _object1 distance _object2 Produces the function LFT_fnc_GetDistance ( TAG_fnc_fileName ) hint str ( [officer_01, weaponsCache] call LFT_fnc_getDistance ); Project and Category can be used in the functions viewer drop downs to see your functions. 1 1 Share this post Link to post Share on other sites
Luft08 27 Posted March 18, 2020 Perfect! With this example I think I may be able to write functions. There is one thing. The editor I use gives a warning on the hint line: "Public variable 'LFT_fnc_getDistance' may be used before being assigned a value." The mission does not complain at all but am I forgetting to define the function or something (Just to shut my editor up) Share this post Link to post Share on other sites
Larrow 2801 Posted March 18, 2020 7 hours ago, Luft08 said: There is one thing. The editor I use gives a warning on the hint line: "Public variable 'LFT_fnc_getDistance' may be used before being assigned a value." Ignore the warning. Functions defined by CfgFunctions, are compiled final before anything else is run( init, intPlayer, initServer etc ) Initialization Order Share this post Link to post Share on other sites