debug

*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.


Podsumowanie

Funkcje
traceback(message: string,level: number):string
traceback(thread: coroutine,message: string,level: number):string
info(level: number,options: string):Tuple
info(function: function,options: string):Tuple
info(thread: coroutine,level: number,options: string):Tuple
profilebegin(label: string):()

Materiały referencyjne dotyczące interfejsów API
Funkcje
traceback
debug.traceback(
message:string, level:number
Parametry
message:string
level:number
Wartość domyślna: 1
Zwroty
Przykłady kodu
Ślad debugowania

traceback
debug.traceback(
thread:coroutine, message:string, level:number
Parametry
thread:coroutine
message:string
level:number
Wartość domyślna: 1
Zwroty
Przykłady kodu
Ślad debugowania wątku

info
debug.info(
level:number, options:string
Parametry
level:number
options:string
Zwroty
Przykłady kodu
Informacje debugowania według poziomu

info
debug.info(
function:function, options:string
Parametry
function:function
options:string
Zwroty
Przykłady kodu
Informacje debugowania według funkcji

info
debug.info(
thread:coroutine, level:number, options:string
Parametry
thread:coroutine
level:number
options:string
Zwroty
Przykłady kodu
Informacje debugowania według wątku

profilebegin
debug.profilebegin(label:string):()
Parametry
label:string
Zwroty
()
Przykłady kodu
Rozpoczęcie profilu debugowania
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():()
Zwroty
()
Przykłady kodu
Zakończenie profilu debugowania
debug.profilebegin("Outer")
debug.profilebegin("Inner")
-- Prace wykonane tutaj są mierzone pod oboma etykietami
debug.profileend() -- zamyka "Inner"
debug.profileend() -- zamyka "Outer"

getmemorycategory
debug.getmemorycategory():string
Zwroty
Przykłady kodu
Debuguj Kategorię Pamięci
local category = debug.getmemorycategory()
print(type(category)) --> string
-- Kategoria podąża za wątkiem, więc nowa może różnić się od tej
local previous = debug.setmemorycategory("Pathfinding")
print(debug.getmemorycategory()) --> Pathfinding
debug.setmemorycategory(previous)

setmemorycategory
debug.setmemorycategory(tag:string):string
Parametry
tag:string
Zwroty
Przykłady kodu
Debuguj Ustaw Kategorię Pamięci
local original = debug.setmemorycategory("MapGeneration")
print(debug.getmemorycategory()) --> MapGeneration
-- Alokacje dokonane tutaj są wymienione pod "MapGeneration" w Konsoli Dewelopera
local tiles = table.create(1000, 0)
-- Wartość zwracana to poprzednia kategoria, więc można ją przywrócić
print(debug.setmemorycategory(original) == "MapGeneration") --> true
print(#tiles) --> 1000

resetmemorycategory
debug.resetmemorycategory():()
Zwroty
()
Przykłady kodu
Kategoria Resetowania Pamięci Debugowania
local automatic = debug.getmemorycategory()
debug.setmemorycategory("Spawning")
print(debug.getmemorycategory()) --> Spawning
debug.resetmemorycategory()
print(debug.getmemorycategory() == automatic) --> true

dumpcodesize
debug.dumpcodesize():()
Zwroty
()
Przykłady kodu
Rozmiar kodu zrzutu debugowania
-- debug.dumpcodesize() działa tylko z paska poleceń Studio, gdzie drukuje
-- raport do Wyjścia z jedną tabelą na każdy natywny skrypt, największe funkcje najpierw:
-- # Analiza rozmiaru kodu natywnego
-- <n> skryptów, <n> funkcji, <n> KB pamięci, limit rozmiaru kodu 256 MB
-- ## <nazwa skryptu>
-- <n> funkcji, <n> KB pamięci
-- | Funkcja | Linia | Rozmiar kodu natywnego | Rozmiar kodu natywnego (%) |
-- Tylko skrypty, które zaczynają się od --!native i zostały uruchomione, pojawiają się w raporcie.
-- Z poziomu skryptu zgłasza błąd, który pcall przechwytuje
local ok, message = pcall(debug.dumpcodesize)
print(ok) --> false
print(message) --> dumpcodesize można wywołać tylko z CommandBar

©2026 Roblox Corporation. Nazwa Roblox, logo Roblox oraz hasło „Powering Imagination” należą do naszych zarejestrowanych i niezarejestrowanych znaków towarowych na terenie Stanów Zjednoczonych oraz w innych krajach.