debug

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


概要


APIリファレンス
関数
traceback
debug.traceback(
message:string, level:number
パラメータ
message:string
level:number
既定値: 1
戻り値
コードサンプル
デバッグトレースバック

traceback
debug.traceback(
thread:coroutine, message:string, level:number
パラメータ
thread:coroutine
message:string
level:number
既定値: 1
戻り値
コードサンプル
スレッドのデバッグトレースバック

info
debug.info(
level:number, options:string
パラメータ
level:number
options:string
戻り値
コードサンプル
レベル別デバッグ情報

info
debug.info(
function:function, options:string
パラメータ
function:function
options:string
戻り値
コードサンプル
関数によるデバッグ情報

info
debug.info(
thread:coroutine, level:number, options:string
パラメータ
thread:coroutine
level:number
options:string
戻り値
コードサンプル
スレッドによるデバッグ情報

profilebegin
debug.profilebegin(label:string):()
パラメータ
label:string
戻り値
()
コードサンプル
デバッグプロファイル開始
local function buildGrid(size)
debug.profilebegin("BuildGrid")
local grid = table.create(size * size, 0)
debug.profileend()
return grid
end
print(#buildGrid(32)) --> 1024

profileend
debug.profileend():()
戻り値
()
コードサンプル
デバッグプロファイル終了
debug.profilebegin("Outer")
debug.profilebegin("Inner")
-- ここで行われた作業は両方のラベルの下で計測されます
debug.profileend() -- "Inner" を閉じます
debug.profileend() -- "Outer" を閉じます

getmemorycategory
debug.getmemorycategory():string
戻り値
コードサンプル
デバッグメモリカテゴリの取得
local category = debug.getmemorycategory()
print(type(category)) --> string
-- カテゴリはスレッドに従うため、新しいものはこれとは異なる場合があります
local previous = debug.setmemorycategory("Pathfinding")
print(debug.getmemorycategory()) --> Pathfinding
debug.setmemorycategory(previous)

setmemorycategory
debug.setmemorycategory(tag:string):string
パラメータ
tag:string
戻り値
コードサンプル
デバッグメモリカテゴリの設定
local original = debug.setmemorycategory("MapGeneration")
print(debug.getmemorycategory()) --> MapGeneration
-- ここで行われた割り当ては、開発者コンソールの「MapGeneration」にリストされます
local tiles = table.create(1000, 0)
-- 戻り値は前のカテゴリなので、元に戻すことができます
print(debug.setmemorycategory(original) == "MapGeneration") --> true
print(#tiles) --> 1000

resetmemorycategory
debug.resetmemorycategory():()
戻り値
()
コードサンプル
デバッグリセットメモリーカテゴリ
local automatic = debug.getmemorycategory()
debug.setmemorycategory("Spawning")
print(debug.getmemorycategory()) --> Spawning
debug.resetmemorycategory()
print(debug.getmemorycategory() == automatic) --> true

dumpcodesize
debug.dumpcodesize():()
戻り値
()
コードサンプル
デバッグダンプコードサイズ
-- debug.dumpcodesize()はスタジオのコマンドバーからのみ動作し、出力に
-- ネイティブスクリプトごとに1つのテーブルを持つレポートを印刷します。最も大きな関数が最初に表示されます:
-- # ネイティブコードサイズ分析
-- <n> スクリプト, <n> 関数, <n> KB メモリ, 256 MB コードサイズ制限
-- ## <script name>
-- <n> 関数, <n> KB メモリ
-- | 関数 | 行 | ネイティブコードサイズ | ネイティブコードサイズ (%) |
-- --!nativeで始まり、実行されたスクリプトのみがレポートに表示されます。
-- スクリプトからはエラーが発生し、pcallがキャッチします
local ok, message = pcall(debug.dumpcodesize)
print(ok) --> false
print(message) --> dumpcodesizeはCommandBarからのみ呼び出すことができます

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