Jump to content
Sign in to follow this  
maruk

Arma 2 Forward Compatibility

Recommended Posts

ArmA 2 will be laregerly compatible with Armed Assault. To make porting of content from ArmA as simple as possible.

Currently, one of the most important things is:

* using of undefined variable in scripts (nil value) will be in ArmA 2 strictly reported as an error. All variables used in any scripts must be initialized before first use.

Reference: community.bistudio.com

Share this post


Link to post
Share on other sites

Nice to hear that means as the continuity is guarented and many mods team will stay loyal for this game. notworthy.gif

Share this post


Link to post
Share on other sites

Out of curiosity, Is using testing isNil against a variable to determine if it exists or not still fair game? I would assume that it is, but it's better to ask.

Share this post


Link to post
Share on other sites

Well, as this is the single thing that most often causes me bugs, specifically by mistyping a variable name and it just defaulting to nil, I'm really happy to have this appear in SQF, even if I have to wait for ArmA II. Many thanks!

Any chance of getting this patched into ArmA, where use of a keyword in a script turned ON this functionality? This was how it was done in Perl: if "use strict" was in a script then Perl would raise an error on an unrecognised variable, the default behaviour would be to just assume that it was nil (or the equivalent in Perl). OK, not seriously expecting you to do this, but it would be great if you could.

A question for clarification: If you private a variable, but don't assign to it, does it default to nil or would dereferencing such a variable also be an error?

Share this post


Link to post
Share on other sites
Out of curiosity, Is using testing isNil against a variable to determine if it exists or not still fair game? *I would assume that it is, but it's better to ask.
Yeah, it is a little confusing. I'm assuming he means that commands that try and reference undeclared variables will now return an error, rather than returning the the variable type the command expected.

For example:

_IsAlive=Alive NOSUCHOBJECT;

Hint Format ["Is Alive %1",_IsAlive];

At the moment the above code would not return an error and the hint would display the value bool.

Edited by W0lle

Share this post


Link to post
Share on other sites
ArmA 2 will be laregerly compatible with Armed Assault.

This is very reassuring - I'd been wondering whether the effort I've been putting into scripting lately was going to be wasted but this says otherwise.

Edited by W0lle

Share this post


Link to post
Share on other sites

on behalf of the community i must say thank you Maruk. was wondering when the compatibility with arma2 discussions would come up.

Share this post


Link to post
Share on other sites

Very good news! Thank you Team! smile_o.gif

So all the work made or still to be made or even in development can be used in ARMA2.

Go Team! wink_o.gif

Share this post


Link to post
Share on other sites

Thanks for the heads-up, however, I'm not sure exactly what the definition of "initialized" is here.

Will there be new scripting commands to declare/initialize a variable?

Or do you just have to store a value in a variable first, as in _variable = 1?

I would assume the latter, but I just want to be 100% sure I understand.

Share this post


Link to post
Share on other sites

Private declares a variable, although there is no matching declaration for public variables.

Edit:

Although this is perfectly valid in arma:

MyGlobalVariable = nil;

I would also like clarification on what BIS is considering initalised however.

Edited by W0lle

Share this post


Link to post
Share on other sites

I would think that you would have to give the variable a value before it can be used in any operation.

--Ben

Share this post


Link to post
Share on other sites

I second the good news here!  Figured as much but nice to know for sure that all the effort we are putting into learning Arma I won't be wasted.  Thanks  smile_o.gif

Share this post


Link to post
Share on other sites
* using of undefined variable in scripts (nil value) will be in ArmA 2 strictly reported as an error.

Excellent. So the parser reports an error if a variable has a value of NIL when being used in a statement. That means that this tedious search for variable typos in long scripts will be history :smile_o:

Like "_startxposition" vs "_starxposition" and the ususal typos, especially in longer or complex scripts.

Thanks,

VictorFarbau

Edited by W0lle

Share this post


Link to post
Share on other sites

So lets say I have the following code:

call compile format["%1Status = east", _varTarget];

_varTarget could be any number of targets and the variable beings stored doesn't exist before this moment. Does this count as initialization for that variable variable?

Edited by W0lle

Share this post


Link to post
Share on other sites

I don't think so. I always declare them before I do that.

--Ben

Edit: I believe that is a valid declaration.

Share this post


Link to post
Share on other sites
So lets say I have the following code:

call compile format["%1Status = east", _varTarget];

_varTarget could be any number of targets and the variable beings stored doesn't exist before this moment. Does this count as initialization for that variable variable?

Looks fine to me as long as _varTarget is defined. Let's say it is set to "foo".

Format creates the string "foo1Status=east".

Compile turns that into a command:-

foo1Status=east

Call runs the command so you are effectively creating a new initialised variable.

Edited by W0lle

Share this post


Link to post
Share on other sites
Although this is perfectly valid in arma:

Code Sample

MyGlobalVariable = nil;

I don't think that is a declaration - very much the reverse! Note the following is not based on any knowledge of ArmA internals but from experience with analoguous interpreted systems. It's possible BIS have a different implementation but I would be surprised if so...

The best way to think of 'definedness' of variables is to consider that they live in a database(1) where entries consist of name/value pairs.

When you create a new variable with "myVar=1" you are actually creating an entry in the database where the 'name' field is set to "myVar" and the 'value' field is set to 1. (There is probably a 'type' field in ArmA but this is irrelevant to this discussion.)

When you subsequently run "myVar=2", the existing entry is updated with a new value field.

Assigning a 'value' of 'nil' to a variable can be used to remove an entry from the database. Note that 'nil' is not really a value at all, it is simply a convenient syntax. So you should really think of "myVar=nil" as "Undefine myVar". Similarly the 'isNil' command is best thought of as a test to see if an entry for that variable exists in the database.

Another point, in contrast to 'nil', which means that a variable doesn't even exist, 'null' is a valid value and just means that the thing to which the variable refers doesn't exist.

So, I would expect the following behaviour...

//Define a variable
myVar=1;
//Now delete it again
myVar=nil;

//Testing for existence can be done with 'isnil'
if (isNil "myVar") then {
 hint "no variable called myVar exists";}

//This should throw an error in Arma2 since we've just
//deleted the variable
hint format ["myvar is %1",myVar];

The 'private' command is interesting since it implies that it is creating uninitialised variables. When I get some time on my gaming PC I'll have a quick check to see if those variables are created with a null value.

(1) Of course, 'database' is a loose term here - it is usually a table/linked-list/hash/binary-tree or other simple structure.

Edited by W0lle

Share this post


Link to post
Share on other sites

There was some suggestion somewhere that SQF format scripting is the way forward.

Will ArmA 2 support SQS and SQF, or SQF only?

Share this post


Link to post
Share on other sites

I belive ArmA 2 will support like ArmA 1 bouth .sqs and .sqf there is no reason why BIS should drop .sqs

Share this post


Link to post
Share on other sites

Hi

_func = 
{
  _return = nil;
  _return
};

_var = [] call _func;

if !(isNil "_var") then
{
...................
};

this gives error?

Edited by W0lle

Share this post


Link to post
Share on other sites

Sqf is imho indeed the way forward.

It's structure is imho a lot better compared to sqs and the possibilities to precompile and call or spawn later is a huge plus also.

I also believe in unification and generalization of code, so imho all should be coded in 1 language and not multiple. As SQF has it's advantages over SQS I drop SQS as a whole personally.

I believe sqs will still be supported in ArmA2, but why would you use it is my question smile_o.gif

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  

×