Fandom

Pico-8 Wiki

Trace

162pages on
this wiki
Add New Page
Comments0 Share
trace( )

Returns a description of the current call stack as a string.

Undocumented feature
This article describes a feature that is not mentioned in the official Pico-8 documentation. The feature was known to work at the time the article was written, but it may be removed or changed in a future version.

The 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 _mainloop function.

Examples Edit

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.6, the console output shows the trace as follows:

stack traceback:
	[string "-- pico-8 header..."]:0.0001144: in function 'next'
	[string "-- pico-8 header..."]:0.0002213: in function '_update'
	[string "-- pico-8 header..."]:0.0004807: in function '_mainloop'
	[string "-- pico-8 header..."]:0.0005875: in main chunk

See also Edit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.