Jump to content
sarogahtyp

get all class names by script

Recommended Posts

Hey guys,

 

is it possible to get all class names which are available by a script?

 

What I want to do is to get all vehicle class names of the CUP vehicles mod because I like to spawn em all and do some automated tests for creating bug reports on CUPs bug tracker.

If it is possible to get all class names then I would be able to filter out the CUP vehicles and do those tests.

Share this post


Link to post
Share on other sites

configClasses:

_allClassNames = ("true" configClasses (configFile >> "CfgVehicles")) apply {configName _x};

You can add filters for further sorting by author, DLC, etc.

Suggest to filter anything that has a scope value of less than 2 if you plan on spawning them.

 

Cheers

  • Like 5
  • Thanks 1

Share this post


Link to post
Share on other sites

@Grumpy Old Man

thanks a lot. I didn't know bout the configClasses command. There is also an example which should fit very well for my purpose:

 

// adapted from Iceman77's example on the wiki entry of configClasses command.

private ["_cfgArray","_xPos","_yPos","_veh"];
 
_cfgArray = "((getNumber (_x >> 'scope') >= 2) && {getText (_x >> 'vehicleClass') in ['Armored', 'Car', 'Air'] } )" configClasses (configFile >> "CfgVehicles");

_xPos = 0;
_yPos = 0;

{
    _yPos = _yPos + 20;
    _veh = createVehicle [ ( configName _x ), player modelToWorld [_xPos, _yPos, 0], [], 0, "None"];
    if (_yPos >= 100) then {
        _yPos = 0;
        _xPos = _xPos + 20;
    };
} forEach _cfgArray;

but I ve  questions.

Why did u @Grumpy Old Man suggest a scope lower than 2 while Iceman77 uses >= 2?

Also I do not fully understand your apply code.

  • Like 1

Share this post


Link to post
Share on other sites
51 minutes ago, sarogahtyp said:

Why did u @Grumpy Old Man suggest a scope lower than 2 while Iceman77 uses >= 2?

He said to filter, and likely meant to filter out anything that is < 2. Same as the example that filters inclusion of scope >= 2.

 

54 minutes ago, sarogahtyp said:

Also I do not fully understand your apply code.

ConfigClasses returns an array of config paths. Applying configname to each path returns the items class name.

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

How about an Eden tool something like...

Spoiler

disableSerialization;

LARs_fnc_clearObjects = {
	params[ "_btn" ];

	delete3DENEntities LARs_spawnedObjects;

	_btn ctrlEnable false;
};

LARs_fnc_spawnObjects = {
	params[ "_btn" ];

	_display = ctrlParent _btn;
	_lb = _display displayCtrl 1004;

	_spawnPosition = screenToWorld [ 0.5, 0.5 ];
	_minSpacing = 2;
	_lastVehicle = nil;

	for "_i" from 0 to ( lbSize _lb ) - 1 do {
		_vehicleType = _lb lbData _i;

		_newVehicle = create3DENEntity [ "Object", _vehicleType, [0,0,0], true ];

		if !( isNil "_lastVehicle" ) then {
			systemChat "adding";
			_maxLast = boundingBoxReal _lastVehicle select 1 select 0;
			_maxNew = boundingBoxReal _newVehicle select 1 select 0;
			_spawnPosition = _spawnPosition vectorAdd [ _maxLast + _maxNew + _minSpacing, 0, 0 ];
			_spawnPosition set[ 2, 0 ];
		};

		_lastVehicle = _newVehicle;
		_lastVehicle set3DENAttribute [ "position", _spawnPosition ];
		_lastVehicle set3DENAttribute [ "rotation", getDir get3DENCamera - 180 ];

		private _nul = LARs_spawnedObjects pushBack _lastVehicle;
	};

	_display displayCtrl 1006 ctrlEnable true;
};

LARs_fnc_selectObjects = {
	params[ "_combo", "_selectedIndex" ];

	_display = ctrlParent _combo;
	_btn = _display displayCtrl 1005;

	//Faction
	if ( ctrlIDC _combo isEqualTo 1001 && { lbCurSel ( _display displayCtrl 1002 ) < 0 } ) exitWith { _btn ctrlEnable false };

	//SubCat
	if ( ctrlIDC _combo isEqualTo 1002 && { lbCurSel ( _display displayCtrl 1001 ) < 0 } ) exitWith { _btn ctrlEnable false };

	_side = lbCurSel ( _display displayCtrl 1000 );
	_faction = ( _display displayCtrl 1001 ) lbData lbCurSel ( _display displayCtrl 1001 );
	_subCat = _display displayCtrl 1002 lbData _selectedIndex;

	systemChat format[ "S: %1, F: %2, SC: %3", _side, _faction, _subCat ];

	_lb = _display displayCtrl 1004;
	lbClear _lb;
	{
		private _index = _lb lbAdd format[ "%1 ( %2 )", getText( _x >> "displayName" ), configName _x ];
		_lb lbSetData[ _index, configName _x ];
	}forEach ( "getNumber( _x >> 'scope' ) >= 2 && { getText( _x >> 'editorSubcategory' ) == _subCat } && { getNumber( _x >> 'side' ) isEqualTo _side } && { getText( _x >> 'faction' ) isEqualTo _faction }"configClasses( configFile >> "CfgVehicles" ));

	if ( lbSize _lb > 0 ) then {
		_btn ctrlEnable true;
	}else{
		_btn ctrlEnable false;
	};

};

