> For the complete documentation index, see [llms.txt](/llms.txt)

# GS2-StateMachine スクリプト トリガー リファレンス

拡張スクリプトを呼び出すイベントトリガーのリファレンス



## トリガー

### start

ステートマシンの開始
**関連するメソッド:**
startStateMachineByUserId - ユーザーIDを指定してステートマシンを開始


#### 同期実行スクリプト

ステートマシンの開始処理の前に、スクリプトが同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| stateMachineMaster | [StateMachineMaster](../sdk/#statemachinemaster) | ステートマシンマスターデータ |
| status | [Status](../sdk/#status) | ステータス |
| userId | string | ユーザーID |
| parameters | string | ステートマシンに渡す引数 |

##### Result

|  | 型 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | 開始を許可するか |

##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local stateMachineMaster = args.stateMachineMaster
local status = args.status
local userId = args.userId
local parameters = args.parameters

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### 非同期実行スクリプト

ステートマシンの開始処理の後に、スクリプトが非同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| stateMachineMaster | [StateMachineMaster](../sdk/#statemachinemaster) | ステートマシンマスターデータ |
| status | [Status](../sdk/#status) | ステータス |
| userId | string | ユーザーID |
| parameters | string | ステートマシンに渡す引数 |


##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local stateMachineMaster = args.stateMachineMaster
local status = args.status
local userId = args.userId
local parameters = args.parameters

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}
```


---
  
### pass

ステートマシンの正常終了
**関連するメソッド:**
emit - ステートマシンにイベントを送信
emitByUserId - ユーザーIDを指定してステートマシンにイベントを送信
report - ステートマシンに複数のイベントを報告
reportByUserId - ユーザーIDを指定してステートマシンに複数のイベントを報告


#### 同期実行スクリプト

ステートマシンの正常終了処理の前に、スクリプトが同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| stateMachineMaster | [StateMachineMaster](../sdk/#statemachinemaster) | ステートマシンマスターデータ |
| status | [Status](../sdk/#status) | ステータス |
| userId | string | ユーザーID |

##### Result

|  | 型 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | ステートマシンの正常終了を許可するか |

##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local stateMachineMaster = args.stateMachineMaster
local status = args.status
local userId = args.userId

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### 非同期実行スクリプト

ステートマシンの正常終了処理の後に、スクリプトが非同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| stateMachineMaster | [StateMachineMaster](../sdk/#statemachinemaster) | ステートマシンマスターデータ |
| status | [Status](../sdk/#status) | ステータス |
| userId | string | ユーザーID |


##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local stateMachineMaster = args.stateMachineMaster
local status = args.status
local userId = args.userId

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}
```


---
  
### error

ステートマシンの異常終了
**関連するメソッド:**
emit - ステートマシンにイベントを送信
emitByUserId - ユーザーIDを指定してステートマシンにイベントを送信
report - ステートマシンに複数のイベントを報告
reportByUserId - ユーザーIDを指定してステートマシンに複数のイベントを報告


#### 同期実行スクリプト

ステートマシンの異常終了処理の前に、スクリプトが同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| stateMachineMaster | [StateMachineMaster](../sdk/#statemachinemaster) | ステートマシンマスターデータ |
| status | [Status](../sdk/#status) | ステータス |
| userId | string | ユーザーID |

##### Result

|  | 型 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | ステートマシンの異常終了を許可するか |

##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local stateMachineMaster = args.stateMachineMaster
local status = args.status
local userId = args.userId

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### 非同期実行スクリプト

ステートマシンの異常終了処理の後に、スクリプトが非同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| stateMachineMaster | [StateMachineMaster](../sdk/#statemachinemaster) | ステートマシンマスターデータ |
| status | [Status](../sdk/#status) | ステータス |
| userId | string | ユーザーID |


##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local stateMachineMaster = args.stateMachineMaster
local status = args.status
local userId = args.userId

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}
```


---
  



