addAction: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 17: Line 17:
Action ID should be returned, but due to bug it is not.<br>
Action ID should be returned, but due to bug it is not.<br>
To determine action ID use following algorithm:<br>
To determine action ID use following algorithm:<br>
First action added to given vehicle has ID zero, next has ID 1, etc.  
First action added to given vehicle has ID zero, next has ID 1, etc.
 
 
It seems that since 1.85+(?) '''addAction''' has correctly returned action ID.
 
Params passed by an action to the executed script:
 
'''[(object action was attached to), (unit that activated action), (index of action)]'''
 
 
So an example of an action-based script goes like this:
 
'''_obj = _this select 0'''
 
'''_man = _this select 1'''
 
'''_index = _this select 2'''
 
 
If you want to remove the action from the object immediately after it's triggered, use this line along with the above:
 
_obj '''''removeAction''''' _index
 
 
An easy way to keep track of and remove actions is to set the ID of the action yourself.
 
This can be accomplished by doing the following:
 
myaction = player '''addAction''' ["Hello", "hello.sqs"]
 
This sets the actions ID to "myaction".
 
This can make keeping track actions much easier.
 
To remove the above action, you would use the following line:
 
player '''''removeAction''''' myaction
 


'''Example:'''
'''Example:'''


player '''addAction''' ["Hello", "hello.sqs"]
player '''addAction''' ["Hello", "hello.sqs"]

Revision as of 13:16, 15 April 2006

back to COMREF

unit addaction action

Operand types:

unit: Object
action: Array

Type of returned value:

Nothing

Description:

Create an action.
Action ID should be returned, but due to bug it is not.
To determine action ID use following algorithm:
First action added to given vehicle has ID zero, next has ID 1, etc.


It seems that since 1.85+(?) addAction has correctly returned action ID.

Params passed by an action to the executed script:

[(object action was attached to), (unit that activated action), (index of action)]


So an example of an action-based script goes like this:

_obj = _this select 0

_man = _this select 1

_index = _this select 2


If you want to remove the action from the object immediately after it's triggered, use this line along with the above:

_obj removeAction _index


An easy way to keep track of and remove actions is to set the ID of the action yourself.

This can be accomplished by doing the following:

myaction = player addAction ["Hello", "hello.sqs"]

This sets the actions ID to "myaction".

This can make keeping track actions much easier.

To remove the above action, you would use the following line:

player removeAction myaction


Example:

player addAction ["Hello", "hello.sqs"]