AddCommand
Objects
Commands
1.0 OC
bool
string
command
Command name (as string). See the table below.
object
target
target object for the command
int
x
X target coordinate
int
y
Y target coordinate
object
target2
secondary target object
int
delay
Time (in ticks or frames) until the command is automatically aborted. Execution will continue with the next command in the stack.
any
Data
additional data for the command
int
retries
Number of retries if the command fails, until the command fails completely.
int
base_mode
Determines the behaviour if the command fails.
base_mode
Name
Description
Failure messages and CallFailed calls
Next command
0
C4CMD_SilentSub
Silent command
Only if this is the last command
Fails
3
C4CMD_Sub
Command
If the next command has no retries left or this is the last command.
Fails
2
C4CMD_SilentBase
Silent base command
Never
Does not fail
1
C4CMD_Base
Base command
Always
Does not fail
Adds a command to the top of the command stack of an object (also see AppendCommand). This command will be executed first, then the object will continue with the existing commands. If the command stack is empty, AddCommand does the same as SetCommand.
For the list of commands see SetCommand.
Commands added using AddCommand are not passed to controlled vehicles (see VehicleControl).
var obj = FindObject(Find_InRect(-20, -40, 40, 40), Find_OCF(OCF_CrewMember));
if(obj)
if(obj->GetComDir() == COMD_Right)
obj->AddCommand("Jump");
return;
If called from an object on the ground, this timer script makes any clonk passing the object from left to right jump. To do this, crew member objects are searched above the object. If one is found and he is moving from left to right (ComDir), he is given a 'Jump' command. Notice that this does not affect the previously set commands of the clonk - after completing the jump command, the clonk will continue with his previous commands. Using this script, you could e.g. ensure that clonks will always jump a given gap in the landscape.
SetCommand
GetCommand
AppendCommand
FinishCommand
PeterW2001-11
Günther2005-01