ActionDoCommand(action)

Inserts a command into the Action Queue.

action ActionDoCommand(
    action aCommand
);

Parameters

aCommand

Void returning function to execute (ignore "action" data type).


Description

Inserts the function call aCommand into the Action Queue. Generally, any function not beginning with ‘Action’ will not be inserted into the queue. Functions called without the use of ActionDoCommand will preempt other previously called functions in the Action Queue and execute immediately.



Remarks

The target of this function is the object making the call. If it's neccessary to command other objects or NPCs then use AssignCommand(). ActionDoCommand() can be nested inside of an AssignCommand() call to add a Command to the targeted objects queue as an Action.
Also note that ActionDoCommand can only accept void returning functions - if you want to use a function that returns a value, you will have to wrap that function in a void returning function call.


Known Bugs

When used in a script during the OnSpawn event, its possible for a creature to assume strange behavior.


Version

1.29

Example

// script without ActionDoCommand()
// in this example the NPC will first speak
// the string "here's my seat", and then
// walk to the chair, and sit.
{
     object oNPC = GetObjectByTag("some_npc");
     object oChair = GetObjectByTag("chair");

     ActionMoveToObject(oChair);
     SpeakString("Here's my seat!");
     ActionSit(oChair);
}

// script with ActionDoCommand()
// in this example the NPC will execute the 
// functions in the order given (as they are in
// the NPCs Action Queue): first walk to the chair,
// then speak the string, and sit down.
{
     object oNPC = GetObjectByTag("some_npc");
     object oChair = GetObjectByTag("chair");

     ActionMoveToObject(oChair);
     ActionDoCommand(SpeakString("Here's my seat!"));
     ActionSit(oChair);
}

See Also

functions: AssignCommand | ClearAllActions
categories: Action on Object Functions


 author: Ryan Hunt, editor: Charles Feduke, additional contributor(s): Jens Eggert, Graziano Lenzi
 Send comments on this topic.