Jump to content
  • 0

_this.


kat

Question

I understand that '_this' can work for this as a local variable :

 

_myVariable =

{

_mVa = _this select 0;

_mVb = _this select 1;

_mVc = _this select 2;

 

_total = _mVa + _mVb - _mVc;

};

 

[1,2,3] call _hinting;

 

hint format ["Example Total: %1",_total];

 

Then i see things like this:

_body = (_this select 3) select 0;

 

Can someone give some detailed advanced examples where "_this" is used?

 

Also is _this strictly local?

 

Thank youuuu!

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

_this same as _x are so called "magic variables", they can not be used by normal means like a local var.

xBowBii gives a good example on how _this variable can be used to access called arguments from external scripts in your function.

 

Here's a little extra on how to create new variables using same functions (can be complex nested arrays, too).

_weLikeDat = ["Damn", "Nice", "Booty"] call fnc_checkDatBooty; //create new variable created from args returned from function

fnc_checkDatBooty = { //this is the function we just called, probably defined in some other files somewhere else.
_booty = _this select 2; // select only variable we want

_booty //return booty
};

//_weLikeDat variable will now become a string with "booty" in it.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...