{"name":"inheritsFrom","operator":null,"title":"inheritsFrom","type":"command","url":"https://community.bistudio.com/wiki/inheritsFrom","revid":349770,"updated":"2023-11-20T22:10:08Z","groups":["Config"],"status":"ok","replaced_by":[],"games":[{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma1","name":"Armed Assault","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Returns base entry of config entry.","syntaxes":[{"syntax":"inheritsFrom config","since":null,"effect":null,"exec":null,"params":[{"name":"config","type":"Config","optional":false,"default":null,"description":null,"types":["Config"],"since":null,"text":"config: Config"}],"returns":{"type":"Config","types":["Config"],"description":null,"text":"Config"},"form":"unary","operator":null,"left":null,"right":{"text":"config","types":["Config"]}}],"examples":[{"text":"```sqf\n_base = inheritsFrom (configFile >> \"CfgVehicles\" >> \"Car\"); // returns \"LandVehicle\" Config entry\n```","code":["_base = inheritsFrom (configFile >> \"CfgVehicles\" >> \"Car\"); // returns \"LandVehicle\" Config entry"]},{"text":"Print parent tree of given config class:\n\n```sqf\nfnc_printParents =\n{\n    disableSerialization;\n    if (!isClass _this) exitWith { hint \"Argument is not a config Class\" };\n\n    private _parents = [];\n\n    while { !isNull _this } do\n    {\n        _parents pushBack configName _this;\n        _this = inheritsFrom _this;\n    };\n\n    reverse _parents;\n\n    private _tv = findDisplay 46 createDisplay \"RscDisplayEmpty\" ctrlCreate [\"RscTree\", -1];\n    _tv ctrlSetPosition [0,0,1,1];\n    _tv ctrlSetBackgroundColor [0,0,0,0.5];\n    _tv ctrlCommit 0;\n\n    private _path = [];\n    {\n        _tv tvAdd [_path, _x];\n        _path pushBack 0;\n    }\n    forEach _parents;\n\n    tvExpandAll _tv;\n};\n\n// Example:\n(configFile >> \"CfgVehicles\" >> typeOf player) call fnc_printParents;\n```","code":["fnc_printParents =\n{\n\tdisableSerialization;\n\tif (!isClass _this) exitWith { hint \"Argument is not a config Class\" };\n\n\tprivate _parents = [];\n\n\twhile { !isNull _this } do\n\t{\n\t\t_parents pushBack configName _this;\n\t\t_this = inheritsFrom _this;\n\t};\n\n\treverse _parents;\n\n\tprivate _tv = findDisplay 46 createDisplay \"RscDisplayEmpty\" ctrlCreate [\"RscTree\", -1];\n\t_tv ctrlSetPosition [0,0,1,1];\n\t_tv ctrlSetBackgroundColor [0,0,0,0.5];\n\t_tv ctrlCommit 0;\n\n\tprivate _path = [];\n\t{\n\t\t_tv tvAdd [_path, _x];\n\t\t_path pushBack 0;\n\t}\n\tforEach _parents;\n\n\ttvExpandAll _tv;\n};\n\n// Example:\n(configFile >> \"CfgVehicles\" >> typeOf player) call fnc_printParents;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["configFile","a / b","configName","count","getArray","getText","getNumber","isArray","isClass","isNumber","isText","select","configHierarchy","isKindOf"],"notes":[{"user":"ffur2007slx2_5","date":"2014-04-02T17:11:00Z","text":"(A3 1.14) Use BIS_fnc_returnParents if a parents' collection of the given entry is needed.\n\n```sqf\n[configFile >> \"CfgVehicles\" >> \"Land_Atm_02_F\", true] call BIS_fnc_returnParents;\n// return: [\"Land_Atm_02_F\", \"House_Small_F\", \"House_F\", \"House\", \"HouseBase\", \"NonStrategic\", \"Building\", \"Static\", \"All\"]\n```\n\nNot all entries have parent, and please differ parents from path.\n\n```sqf\ninheritsFrom (configFile >> \"CfgUIColors\" >> \"IGUI\" >> \"Presets\" >> \"PresetA1\" >> \"Variables\");\n// return: Nothing\n```"}],"categories":["ArmA: Armed Assault: New Scripting Commands","ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Config","Introduced with Armed Assault version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}