inheritsFrom: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "$1$2</code>") |
Lou Montana (talk | contribs) m (Text replacement - "[[Image:" to "[[File:") |
||
(40 intermediate revisions by 2 users not shown) | |||
Line 26: | Line 26: | ||
|r1= [[Config]] | |r1= [[Config]] | ||
|x1= < | |x1= <sqf>_base = inheritsFrom (configFile >> "CfgVehicles" >> "Car"); // returns "LandVehicle" Config entry</sqf> | ||
|x2= Print parent tree of given config class: | |x2= [[File:inheritsFrom.jpg|right|300px]] | ||
< | Print parent tree of given config class: | ||
<sqf> | |||
fnc_printParents = | |||
{ | { | ||
disableSerialization; | |||
if (!isClass _this) exitWith { hint "Argument is not a config Class" }; | |||
private _parents = []; | |||
while { !isNull _this } do | |||
{ | { | ||
_parents | _parents pushBack configName _this; | ||
_this = | _this = inheritsFrom _this; | ||
}; | }; | ||
reverse _parents; | |||
private _tv = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscTree", -1]; | |||
_tv | _tv ctrlSetPosition [0,0,1,1]; | ||
_tv | _tv ctrlSetBackgroundColor [0,0,0,0.5]; | ||
_tv | _tv ctrlCommit 0; | ||
private _path = []; | |||
{ | { | ||
_tv | _tv tvAdd [_path, _x]; | ||
_path | _path pushBack 0; | ||
} | } | ||
forEach _parents; | |||
tvExpandAll _tv; | |||
}; | }; | ||
// Example: | // Example: | ||
(configFile >> "CfgVehicles" >> typeOf | (configFile >> "CfgVehicles" >> typeOf player) call fnc_printParents; | ||
</sqf> | |||
|seealso= [[configFile]] [[ | |seealso= [[configFile]] [[a / b]] [[configName]] [[count]] [[getArray]] [[getText]] [[getNumber]] [[isArray]] [[isClass]] [[isNumber]] [[isText]] [[select]] [[configHierarchy]] [[isKindOf]] | ||
}} | }} | ||
{{Note | |||
|user= ffur2007slx2_5 | |||
|timestamp= 20140402171100 | |||
|text= (A3 1.14) Use [[BIS_fnc_returnParents]] if a parents' collection of the given entry is needed. | |||
<sqf> | |||
[configFile >> "CfgVehicles" >> "Land_Atm_02_F", true] call BIS_fnc_returnParents; | |||
(A3 1.14)Use [[BIS_fnc_returnParents]] if a parents' collection of the given entry is needed. | // return: ["Land_Atm_02_F", "House_Small_F", "House_F", "House", "HouseBase", "NonStrategic", "Building", "Static", "All"] | ||
< | </sqf> | ||
//return: ["Land_Atm_02_F","House_Small_F","House_F","House","HouseBase","NonStrategic","Building","Static","All"] | |||
</ | |||
Not all entries have parent, and please differ parents from path. | Not all entries have parent, and please differ parents from path. | ||
< | <sqf> | ||
//return: Nothing | inheritsFrom (configFile >> "CfgUIColors" >> "IGUI" >> "Presets" >> "PresetA1" >> "Variables"); | ||
</ | // return: Nothing | ||
</sqf> | |||
}} |
Latest revision as of 23:10, 20 November 2023
Description
- Description:
- Returns base entry of config entry.
- Groups:
- Config
Syntax
- Syntax:
- inheritsFrom config
- Parameters:
- config: Config
- Return Value:
- Config
Examples
- Example 1:
- Example 2:
-
Print parent tree of given config class:
fnc_printParents = { disableSerialization; if (!isClass _this) exitWith { hint "Argument is not a config Class" }; private _parents = []; while { !isNull _this } do { _parents pushBack configName _this; _this = inheritsFrom _this; }; reverse _parents; private _tv = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscTree", -1]; _tv ctrlSetPosition [0,0,1,1]; _tv ctrlSetBackgroundColor [0,0,0,0.5]; _tv ctrlCommit 0; private _path = []; { _tv tvAdd [_path, _x]; _path pushBack 0; } forEach _parents; tvExpandAll _tv; }; // Example: (configFile >> "CfgVehicles" >> typeOf player) call fnc_printParents;
Additional Information
- See also:
- configFile a / b configName count getArray getText getNumber isArray isClass isNumber isText select configHierarchy isKindOf
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
- Posted on Apr 02, 2014 - 17:11 (UTC)
-
(A3 1.14) Use BIS_fnc_returnParents if a parents' collection of the given entry is needed.
Not all entries have parent, and please differ parents from path.[configFile >> "CfgVehicles" >> "Land_Atm_02_F", true] call BIS_fnc_returnParents; // return: ["Land_Atm_02_F", "House_Small_F", "House_F", "House", "HouseBase", "NonStrategic", "Building", "Static", "All"]
Categories:
- Scripting Commands
- Introduced with Armed Assault version 1.00
- ArmA: Armed Assault: New Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: Config