*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

LuauExecutionSessionTask

A LuauExecutionSessionTask ("任務" 簡稱) 在特定版本的空間方上執行給定的 Luau 腳本。

在任務中,物理模擬不會執行。位置內的服務器和本地腳本也不會自動執行。

腳本可以存取並更新位空間的數據模型,包括呼叫任何模組腳本。然而,數據模型變更是本地於任務,無法被保持。

腳本也可以呼叫雲端中寫入和/或修改存儲的資料的引擎 API,例如數據儲存的 API。使用這些 API 時請注意小心。

腳本的大小可達 4MB,並可運行長達 5 分鐘。超過時間限制的腳本將以錯誤結束。

腳本原樣執行,不需要包裝在函數中。

腳本可以返回值 (使用 Luau return 關鍵字)。返回值會被 serialized到JSON,並可以在任務完成後使用 Get LuauExecutionSessionTask API 來取得。JSON 序列化後的返回值總大小不得超過 4MB。如果達到限制,任務將以錯誤結束。

如果腳本發出未處理的錯誤,任務將終止。錯誤信息可以使用 GetLuauExecutionSessionTask API 來恢復。

標準輸出(由 Luau print 函數生成)可以在任務完成後使用 ListLuauExecutionSessionTaskLogs 方法來恢復。最多保留 450 KB 的日誌記錄。如果記錄數量超出限制,較舊的記錄將被丟棄。

任務資訊在任務完成後的 24 小時內保留。

每個地方最多只允許十個未完成的任空間。嘗試在第十個任務未完成時創建更多任務會導致 HTTP 429 回應。

  • 資源路徑
  • /cloud/v2/universes/{universe_id}/places/{place_id}/luau-execution-session-tasks
  • /cloud/v2/universes/{universe_id}/places/{place_id}/versions/{version_id}/luau-execution-session-tasks
  • /cloud/v2/universes/{universe_id}/places/{place_id}/versions/{version_id}/luau-execution-sessions/{luau_execution_session_id}/tasks

特性

pathstring

luau執行會話任務的資源路徑。

格式:

  • universes/{universe_id}/places/{place_id}/luau-execution-session-tasks/{luau_execution_session_task_id}
  • universes/{universe_id}/places/{place_id}/versions/{place_version_id}/luau-execution-session-tasks/{luau_execution_session_task_id}
  • universes/{universe_id}/places/{place_id}/luau-execution-sessions/{luau_execution_session_id}/tasks/{luau_execution_session_task_id}
  • universes/{universe_id}/places/{place_id}/versions/{place_version_id}/luau-execution-sessions/{luau_execution_session_id}/tasks/{luau_execution_session_task_id}.
createTimestring
僅限輸出

此任務創建時間。. 此字串的格式為 Timestamp

updateTimestring
僅限輸出

此任務狀態最後更改時間。. 此字串的格式為 Timestamp

userstring
僅限輸出

創建此任務所使用的 API 鑰匙的用戶。.

stateEnum<string>
僅限輸出

任務狀態。請參閱狀態枚列以獲得每種可能值的資訊。

可能的值:

| 值 | 說明 | | --- | --- | | 狀態_未指定 | 未指定 | | 已排隊 | 任務正在等待處理。| | 處理 | 任務已被選擇以進行處理。| | 已取消 | 任務已被使用者停止。| | 完成 | 任務已完成處理。輸出欄包含輸出。| | 失敗 | 任務失敗。錯誤欄包含關於錯誤的詳細信息。|. 可能的值:

scriptstring
不可改變

要作為此任務一部分的腳本。

例如:


local x = 3
local y = 4
return x + y
```.
timeoutstring
不可改變

限制腳本能運執行多久。

任務會失敗,如果腳本在指定時間內未完成。

預設為 5 分鐘。.

result 請選擇其中一項:

errorobject

在任務執行失敗時呈現。包含失敗原因的詳細資訊。.

outputobject

在任務執行成功時提供。包含執行的輸出。.

基本網址

https://apis.roblox.com
LuauExecutionSessionTask資源

{
"path": "universes/123/places/123/luau-execution-session-tasks/123e4567-e89b-12d3-a456-426655440000",
"createTime": "2023-07-05T12:34:56Z",
"updateTime": "2023-07-05T12:34:56Z",
"user": "string",
"state": "STATE_UNSPECIFIED",
"script": "string",
"timeout": "3s",
"error": {
"code": "ERROR_CODE_UNSPECIFIED",
"message": "string"
}
}

LuauExecutionSessionTask

Create Luau Execution Session Task
Beta

POST /cloud/v2/universes/{universe_id}/places/{place_id}/luau-execution-session-tasks

創建任務,但不等待任務完成。

若要檢查任務是否已完成,請呼叫 GetLuauExecutionSessionTask 方法並檢查返回資源的 state 欄位。

額度:

  • 每 API 鑰匙擁有者每分鐘 5 次呼叫
  • 每個 IP 地址每分鐘 45 次呼叫
範圍
universe.place.luau-execution-session:write
請求路徑參數
universe_idstring
需要

宇宙ID。.

place_idstring
需要

地點ID。.

請求主體LuauExecutionSessionTask
POST /cloud/v2/universes/{universe_id}/places/{place_id}/luau-execution-session-tasks

curl -L -X POST 'https://apis.roblox.com/cloud/v2/universes/{universe_id}/places/{place_id}/luau-execution-session-tasks' \
-H 'x-api-key: {your-api-key}' \
-H 'Content-Type: application/json' \
--data '{
"script": "string",
"timeout": "3s"
}'
回應

{
"path": "universes/123/places/123/luau-execution-session-tasks/123e4567-e89b-12d3-a456-426655440000",
"createTime": "2023-07-05T12:34:56Z",
"updateTime": "2023-07-05T12:34:56Z",
"user": "string",
"state": "STATE_UNSPECIFIED",
"script": "string",
"timeout": "3s",
"error": {
"code": "ERROR_CODE_UNSPECIFIED",
"message": "string"
}
}