Jump to content
Sign in to follow this  
CarlGustaffa

Turrets - a living nightmare

Recommended Posts

especially when doing it wrong - like I've been doing for god knows how many hours.

What the hell am I doing wrong?

Works: getText (configFile >> "CfgVehicles" >> typeOf vec >> "DisplayName")

cfg = (configFile >> "CfgVehicles" >> typeOf vec)

and returns bin\config.bin/CfgVehicles/UH60M_EP1, a config, right?

result = [cfg] call fn_returnVehicleTurrets

Showing result, it always comes out empty.

configFile >> "CfgVehicles" >> typeOf vec >> "Turrets"

returns bin\config.bin/CfgVehicles/UH60M_EP1/Turrets

getArray (configFile >> "CfgVehicles" >> typeOf vec >> "Turrets")

returns []

even if

configFile >> "CfgVehicles" >> typeOf vec >> "Turrets" >> "MainTurret"

returns bin\config.bin/CfgVehicles/UH60M_EP1/Turrets/MainTurret

Basically, about 8 hours spent trying to get number of crew positions (and eventually weapons list for each position) on an empty (has to be) vehicle, as emptyPositions doesn't return turret positions.

I'm going slightly mad over this :(

I'm using cfgExplorer to the best of my abilities, but still I'm just getting absolutely nowhere with this.

Share this post


Link to post
Share on other sites

Hi Carl. This is what I've been using to get an empty vehicles turrets/crew positions. Some BIS scripts modified by Murklor.

Not sure if they will help you or not but here goes.

As it is the functions are meant to be part of an include file.

// These functions thanks to Murklor
// -------------------------------------------------------- //
// -----------------  Start Functions  -------------------- //
// -------------------------------------------------------- //

// *WARNING* BIS FUNCTION RIPOFF - Taken from fn_returnConfigEntry as its needed for turrets and shortened a bit
_fnc_returnConfigEntry = {

private ["_config", "_entryName","_entry", "_value"];

_config = _this select 0;
_entryName = _this select 1;
_entry = _config >> _entryName;

//If the entry is not found and we are not yet at the config root, explore the class' parent.
if (((configName (_config >> _entryName)) == "") && (!((configName _config) in ["CfgVehicles", "CfgWeapons", ""]))) then {
	[inheritsFrom _config, _entryName] call _fnc_returnConfigEntry;
}
else { if (isNumber _entry) then { _value = getNumber _entry; } else { if (isText _entry) then { _value = getText _entry; }; }; };
//Make sure returning 'nil' works.
if (isNil "_value") exitWith {nil};

_value;
};

// *WARNING* BIS FUNCTION RIPOFF - Taken from fn_fnc_returnVehicleTurrets and shortened a bit
_fnc_returnVehicleTurrets = {

private ["_entry","_turrets","_turretIndex","_i"];

_entry = _this select 0;
_turrets = [];
_turretIndex = 0;

//Explore all turrets and sub-turrets recursively.
for "_i" from 0 to ((count _entry) - 1) do {
	private ["_subEntry"];
	_subEntry = _entry select _i;
	if (isClass _subEntry) then {
		private ["_hasGunner"];
		_hasGunner = [_subEntry, "hasGunner"] call _fnc_returnConfigEntry;
		//Make sure the entry was found.
		if (!(isNil "_hasGunner")) then {
			if (_hasGunner == 1) then {
				_turrets = _turrets + [_turretIndex];
				//Include sub-turrets, if present.
				if (isClass (_subEntry >> "Turrets")) then { _turrets = _turrets + [[_subEntry >> "Turrets"] call _fnc_returnVehicleTurrets]; }
				else { _turrets = _turrets + [[]]; };
			};
		};
		_turretIndex = _turretIndex + 1;
	};
	sleep 0.01;
};
_turrets;
};

The call is:-

_turrets = [configFile >> "CfgVehicles" >> [b]_vehicle[/b] >> "turrets"] call _fnc_returnVehicleTurrets;

As I said.... I hope it is of some help.

Share this post


Link to post
Share on other sites

Oh man, this is embarrassing. Since the default variant doesn't output anything to something we can actually see (it uses unavailable to consumers debuglog rather than diag_log), I copied the function into own mission. But I missed adding the functions module. I would really like to see error messages when doing calls that aren't defined, in this case

_hasGunner = [_subEntry, "hasGunner"] call BIS_fnc_returnConfigEntry;

wasn't defined (due no functions module added).

I want my hair back... Anyways, problem solved.

Edit: Ninja'd, but thanks anyway. Will have a look at it.

Share this post


Link to post
Share on other sites

Oooops... was too slow in my reply.

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
Sign in to follow this  

×