Jump to content

Recommended Posts

I have a bunch of groups, which might or might not have been created so far (depending on the path the player has chosen). At some point I want to delete all groups that have been created so far.

I've tried an isNil check for an array of all groupnames, which works well when all groups have been created. But if any of those groups has not been created, it throws up an undefined variable error.

Different variants I have tried, so far to no avail:

{if (!isNil _x) then {deleteGroup _x}} forEach  [grp1, grp2, grp3]; // Undefined Variable

{if (!isNil "_x") then {deleteGroup _x}} forEach  [grp1, grp2, grp3]; // Undefined Variable

{if (!isNil {_x}) then {deleteGroup _x}} forEach  [grp1, grp2, grp3]; // Undefined Variable

{if (!isNil str (_x)) then {deleteGroup _x}} forEach  [grp1, grp2, grp3]; // Undefined Variable

{if (!isNil _x) then {deleteGroup _x}} forEach  ["grp1", "grp2", "grp3"]; // deleteGroup: Type String, expected Group

Of course I could check each group individually, or add all created groups to an array and use this instead (which I'll probably do anyway).

But I'd like to understand why this variant does not work.

Anyone can enlighten me?^^

Share this post


Link to post
Share on other sites
{
	deleteGroup (missionNamespace getVariable [_x, grpNull]);
} 
forEach  ["grp1", "grp2", "grp3"];

 

Share this post


Link to post
Share on other sites

That did the trick, thanks. Although I don't quite understand what I am doing here.

Is it all about different data types? getVariable using a string as argument, while missionNamespace returning the actual group?

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

×