inheritsFrom: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (template:command argument fix)
m (Text replacement - "[[Image:" to "[[File:")
 
(100 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma |= Game name
|game1= arma1
|version1= 1.00


|1.00|= Game version
|game2= arma2
____________________________________________________________________________________________
|version2= 1.00


| Returns base entry of config entry.  |DESCRIPTION=
|game3= arma2oa
____________________________________________________________________________________________
|version3= 1.50


| '''inheritsFrom''' config |SYNTAX=
|game4= tkoh
|version4= 1.00


|p1= config: [[Config]] |PARAMETER1=
|game5= arma3
|version5= 0.50


| [[Config]] |RETURNVALUE=
|gr1= Config
____________________________________________________________________________________________
|x1 = <code>_base = [[inheritsFrom]] ([[configFile]] [[gtgt|>>]] "CfgVehicles" [[gtgt|>>]] "Car");</code> Result is [[Config]] entry for class "LandVehicle" |EXAMPLE1=


|x2 = Print parent tree of given config class:<code>fnc_printParents =
|descr= Returns base entry of config entry.
 
|s1= [[inheritsFrom]] config
 
|p1= config: [[Config]]
 
|r1= [[Config]]
 
|x1= <sqf>_base = inheritsFrom (configFile >> "CfgVehicles" >> "Car"); // returns "LandVehicle" Config entry</sqf>
 
|x2= [[File:inheritsFrom.jpg|right|300px]]
Print parent tree of given config class:
<sqf>
fnc_printParents =
{
{
[[disableSerialization]];
disableSerialization;
[[if]] (![[isClass]] _this) [[exitWith]] {[[hint]] "Argument is not a config Class"};
if (!isClass _this) exitWith { hint "Argument is not a config Class" };
 
[[private]] _parents = [];
private _parents = [];
 
[[while]] {![[isNull]] _this} [[do]]
while { !isNull _this } do
{
{
_parents [[pushBack]] [[configName]] _this;
_parents pushBack configName _this;
_this = [[inheritsFrom]] _this;
_this = inheritsFrom _this;
};
};
 
[[reverse]] _parents;
reverse _parents;
 
[[private]] _tv = [[findDisplay]] 46 [[createDisplay]] "RscDisplayEmpty" [[ctrlCreate]] ["RscTree", -1];
private _tv = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscTree", -1];
_tv [[ctrlSetPosition]] [0,0,1,1];
_tv ctrlSetPosition [0,0,1,1];
_tv [[ctrlSetBackgroundColor]] [0,0,0,0.5];
_tv ctrlSetBackgroundColor [0,0,0,0.5];
_tv [[ctrlCommit]] 0;
_tv ctrlCommit 0;
 
[[private]] _path = [];
private _path = [];
{
{
_tv [[tvAdd]] [_path, _x];
_tv tvAdd [_path, _x];
_path [[pushBack]] 0;
_path pushBack 0;
}  
}
[[forEach]] _parents;
forEach _parents;
 
[[tvExpandAll]] _tv;
tvExpandAll _tv;
};
};


// Example:
// Example:
([[configFile]] >> "CfgVehicles" >> [[typeOf]] [[player]]) [[call]] fnc_printParents;</code>
(configFile >> "CfgVehicles" >> typeOf player) call fnc_printParents;
[[Image:inheritsFrom.jpg|left|300px]] |EXAMPLE2=
</sqf>
 
 
| [[configFile]], [[config/name]], [[configName]], [[count]], [[getArray]], [[getText]], [[getNumber]], [[isArray]], [[isClass]], [[isNumber]], [[isText]], [[select]], [[configHierarchy]], [[isKindOf]] |SEEALSO=


|seealso= [[configFile]] [[a / b]] [[configName]] [[count]] [[getArray]] [[getText]] [[getNumber]] [[isArray]] [[isClass]] [[isNumber]] [[isText]] [[select]] [[configHierarchy]] [[isKindOf]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= ffur2007slx2_5
<!-- Note Section BEGIN -->
|timestamp= 20140402171100
<dd class="notedate">Posted on Apr 2, 2014 - 17:11
|text= (A3 1.14) Use [[BIS_fnc_returnParents]] if a parents' collection of the given entry is needed.
<dt class="note">'''[[User:ffur2007slx2_5|ffur2007slx2_5]]'''<dd class="note">
<sqf>
(A3 1.14)Use [[BIS_fnc_returnParents]] if a parents' collection of the given entry is needed.
[configFile >> "CfgVehicles" >> "Land_Atm_02_F", true] call BIS_fnc_returnParents;
<code>
// return: ["Land_Atm_02_F", "House_Small_F", "House_F", "House", "HouseBase", "NonStrategic", "Building", "Static", "All"]
[([[configFile]] >> "CfgVehicles" >> "Land_Atm_02_F"),[[true]] ] [[call]] [[BIS_fnc_returnParents]];
</sqf>
//return: ["Land_Atm_02_F","House_Small_F","House_F","House","HouseBase","NonStrategic","Building","Static","All"]
</code>
Not all entries have parent, and please differ parents from path.
Not all entries have parent, and please differ parents from path.
<code>
<sqf>
[[inheritsFrom]] ([[configFile]] >> "CfgUIColors" >> "IGUI" >> "Presets" >> "PresetA1" >> "Variables");
inheritsFrom (configFile >> "CfgUIColors" >> "IGUI" >> "Presets" >> "PresetA1" >> "Variables");
//return: Nothing
// return: Nothing
</code>
</sqf>
<!-- Note Section END -->
}}
</dl>
 
<h3 style="display:none">Bottom Section</h3>
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_System_Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 23:10, 20 November 2023

Hover & click on the images for description

Description

Description:
Returns base entry of config entry.
Groups:
Config

Syntax

Syntax:
inheritsFrom config
Parameters:
config: Config
Return Value:
Config

Examples

Example 1:
_base = inheritsFrom (configFile >> "CfgVehicles" >> "Car"); // returns "LandVehicle" Config entry
Example 2:
inheritsFrom.jpg

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
ffur2007slx2_5 - c
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.
[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"]
Not all entries have parent, and please differ parents from path.
inheritsFrom (configFile >> "CfgUIColors" >> "IGUI" >> "Presets" >> "PresetA1" >> "Variables"); // return: Nothing