Skip to content

Commit

Permalink
Update ports-and-triggers.md
Browse files Browse the repository at this point in the history
  • Loading branch information
TigerHix authored Jun 15, 2024
1 parent e3eca88 commit 5719550
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions docs/scripting/api/ports-and-triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,14 @@ Here are a few more examples:
- **Enum Input:** (Shown as a dropdown in the editor)
```csharp
public enum Color {
[Label("RED!!!")]
Red,
[Label("GREEN!!!")]
Green,
[Label("BLUE!!!")]
Blue
}

[DataInput]
public Color MyColor = Color.Red;
```
Note you can add labels to enum values using the `[Label(string label)]` attribute.
- **Array Input:** (Shown as an editable list in the editor)
```csharp
[DataInput]
Expand Down Expand Up @@ -259,7 +255,7 @@ protected bool FilterCharacterAsset(CharacterAsset character) {
Let's say you have an entity. There are two ways to read its data inputs:

1. Access the data input field directly. For example, if you have a node with a _public_ data input field `public int MyNumber = 42;`, you can read the value of `MyNumber` directly by using `node.MyNumber`.
2. Use the `T GetDataInput<T>(string key)` or `object GetDataInput(string key)` method. This method is available in all entities and returns the value of the data input with the specified name. For example, if you have a node with a data input named `MyNumber`, you can read the value of `MyNumber` by using `node.GetDataInput<int>("MyNumber")` (or `node.GetDataInput(nameof(node.MyNumber))` which is stylistically preferred).
2. Use the `T GetDataInput<T>(string key)` or `object GetDataInput(string key)` method. This method is available in all entities and returns the value of the data input with the specified name. For example, if you have a node with a data input named `MyNumber`, you can read the value of `MyNumber` by using `node.GetDataInput<int>("MyNumber")` (or `node.GetDataInput<int>(nameof(node.MyNumber))` which is stylistically preferred).

:::tip
The key of a port is always the name of the field, unless the port is dynamically added (see [Dynamic Ports](#dynamic-ports))
Expand Down Expand Up @@ -371,10 +367,6 @@ public async void ShowConfirmationDialog() {
}
```

:::info
A list of available operations in the `Service` class can be found in [Common Operations](operations#service).
:::

### Invoking Triggers Programmatically

Similar to [accessing data inputs](#accessing-data-inputs), you can invoke triggers programmatically by calling the method directly or using the `void InvokeTrigger(string key)` method on the entity. For example, to invoke a trigger named `ShowPopupMessage`, you can use `entity.ShowPopupMessage()` or `entity.InvokeTrigger("ShowPopupMessage")`.
Expand Down

0 comments on commit 5719550

Please sign in to comment.