It took me ages to get the hang of the whole "_this" thing. This is not a syntax or code question at heart: it's a concept. Needless to say it has nothing in particular to do with addAction, but we'll come on to how it applies to addAction in a minute.
Every time a script starts, an array is created. The array is local to the script, so its name starts with an underscore. The name of the array is _this.
When some scripts start, the array _this is empty.
Sometimes, _this has a bunch of stuff in it. You know you sometimes call a script like this?
[loon1, bmp1] exec "whatever.sqs"
Well the stuff in the square brackets gets put into _this when the script starts.
STOP! Go back and read all that again. Happy so far? Good.
Now, to pick an element out of an array and do something to it, you need the command select. Arrays start numbering their elements at 0, rather than 1, so the first element has the index 0.
Let's say your script whatever.sqs is going to do something to loon1. You want to assign a local variable within the script that refers to loon1. Here's how you do it:
_victim = _this select 0
The local variable _victim now refers to the first element (numbered 0, if you recall) of the array _this. We know that _this is the stuff that was sent to the script, ([loon1, BMP1]) and that the first element was loon1, so _victim now refers to loon1.
STOP! Read through all that again. I hope it makes sense. Look up the command select in the comref.
That's all well and good, you say, but what's this got to do with addAction? Well, addAction is a jolly clever little command. Or rather, the people who designed the code are jolly clever and this same trick turns up all over the place in OFP code.
When you start a script by using an action, the script starts as usual. Fine. Does this script have an array _this like other scripts? Yes it does.
Ah-ha, but how can it, when there were no square brackets [] anywhere? How can _this not be empty when we haven't passed anything into the script? Well here's the clever bit. A whole bunch of useful stuff is passed automatically into _this. The useful stuff in the case of a script called from an Action is
- the object to which the action is attached (in other words, the object that had the original addAction command)
- the dude that did the action (usually the player but not always)
- the index of the action (an object can have more than one action added to it: each action added gets an index number)
So we've got some shorthand here. The addAction command really works a bit like this, but the bits in blue don't appear - they are automatic.
radio1 addAction ["Switch on radio", "[the object to which the action is attached, the loon that did the action, action ID] exec radio.sqs"]
STOP! I guess you know by now what to do when I shout stop ....
When the action is done the script starts and the array _this is created with the relevant information in it. _this has the three elements mentioned above, in that order. (Remember that the first thing is always numbered 0 rather than 1.) In other words, in our script the following line has happened. It's automatic and invisible, so you don't see it happen and you don't write it down.
_this = [object to which action was attached, dude who did action, action ID]
So now we come to General Barron's mysterious command:-
(_this select 0) removeaction (_this select 2)
Which, as you can now figure out, translates as:-
(object to which action was attached) removeAction (action ID)
The reason you had trouble understanding all this is that it has very little to do with addAction. In fact a really good addAction tutorial would cover virtually none of what I've just written. Firstly you need to understand about arrays, and then about how scripts are called. Once you understand that, the way it applies to addAction is obvious.
I hope this has cleared things up a little. If any of this is unclear, ask again. It's one of these things that is utterly incomprehensible the first three times you read it, then two days later on the bus you suddenly think "duh-oh, that's so obvious".