Jump to content
Sign in to follow this  
davidoss

type target

Recommended Posts

I have a function that returns <NULL-target> if the player  was targeting nothing while calling it

I am trying to catch that and exit when <NULL-target> has been returned.

if (isnull _toevac ) exitWith {}; //error
if (isnil _toevac ) exitWith {}; //error
if (_toevac  == objNull ) exitWith {}; // error type target

str _toevac // <NULL-target>

how to bite this?

Share this post


Link to post
Share on other sites

What's _toevac? Cursortarget?

If it's cursortarget then a simple

isNull cursorTarget

should do it. No idea why or what's throwing error on your side.

 

when _toevac is actually returning objNull then

_toevac  == objNull

will return false. Use isEqualTo instead.

isNil wants string or code btw.

Hard to say without more context.

 

Cheers

Share this post


Link to post
Share on other sites

I have a function that returns <NULL-target> if the player  was targeting nothing while calling it

I am trying to catch that and exit when <NULL-target> has been returned.

if (isnull _toevac ) exitWith {}; //error
if (isnil _toevac ) exitWith {}; //error
if (_toevac  == objNull ) exitWith {}; // error type target

str _toevac // <NULL-target>

how to bite this?

isNil accepts only strings, so it'd be

if (isnil "_toevac") exitWith {};

Share this post


Link to post
Share on other sites

This bug should be fixed since 1.65.138622 The type returned should now be Object and not Target. Check tomorrow DEV please.

  • Like 1

Share this post


Link to post
Share on other sites

Additionally to what KK's says, if the return was nil you would have error, not only because of the brackets, but also because you are checking null before nil.

 

Correct code should be:

if (isnil "_toevac" ) exitWith {};

if (isnull _toevac ) exitWith {};

 

Also this: if (_toevac  == objNull ) exitWith {}; will return allways false, as objNull never equals to anything, to check if something is null, it's isNull command.

Share this post


Link to post
Share on other sites

Also this: if (_toevac  == objNull ) exitWith {}; will return allways false, as objNull never equals to anything, to check if something is null, it's isNull command.

 

 

True, but this would work:

if (_toevac isEqualTo objNull) exitWith {}; 

Share this post


Link to post
Share on other sites

There is going about something different that just syntax.

Type target but the type target are non existing yet in arma

if (isNull _toevac ) exitWith {hint "exited">
 1:46:40   Error position: <isNull _toevac ) exitWith {hint "exited">
 1:46:40   Error isnull: Type Target, expected Object,Group,Script,Config entry,Display (dialog),Control,Network Object,Task,Location

https://community.bi...om/wiki/Target says
 

 

 

This is a reserved Type for future implementations. In Armed Assault it is not implemented yet

Share this post


Link to post
Share on other sites

Don't underestimate syntax.

If you know what value it has exactly, then you could use isEqualTo to check it even when isNull doesn't work. (maybe TargetNull already exists?)

If that is too tricky, then you could always try comparing it as string.

Share this post


Link to post
Share on other sites

Value can be object or <NULL-target>.

With object there are no problem but if this return <NULL-target> i cant or do not knew how to detect that.

Share this post


Link to post
Share on other sites

This might be just me not realizing what you're after, but i can detect "Nothing" without errors

_target = cursorTarget ; if (isNull _target ) exitWith {hint "Nothing"};

Share this post


Link to post
Share on other sites

yeah when that would be objnull not <NULL-target>

Error isnull: Type Target, expected Object,Group,Script,Config entry,Display (dialog),Control,Network Object,Task,Location

Share this post


Link to post
Share on other sites

Note: A test via == does not work, because, for example, objNull is not equal to anything, not even to itself. Use isEqualTo.

 

I would advise to do whatever you're doing differently if you cannot find a correct solution from what you have. Good luck

Share this post


Link to post
Share on other sites

It seems no one really is bothered reading through the thread but everyone quick to give advice. Ok, I will give you digest version:

PROBLEM SOLVED, "expression" now gets Object type as _target. It is currently fixed on DEV, so If you are on STABLE will have to wait.

 

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  

×