taskライブラリ
ライブラリ日本語解説あり
ひとことで言うと
待つ・あとで実行する・同時に実行する、といった時間に関わる処理のためのライブラリです。task.wait(1) で1秒待てます。
公式の説明(英語):Allows for functions and threads to be coordinated with the engine's scheduler.
使用例
Script置く場所:ServerScriptService
local count = 3
while count > 0 do
print(count)
count -= 1
task.wait(1)
end
print("スタート!")スクリプトは、Luauの型チェック(luau-lsp)で確認しています。
関数(7)
| 名前と書き方 | 説明 |
|---|---|
spawntask.spawn(functionOrThread: function | thread, ...: Variant): thread | 関数をすぐに、別の流れ(スレッド)で実行します。Calls/resumes a function/coroutine immediately through the engine's scheduler. |
defertask.defer(functionOrThread: function | thread, ...: Variant): thread | 今の処理が終わったあとに関数を実行します。Calls/resumes a function/coroutine at the end of the current resumption cycle. |
delaytask.delay(duration: number, functionOrThread: function | thread, ...: Variant): thread | 指定した秒数のあとに関数を実行します。Schedules a function/coroutine to be called/resumed on the next Heartbeat after the given duration (in seconds) has passed, without throttling. |
desynchronizetask.desynchronize(): () | Causes the following code to be run in parallel. |
synchronizetask.synchronize(): () | Causes the following code to be run in serial. |
waittask.wait(duration: number): number | 指定した秒数だけ待ちます。Yields the current thread without throttling. |
canceltask.cancel(thread: thread): () | spawnやdelayで予定した処理を取り消します。Cancels a thread, preventing it from being resumed. |
taskを使う記事
英語の説明とメンバーの一覧は、Roblox Creator Documentation(task)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。