jshock 513 Posted November 14, 2014 (edited) Hello Scripting Community, Is there a way to use something like MISSION_ROOT, but with the configfile instead? Here is a standard configfile directory path to the desired class: (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSentry") I'm wondering if there can be anything like this: (CONFIG_ROOT >> "OIA_InfSentry") Main reason behind this is that the group class being defined (in the example: "OIA_InfSentry") is randomized, and I want to be able to fill the array with group classes from all sides, not just EAST, so if I can define just the final group class name, and then have the rest of the configFile directory filled in, it would make life much easier. Edited November 14, 2014 by JShock Share this post Link to post Share on other sites
dreadedentity 278 Posted November 14, 2014 Yes, you can do this _myConfig = (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry"); _unitConfig = (_myConfig >> "OIA_InfSentry"); That creates a variable containing a "config" data type ---------- Post added at 23:36 ---------- Previous post was at 23:27 ---------- Okay, the main difference between what you asking for and MISSION_ROOT is that with ROOT, there is actually no variability. You want to input something and get a certain output. So that said, this should be good. CONFIG_ROOT = { _myConfig = (configfile >> "CfgGroups" >> _this >> "OPF_F" >> "Infantry"); _myConfig; }; So all you have to do is call CONFIG_ROOT with the side string _myConfig = ("East" call CONFIG_ROOT >> "OIA_InfSentry"); _myConfig = ("West" call CONFIG_ROOT >> "OIA_InfSentry"); _myConfig = ("Civ" call CONFIG_ROOT >> "OIA_InfSentry"); _myConfig = ("Guer" call CONFIG_ROOT >> "OIA_InfSentry"); Yeah...that should totally work. Share this post Link to post Share on other sites
jshock 513 Posted November 14, 2014 Yes, you can do this _myConfig = (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry"); _unitConfig = (_myConfig >> "OIA_InfSentry"); That creates a variable containing a "config" data type ---------- Post added at 23:36 ---------- Previous post was at 23:27 ---------- Okay, the main difference between what you asking for and MISSION_ROOT is that with ROOT, there is actually no variability. You want to input something and get a certain output. So that said, this should be good. CONFIG_ROOT = { _myConfig = (configfile >> "CfgGroups" >> _this >> "OPF_F" >> "Infantry"); _myConfig; }; So all you have to do is call CONFIG_ROOT with the side string _myConfig = ("East" call CONFIG_ROOT >> "OIA_InfSentry"); _myConfig = ("West" call CONFIG_ROOT >> "OIA_InfSentry"); _myConfig = ("Civ" call CONFIG_ROOT >> "OIA_InfSentry"); _myConfig = ("Guer" call CONFIG_ROOT >> "OIA_InfSentry"); Yeah...that should totally work. I will definitely resort to this when I need to, but there is so much variability in each config call("East"/"OPF_F"/"Infantry", etc.) that needs to change based on the group's side, and even though I don't use mods, it would be nice to have this mod friendly so someone would only have to input the group classes from the mod and it gets the config directory automatically for them. Share this post Link to post Share on other sites
Tajin 349 Posted November 15, 2014 So this is just about providing an easy way to select all available infantry groups from a certain mod, correct ? Share this post Link to post Share on other sites
jshock 513 Posted November 15, 2014 This is about an easy way to get the config directory of a group class, so that even if someone were to use a mod the function would find/use the correct configFile directory when spawning in that group via BIS_fnc_spawnGroup. Share this post Link to post Share on other sites
Tajin 349 Posted November 15, 2014 fnc_configSearch = { private ["_needle","_cfg","_found","_x"]; _needle = _this select 0; _cfg = _this select 1; if ( !isClass _cfg ) exitWith { false }; _name = configName _cfg; if ( _name == _needle ) exitWith { _cfg }; _cnt = count _cfg; if ( _cnt isEqualTo 0 ) exitWith { false }; _x = 0; while { _x < _cnt } do { if ( isClass (_cfg select _x) ) then { _found = [_needle,_cfg select _x] call fnc_configSearch; }; if (typeName _found == "CONFIG") exitWith {_found}; _x = _x + 1; }; _found }; Use like this: result = ["OIA_InfSquad",configfile >> "CfgGroups"] call fnc_configSearch; For a reason that I completely fail to understand, it throws a script error. Aside from that, it works. Share this post Link to post Share on other sites
mikey74 169 Posted March 27, 2016 I know this is an old thread, but is there a way to get a group class name by script call. We have typeOf for units, but is there something for groups. So far I've not found anything, but I seem to remember pulling this off 3 or 4 computers ago. Wished Id kept all my pc's lol Share this post Link to post Share on other sites
das attorney 858 Posted March 27, 2016 Not sure but you could save a variable to the group to store what class it is and retrieve it when you need it. Share this post Link to post Share on other sites
mikey74 169 Posted March 27, 2016 Thanks das, What I've been doing. I can select all groups in bis by script now, but some mods and 1 faction for bis does not follow patterns of configs. hmm Thats confusing. let me put a piece of my code up and you may figure out what im trying to do. Before I do. There are certian mods that do not have the same factions for groups as they do there units. Bis has 1 that does that. Guer: If I can get an actual classname for a group I can fix this without individually loading each mod classname. params[ "_mod"// Is the module used to call this script ]; private ["_playableP","_playable","_side","_type","_Suptype","_Strength","_units","_StrStrt","_sidePlay","_UNside","_UNside1"]; _playableP = if (isMultiplayer) then {playableUnits + [player]} else {switchableUnits + [player]}; _playable = _mod getVariable "BL_SyncdU"; //synced units to module if (isNil "_playable" or count _playable <=0) then {_playable = _playableP}; _side = (_mod getVariable "BL_side"); _type = (_mod getVariable "BL_Type"); _Suptype = (_mod getVariable "BL_SupType"); _Strength = (_mod getVariable "BL_Strength"); _units = (_mod getVariable "BL_sideU"); _sidePlay = []; {if (_side == side _x or _units == side _x) then {_sidePlay pushBack _x};} forEach _playable; _F2pick = if (count _sidePlay > 0) then {(_sidePlay call BIS_fnc_selectRandom)} else {nil}; if (isNil "_F2pick") then { _sidePlay = []; }; _UNside = format ["%1",_units]; _UNside1 = if (_UNside == "Guer") then {"Indep"} else {_UNside}; _WAllFac = (configFile >> "CfgGroups" >> _UNside1) call BIS_fnc_getCfgSubClasses; _RFac = if (count _sidePlay > 0) then {faction _F2pick} else {_WAllFac call BIS_fnc_selectRandom};//if (_side == side player) then {faction player} else {_WAllFac call BIS_fnc_selectRandom}; _RFac = if (_RFac == "BLU_G_F") then {"Guerilla"} else {_RFac}; _RFac = if (_RFac == "rhs_faction_tv") then {"rhs_faction_vdv"} else {_RFac};///////// FIX THIS TANKSSSS _WAllClass = (configFile >> "CfgGroups" >> _UNside1 >> _RFac) call BIS_fnc_getCfgSubClasses; //hint str [_WAllClass,_RFac]; //_WAllGroupsG = (configFile >> "CfgGroups" >> _UNside1 >> _RFac >> _Rclass) call BIS_fnc_getCfgSubClasses; _Rclass = _WAllClass call BIS_fnc_selectRandom; //hint str [_WAllClass_mrk1,_RFac]; _Fac_has_infantry = [_WAllClass,_UNside1,_RFac] call BL_fnc_BLhasInfantry; _Fac_has_tanks = [_WAllClass,_UNside1,_RFac] call BL_fnc_BLhasTank; _Fac_has_motor = [_WAllClass,_UNside1,_RFac] call BL_fnc_BLisMotor; _Fac_has_Mech = [_WAllClass,_UNside1,_RFac] call BL_fnc_BLisMech; //[_WAllClass,_UNside1,_RFac] call BL_BLhasAir; _Fac_has_Arty = [_WAllClass,_UNside1,_RFac] call BL_fnc_BLhasArty; _Fac_has_car = [_WAllClass,_UNside1,_RFac] call BL_fnc_BLhasCar; Most mods and all vanilla works with this. There is 2 mods that I know of that throw errors. Both mods are massive. lol Share this post Link to post Share on other sites
mikey74 169 Posted March 27, 2016 ok I've written a script to find a group in a faction with different faction names for groups as apposed to faction names for there units. Don't know why I didn't think of this sooner. :/ params [ "_group" ]; _side = str (side _group); _unitsGrpT = []; _unitfaction = faction leader _group; _WAllFac = (configFile >> "CfgGroups" >> _side) call BIS_fnc_getCfgSubClasses; if (_unitfaction in _WAllFac) exitWith {_unitfaction};//else {hint "in"}; //sleep 1; { _type = typeOf (Vehicle _x); if !(_type in _unitsGrpT) then {_unitsGrpT pushBack _type}; } forEach units _group;//Alpha; _SideAllClass = [];//(configFile >> "CfgGroups" >> _mrk1 >> _RFac) call BIS_fnc_getCfgSubClasses; //sleep 1; _allsideGroups = []; _factionsselected = []; { _factions = _x; //sleep 1; _Classes = (configFile >> "CfgGroups" >> _side >> _factions) call BIS_fnc_getCfgSubClasses; //hint str _Classes; if !(_Classes in _SideAllClass) then { _SideAllClass append _Classes; { _class = _x; //sleep 1; _Groups = (configFile >> "CfgGroups" >> _side >> _factions >> _class) call BIS_fnc_getCfgSubClasses; //hint str _Classes; if !(_Groups in _allsideGroups) then { _allsideGroups append _Groups; { _grpclass = _x; _Unitclasses = (configFile >> "CfgGroups" >> _side >> _factions >> _class >> _grpclass) call BIS_fnc_getCfgSubClasses; _allUnitsgrpClass = []; { _unt = _x; _unitT = [(configFile >> "CfgGroups" >> _side >> _factions >> _class >> _grpclass >> _unt),"vehicle",0]call BIS_fnc_returnConfigEntry; if !(_unitT in _allUnitsgrpClass) then {_allUnitsgrpClass pushBack _unitT}; //hint str _unitT; //sleep 1; } forEach _Unitclasses; //hint str _allUnitsgrpClass; //sleep 1; if (_unitsGrpT isequalTo _allUnitsgrpClass) then {_factionsselected pushBack _factions}; } forEach _Groups; }; } forEach _Classes; }; } forEach _WAllFac; //hint str _SideAllClass; _selected = if (count _factionsselected > 0) then {selectRandom _factionsselected} else {nil}; hint str _selected; _selectedYou call it with something like [groupname] execVM "namegiventoscript.sqf"example of that for me will be [_group] execVM "FindGfaction.sqf" or If you define script in a config or descriptionext for me it will be: [_group] spawn FOA_fnc_findGclass; Share this post Link to post Share on other sites