Jump to content
Sign in to follow this  
Bulldog72

Best way to check if a parameter is a variable or an array

Recommended Posts

Please consider this:

FUNC_f = {
 _param = _this select 0;
...
};

FUNC_f may be called with an unit or a position (array) as its parameter - how do I find out what _param is?

I would need something like this here:

...
if (_param isKindOf "AllVehicles") then {
	_splashPos = getPos _param;		
} else {
	//assume _param already is a [position]
	_splashPos = _param;
};
...

It does not work like this and throws me a runtime error because isKindOf cant deal if "_param" actually is an array.

But I need something similar... anybody got a better idea for me?

Edited by Bulldog72

Share this post


Link to post
Share on other sites

Use typeName. Example:

...
   if (typeName _param == "ARRAY") then {
   .......
   };
....
//Alternative for the same
   if (typeName _param == typeName []) {
   .....
};

Ofc. you could do it on the object instead:

.....
   if (typeName _param == "OBJECT") then {...
       ....

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  

×