Returns a description of the current call stack as a string.
- Adds the given string to the top of the trace report. Defaults to blank.
- Number of levels of the stack to skip. Defaults to 1, to skip the trace() call's own level.
trace() function returns a description of the current call stack as a string. This string is long, and is only useful when printed to a terminal window with printh().
As of Pico-8 v0.1.6, the string includes useless information referring to internal details. For example, if the cart uses the game loop, this stack trace includes the hidden
Here's a simple program that counts up to 30, prints the stack trace to the console, then stops.
v = 0 function next() if v > 30 then printh(trace()) stop() end return v + 1 end function _update() v = next() end function _draw() cls() print(v, 0, 0, 7) end
As of Pico-8 v0.1.11g, the console output shows the trace as follows:
stack traceback: [string "-- pico-8 header..."]:7: in function 'next' [string "-- pico-8 header..."]:14: in function '_update' [string "-- pico-8 header..."]:31: in function '_mainloop' [string "-- pico-8 header..."]:38: in main chunk