coroutine

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。


概要


APIリファレンス
関数
close
coroutine.close(co:coroutine):boolean,Variant<string, ()>
パラメータ
戻り値
boolean, Variant<string, ()>
コードサンプル
コルーチンのクローズ

create
coroutine.create(f:function):coroutine
パラメータ
戻り値
コードサンプル
コルーチンの作成

finally
coroutine.finally(
co:coroutine, callback:Variant)
パラメータ
callback:Variant
コードサンプル
コルーチンの最終処理
local function observe(co, label)
coroutine.finally(co, function(status, ...)
print(label, status, ...)
end)
end
local finishing = coroutine.create(function()
return "結果"
end)
observe(finishing, "finishing") --> finishing finished result
coroutine.resume(finishing)
local failing = coroutine.create(function()
error("バン", 0)
end)
observe(failing, "failing") --> failing error boom
coroutine.resume(failing)
local cancelled = coroutine.create(function()
coroutine.yield()
end)
coroutine.resume(cancelled)
observe(cancelled, "cancelled") --> cancelled cancelled
coroutine.close(cancelled)

isyieldable
coroutine.isyieldable():boolean
戻り値
コードサンプル
コルーチンは中断可能です

resume
coroutine.resume(
co:coroutine, ...:Variant
):boolean,Variant<Tuple, string>
パラメータ
...:Variant
戻り値
boolean, Variant<Tuple, string>
コードサンプル
コルーチンの再開

running
coroutine.running():coroutine
戻り値
コードサンプル
コルーチンの実行

status
coroutine.status(co:coroutine):string
パラメータ
戻り値
コードサンプル
コルーチンの状態

wrap
coroutine.wrap(f:function):function
パラメータ
戻り値
コードサンプル
コルーチンラップ

yield
coroutine.yield(...:Tuple):Tuple<Variant>
パラメータ
...:Tuple
戻り値
Tuple<Variant>
コードサンプル
コルーチンの一時停止

©2026 Roblox Corporation。Roblox(ロブロックス)、RobloxロゴおよびPowering Imaginationは、米国並びにその他の国における登録商標および非登録商標です。