# Command Action and Data

### CommandAction Enum

Specifies a command action.

### Syntax

\[Sansar.Script.Interface]\
\[System.Flags]\
public enum **CommandAction**

### Remarks

### Members

| Member Name  | Description                         |
| ------------ | ----------------------------------- |
| **All**      | A combination of all other values.  |
| **Invalid**  | An invalid command action.          |
| **Pressed**  | Fired when the command is pressed.  |
| **Released** | Fired when the command is released. |

### Requirements

**Namespace:** Sansar.Simulation\
**Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
**Assembly Versions:** 1.1.0.0

***

### CommandData

### CommandData Class

Command events are generated by the client when input events occur.

### Syntax

### Remarks

| Command            | Default Key Binding   |
| ------------------ | --------------------- |
| Trigger            | Left Mouse Button     |
| PrimaryAction      | F                     |
| SecondaryAction    | R                     |
| Modifier           | Shift                 |
| Action1 to Action0 | Number keys 1 to 0    |
| Confirm            | Enter                 |
| Cancel             | Escape                |
| SelectLeft         | Left arrow            |
| SelectRight        | Right arrow           |
| SelectUp           | Up arrow              |
| SelectDown         | Down arrow            |
| Keypad0 to Keypad9 | Numberpad keys 0 to 9 |
| KeypadEnter        | Numberpad Enter       |

An example script for handling client commands:

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><strong>C# Example</strong></td></tr><tr><td><pre><code>/* This content is licensed under the terms of the Creative Commons Attribution 4.0 International License.
</code></pre></td></tr></tbody></table>

* When using this content, you must:
* � Acknowledge that the content is from the Sansar Knowledge Base.
* � Include our copyright notice: "� 2017 Linden Research, Inc."
* � Indicate that the content is licensed under the Creative Commons Attribution-Share Alike 4.0 International License.
* � Include the URL for, or link to, the license summary at <https://creativecommons.org/licenses/by-sa/4.0/deed.hi> (and, if possible, to the complete license terms at <https://creativecommons.org/licenses/by-sa/4.0/legalcode>.
* For example:
* "This work uses content from the Sansar Knowledge Base. � 2017 Linden Research, Inc. Licensed under the Creative Commons Attribution 4.0 International License (license summary available at <https://creativecommons.org/licenses/by/4.0/> and complete license terms available at <https://creativecommons.org/licenses/by/4.0/legalcode>)." \*/ using Sansar.Script; using Sansar.Simulation; public class CommandExample : SceneObjectScript { #region ScriptParameters \[Tooltip(@"The command to enable listening for the Action Command. Default: Confirm (Enter)")] \[DefaultValue("Confirm")] \[DisplayName("Subscribe Command")] public readonly string SubscribeCommand; \[Tooltip(@"The command to disable listening for the Action Command. Default: Cancel (Escape)")]\[DefaultValue("Cancel")]\[DisplayName("Unsubscribe Command")]public readonly string UnsubscribeCommand;\[Tooltip(@"If the command has been subscribed to by the 'Subscribe Command', this will log the action to the script console.")]\[DefaultValue("Trigger")]\[DisplayName("Action Command")]public readonly string ActionCommand;#endregion ScriptParameterspublic override void Init(){// Subscribe to new user events;ScenePrivate.User.Subscribe(User.AddUser, NewUser);}IEventSubscription subscription = null;void NewUser(UserData newUser){ Client client = ScenePrivate.FindAgent(newUser.User).Client; // CommandReceived will be called every time the command it triggered on the client // CommandCanceled will be called if the subscription fails if (SubscribeCommand != "") { client.SubscribeToCommand(SubscribeCommand, CommandAction.Pressed, (data) =\&gt; { if (subscription == null) { Log.Write(GetType().Name, $"\[{SubscribeCommand}] Subscribing to {ActionCommand}."); subscription = client.SubscribeToCommand(ActionCommand, CommandAction.All, CommandReceived, CommandCanceled); } }, CommandCanceled); } if (UnsubscribeCommand != "") { client.SubscribeToCommand(UnsubscribeCommand, CommandAction.Pressed, (data) =\&gt; { if (subscription != null) { Log.Write(GetType().Name, $"\[{UnsubscribeCommand}] Unsubscribing to {ActionCommand}."); subscription.Unsubscribe(); subscription = null; } }, CommandCanceled); }}void CommandReceived(CommandData command){ Log.Write(GetType().Name, $"Received command {command.Command}: {command.Action}. Targeting Info: {command.TargetingComponent}, Origin:{command.TargetingOrigin}, Position:{command.TargetingPosition}, Normal{command.TargetingNormal}");}void CommandCanceled(CancelData data){ Log.Write(GetType().Name, "Subscription canceled: "+data.Message);} } |

### Requirements

**Namespace:** Sansar.Simulation\
**Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
**Assembly Versions:** 1.1.0.0

### Members

### Member Details

#### Action Property

> The action which occurred.
>
> #### Syntax
>
> \[get: Sansar.Script.Interface]\
> public [CommandAction](https://help.sansar.com/hc/en-us/articles/115005722283) **Action** { get; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### CameraControlMode Property

> #### Syntax
>
> \[get: Sansar.Script.Interface]\
> public [CameraControlMode](https://help.sansar.com/hc/en-us/articles/360020528532) **CameraControlMode** { get; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### Command Property

> The command which occurred.
>
> #### Syntax
>
> \[get: Sansar.Script.Interface]\
> public [string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) **Command** { get; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### ControlPoint Property

> #### Syntax
>
> \[get: Sansar.Script.Interface]\
> public [ControlPointType](https://help.sansar.com/hc/en-us/articles/115004507483) **ControlPoint** { get; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### MouseLookMode Property

> #### Syntax
>
> \[get: Sansar.Script.Interface]\
> public [bool](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean) **MouseLookMode** { get; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### SessionId Property

> The client which generated the event.
>
> #### Syntax
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### SimulationFrame Property

> #### Syntax
>
> \[get: Sansar.Script.Interface]\
> public [ulong](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.UInt64) **SimulationFrame** { get; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### TargetingComponent Property

> #### Syntax
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### TargetingNormal Property

> #### Syntax
>
> \[get: Sansar.Script.Interface]\
> public [Sansar.Vector](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/vector) **TargetingNormal** { get; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### TargetingOrigin Property

> #### Syntax
>
> \[get: Sansar.Script.Interface]\
> public [Sansar.Vector](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/vector) **TargetingOrigin** { get; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### TargetingPosition Property

> #### Syntax
>
> \[get: Sansar.Script.Interface]\
> public [Sansar.Vector](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/vector) **TargetingPosition** { get; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

#### ToString Method

> A string representation of this object.
>
> #### Syntax
>
> \[Sansar.Script.Interface]\
> public override [string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) **ToString** ()
>
> **Returns**
>
> > A string representation of this object.
>
> #### Remarks
>
> The format of this string may change between releases.
>
> #### Requirements
>
> **Namespace:** Sansar.Simulation\
> **Assembly:** Sansar.Simulation (in Sansar.Simulation.dll)\
> **Assembly Versions:** 1.1.0.0
>
> ***

***