LARs_fnc_getFactions = {
	params[ "_sideCombo", "_selectedIndex", "_factionIDC" ];

	_display = ctrlParent _sideCombo;
	_factionCombo = _display displayCtrl _factionIDC;
	lbClear _factionCombo;

	{
		private _index = _factionCombo lbAdd getText( _x >> "displayName" );
		_factionCombo lbSetData[ _index, configName _x ];
	}forEach ( "getNumber( _x >> 'side' ) isEqualTo _selectedIndex"configClasses( configFile >> "CfgFactionClasses" ));
	lbSort _factionCombo;
};

if ( isNil "LARs_spawnedObjects" ) then {
	LARs_spawnedObjects = [];
};

_display = findDisplay 313 createDisplay "RscDisplayEmpty";

_elementWidth = 0.3;
_spacing = 1/3 - _elementWidth;

{
	_x params[ "_heading", [ "_data", [] ], [ "_code", {} ], [ "_sort", false ] ];

	_idc = 1000 + _forEachIndex;

	_header = _display ctrlCreate [ "ctrlStatic", -1 ];
	_header ctrlSetText _heading;
	_header ctrlSetPosition[ (( _spacing + _elementWidth ) * _forEachIndex ), -0.05, _elementWidth, 0.05 ];
	_header ctrlCommit 0;

	_combo = _display ctrlCreate [ "ctrlCombo", _idc ];
	_combo ctrlSetPosition[ (( _spacing + _elementWidth ) * _forEachIndex ), 0, _elementWidth, 0.05 ];
	_combo ctrlCommit 0;
	{
		//Ed Sub Cat
		if ( _idc isEqualTo 1002 ) then {
			private _index = _combo lbAdd getText( _x >> "displayName" );
			_combo lbSetData[ _index, configName _x ]
		}else{
			//Side
			_combo lbAdd str _x;
		};
	}forEach _data;
	if ( _sort ) then {
		lbSort _combo;
	};
	_combo ctrlAddEventHandler [ "LBSelChanged", _code ];

}forEach [
	[ "Side", [ east, west, independent, civilian ], { _this + [ 1001 ] call LARs_fnc_getFactions } ],
	[ "Faction", [], { _this call LARs_fnc_selectObjects } ],
	[ "Eden Sub Cat", "true"configClasses( configFile >> "CfgEditorSubcategories" ), { _this call LARs_fnc_selectObjects }, true ]
];

_lb = _display ctrlCreate [ "ctrlListbox", 1004 ];
_lb ctrlSetPosition[ 0, 0.1, 0.66, 0.8 ];
_lb ctrlCommit 0;

_btn = _display ctrlCreate [ "ctrlButton", 1005 ];
_btn ctrlSetText "Spawn";
_btn ctrlEnable false;
_btn ctrlSetPosition[ 0, 0.9, 0.66, 0.1 ];
_btn ctrlAddEventHandler [ "ButtonClick", { _this call LARs_fnc_spawnObjects }];
_btn ctrlCommit 0;

_btn = _display ctrlCreate [ "ctrlButton", 1006 ];
_btn ctrlSetText "Clear";
_btn ctrlEnable !( LARs_spawnedObjects isEqualTo [] );
_btn ctrlSetPosition[ 0.66 + _spacing, 0.9, _elementWidth, 0.1 ];
_btn ctrlAddEventHandler [ "ButtonClick", { _this call LARs_fnc_clearObjects }];
_btn ctrlCommit 0;

 

Just run it from the debugConsole whilst in Eden.

Could have some better options for drilling down to specific sets, but will do as a quick test piece.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

gorgeous!

if you think you are understanding scripting partially and are kind of proud of it then Larrow walks around the corner and shows you things which are looking kind of chinese to you.

 

nice script, thanks man.

  • Like 2

Share this post


Link to post
Share on other sites

@Larrow

I guess I filtered the wanted CUP vehicles now with this modification of ur code:

lbClear _lb;
	{
	   if (((toLower configName _x) find "cup") > -1) then
	   {
	   
		private _index = _lb lbAdd format[ "%1 ( %2 )", getText( _x >> "displayName" ), configName _x ];
		_lb lbSetData[ _index, configName _x ];
	   };
	}forEach ( "getNumber( _x >> 'scope' ) >= 2 && { getText (_x >> 'vehicleClass') in ['Armored', 'Car', 'Air'] && getText( _x >> 'editorSubcategory' ) == _subCat } && { getNumber( _x >> 'side' ) isEqualTo _side } && { getText( _x >> 'faction' ) isEqualTo _faction }"
	           configClasses( configFile >> "CfgVehicles" ));

 

but could you point me pls where I ve to start if I'dlike to filter out all sub categories where no cup vehicle is in?

 

EDIT: I think this wish isn't such important. I noticed that Ive to test so much vehicles now that the time I need to crawl that categories does not matter...

 

         thx again. now after testing and working with ur script I notice that it is a real big help for my purpose.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×