Jump to content
Sign in to follow this  
Skelt

nul = []...execVM vs. just execVM in init.sqf

Recommended Posts

null = []...execVM
nul = []...execVM
nul0 = []..execVM

I've seen all sorts of different script calls from the init.sqf why not just run it with:

execVM "scripts.sqf";

(this only applies to scripts which does not require an array) Otherwise I can understand. Besides for that, when you do null = arn't you assigning null a value?

Share this post


Link to post
Share on other sites

ayeee,

I'm a bit obsessive compulsive about the way things look, is there anything wrong with just running them flat out:

execVM from the line?

Share this post


Link to post
Share on other sites

You can start your scripts with execVM "bla.sqf"; if you like... if you need to wait until a script is finished you can use nul=execVM "bla.sqf"; and then waitUntil{scriptDone nul};.

:)

Share this post


Link to post
Share on other sites

This nul = ... stuff is probably result of not understanding the language and it's environment properly or copy-paste syndrome. Almost all expressions in the editor cannot result in anything else than "Nothing" (one exception is the condition field of a trigger).

[] execVM "script.sqf" - the result of this is a handle to the script.

_nul = [] execVM "script.sqf" - the result of this is Nothing and is therefore valid in the editor.

null is a free variable in arma scripting unlike other languages. You might be thinking of objNull, grpNull and some others: http://community.bistudio.com/wiki/objNull. Don't change 'nil'.

Guess you don't have to pass an argument to execVM, but I would recommend always doing it for call's since if you omit the argument it called function will be able to access the 'this' of the calling function which can cause problems.

Share this post


Link to post
Share on other sites

had to read your post twice Muzz. ObjNull is kinda like dividing by zero then eh. Not equal to anything, not even itself.. kind of dumbfounding isn't it?

Thanks for the replies*

Share this post


Link to post
Share on other sites

Scripts executed in triggers and init lines require a script handle because the editor won't let you do it otherwise for some reason. But I don't get the whole "nul" thing, especially outside the editor. It's just a variable that has no special function. Numbers can't be reassigned in the engine, so 0= does the same thing.

Edited by Celery

Share this post


Link to post
Share on other sites

I have always used "null" because for execVM and the like so on quick glance I know this is a variable (usually a script handle) that I am not expecting to use/need. I just use it to stay consistent so when I see anything other than null I know it has a purpose.

Share this post


Link to post
Share on other sites

Non used variable is usually considered (in various coding convensions) as maybe not bug but something wrong. And this null = [] execVM thing is nothing more than unused variable

Share this post


Link to post
Share on other sites

Thanks again.

Edited by Skelt

Share this post


Link to post
Share on other sites

Yes, just don't assign it into a variable unless you actually need to for one reason or another.

Share this post


Link to post
Share on other sites

ah* thank you, didn't hear back from anyone for a little so figured I'd close the post without bumping it. Since I'm going to now anyways, my question I edited out was:

can you pass arguments to scripts without using null=[] which resulted in the response above.

*cheers

Share this post


Link to post
Share on other sites
ah* thank you, didn't hear back from anyone for a little so figured I'd close the post without bumping it. Since I'm going to now anyways, my question I edited out was:

can you pass arguments to scripts without using null=[] which resulted in the response above.

*cheers

You can pass arguments by including them in the brackets. The handle is unnecessary unless you're doing it in the mission editor.

Share this post


Link to post
Share on other sites

Thank you Celery, I'm not a great script writer but I have written a few working scripts from the ground up. As such I've looked at a ton of other people's code and I kept seeing that over and over again null = [] inside of functions and I started changing them because I'm a lil OCD about the way the code looks, which brought this question to light - was there going to be any effect from me changing the way these scripts are called inside of my functions.

-You guys are great. Thanks again.

Share this post


Link to post
Share on other sites

I don't know much about the editor calls, but in a script you can even pass arguments without [].

[] is only needed if you want to pass an array of arguments.

_arg = [1,2,3];

_arg execVM "xy.sqf";

Then, in xy.sqf _this will equal _arg. Thus _this select 0 is _arg select 0, which is 1.

The whole stuff is the same with [1,2,3] execVM "xy.sqf";

Edited by zapat

Share this post


Link to post
Share on other sites

Yeah, I personally run them all as:

[] execVM "script.sqf";

and when they are in triggers or somewhere in mission I use:

0=execVM "script.sqf";

But that's me... :)

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  

×