Jump to content

Sign in to follow this  
mr-blizzard

Arma 3 "objects"?

Recommended Posts

Does Arma 3 have "objects" like in JavaScript? If your not sure what im talking about, it is something along the lines of a variable Inside of a variable.

Share this post


Link to post
Share on other sites

Yes it does, however you cannot access object attributes directly, they've all been encapsulated and abstracted. The only way to get the information each field contains is by using the scripting commands available to us.

When you say objects "like JavaScript", I assume you're talking about objects in the context of object-oriented programming. The answer is most undoubtedly yes, because Real Virtuality is also most likely written in an object-oriented programming language (probably C++ like almost every game these days).

For example their solider class might look something like this:

class Soldier_Base
{
public:
	model = //stuff
	name = //stuff
	faction = NULL
	health = 1;
	direction = 0;

	float returnDirection()
	{
		return direction;
	};
	//other fields and functions
}

However, there is no way to access object attributes directly using .sqf (and probably .sqs also). We have to use commands like getDir or direction:

_myDir = direction player;

//equivalent C++ statement (pre-compiled code):

resultToSQF = Soldier_Base.returnDirection();

Notice how we did not access the variable directly, but rather used a function? Using functions to return relevant information rather than accessing attributes directly is called encapsulation.

Edited by DreadedEntity

Share this post


Link to post
Share on other sites
  NeMeSiS said:
https://community.bistudio.com/wiki/setVariable may be close enough to what you are looking for.

Indeed. For example you can use empty logics as your "objects", and then set-/getVariable. But more often than not, it's actually nicer to use already existing objects: groups, units, ... and set-/getVariable on them.

Or just use a hashmap/dictionary (you need to implement that in sqf though...).

Share this post


Link to post
Share on other sites
  DreadedEntity said:

However, there is no way to access object attributes directly using .sqf (and probably .sqs also). We have to use commands like getDir or direction:

_myDir = direction player;

//equivalent C++ statement (pre-compiled

Never really thought about it like that, really do appreciate the feedback guys, thanks.

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  

×