Home   Help Search Login Register  

Author Topic: _this select 0 etc etc etc  (Read 1196 times)

0 Members and 1 Guest are viewing this topic.

Offline Colonel_Klink

  • Members
  • *
  • Independent Addon Creator
    • DC3D Game Modelling Zone
_this select 0 etc etc etc
« on: 09 Dec 2002, 11:00:59 »
Ok scripting gurus I have a problem.
In a lot of scripts there are values such as _this select 0, _this select 1 etc etc. The problem I am having is finding out how to ascertain what those values are.
Is there  method to uncovering these values, by scripting or some other secret handshake method:)
Cheers
Rebel without a pause...D.I.L.L.I.G.A.F.

CareyBear

  • Guest
Re:_this select 0 etc etc etc
« Reply #1 on: 09 Dec 2002, 13:32:17 »
What the hell is _this?

The object _this varies depending on the context. It is applicable to scripts and eventHandlers.

In a script, the object _this refers to the parameters passed to the script.

eg: [player, "helloworld"] exec "script.sqs"

in this case, the object _this refers to the array - ie:
_this = [player, "helloworld"]

so by standard array referencing:
_this select 0 = player
_this select 1 = "helloworld"

with eventhandlers, _this is a specific array containing predefined information. The "killed" eventHandler _this object, for example, contains the dead unit & the killing unit. The "GETIN" _this object contains the vehicle, the location ("driver", "gunner", "commander" or "cargo") and the unit that boarded.

Actually answering your question:

The simple technique for examining any data you want to know the structure of is to place a line like this in the script (or 'command string' in the case of eventhandlers) which goes like:

hint format ["%1", _this]

In the example above, you'll get a little hint box which reads something like:

[Alpha Black 1(CareyBear), "helloworld"]

Hope that helps.

PS: You cannot refer to a unit by it's universal ID (ie: Alpha Black 1). You have to assign it to a global variable and then refer to the variable.

PPS: for eventhandlers, each eventhandler is different, suggest you try the one you want to use with the hint technique to find out exactly what it returns.

Offline Colonel_Klink

  • Members
  • *
  • Independent Addon Creator
    • DC3D Game Modelling Zone
Re:_this select 0 etc etc etc
« Reply #2 on: 10 Dec 2002, 02:50:17 »
Thanks CareyBear
This should solve all my _this select damnstuff woes :).
BTW the SE5A is ready for you to test. Send me an email and I'll give u the download.
Cheers
Klink
Rebel without a pause...D.I.L.L.I.G.A.F.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:_this select 0 etc etc etc
« Reply #3 on: 10 Dec 2002, 02:58:58 »
@Careybear - great explanation.
@Colonel_Klink - please click the solve button. This is FAQ material.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.