Probably something pretty easy again but i don't get the way to solve this.
Ok, base settings:
I have an array which contains sub-arrays which are filled with classnames. Below an simplified example:
acep2_complete_class_array = [["SoldierMB","SoldierMMG"], ["SoldierPB","SoldierPTeamLeader"]];
Ok, the real array is much bigger but thats the only difference to this example.
Now as these arrays should only contain valid classnames, i try to remove anything that isn't a classname. This also includes variables booleans, other array or whatever doesn't fit in there. I want to do this to catch invalid entries before they may cause serious script failure and also this script is meant to be edited by user.
So i try to catch up all invalid types inside these arrays and delete them.
This works as long it is a STRING. In this case the isclass check works well and discards any classnames that aren't actually loaded classes (from addons).
But as soon the invalid classname isn't a string, my check fails. I tried with this array to find a working solution:
acep2_complete_class_array = [["SoldierMB","SoldierMMG"], ["SoldierPB","SoldierPTeamLeader", idiot]];
Now idiot is obviously not a classname (or might be but it isn't a string). What i have by now, based on the above array structur is this piece of code:
{
{
if (typename _x != "STRING") then {
ACEP2_DEBUG_INVALID_CLASSES = ACEP2_DEBUG_INVALID_CLASSES + [_x];
ACEP2_DEBUG_NON_FATAL_ERROR = ACEP2_DEBUG_NON_FATAL_ERROR + 1;
_acep2_get_invalid_pos = _acep2_array_to_check find _x;
_acep2_array_to_check set [_acep2_get_invalid_pos, nil];
_acep2_array_to_check resize ((count _acep2_array_to_check) - 1);
};
} foreach _x;
} foreach acep2_complete_class_array;
{
{
if (! isclass (configFile >> "CfgVehicles" >> _x)) then {
ACEP2_DEBUG_INVALID_CLASSES = ACEP2_DEBUG_INVALID_CLASSES + [_x];
ACEP2_DEBUG_NON_FATAL_ERROR = ACEP2_DEBUG_NON_FATAL_ERROR + 1;
_acep2_get_invalid_pos = _acep2_array_to_check find _x;
_acep2_array_to_check set [_acep2_get_invalid_pos, nil];
_acep2_array_to_check resize ((count _acep2_array_to_check) - 1);
};
} foreach _x;
} foreach acep2_complete_class_array;
The all-uppercase variables/arrays are for debugging use for the missionmaker to find errors faster as i show a hint if any errors come up and for the functionality they haven't anything to do with. Although i use ACEP2_DEBUG_INVALID_CLASSES as hint to see if the invalid entry was detected or not, as it would show up in there if it is detected. But so far no luck, this array remains empty.
Also by now there are 2 separate codeblocks as it is easier to get it working. Once it works as expected i will put those codes together but this is a sidenote yet.
So what am i doing wrong to get this entry out of the array? How do i get rid of this idiot (putting a Dollar in the PUN box)?
Oh, i also already tried the most easiest possible way:
_acep2_array_to_check = _acep2_array_to_check - [_x];
This also didn't worked at all.
And for completeness, ArmA doesn't throw an error on these lines, it just doesn't work as i want it to do.
Any help much appreciated.
Myke out