3 Debugging
Victor Westerlund edited this page 2026-08-22 12:01:04 +02:00

Debugging

mcfstd includes a small debug surface for inspecting scoreboards and receiving trace messages.


Functions

Function Arguments Purpose
debug:var none Display the _var objective in the sidebar
debug:reg none Display the _reg objective in the sidebar
debug:trace/enable k Add _debug tag to an entity and enable trace output
debug:trace/disable k Remove _debug tag from an entity

Display variables

function debug:var

This sets the sidebar display to _var, showing user variables managed through var:.

function debug:reg

This sets the sidebar display to _reg, showing internal registers and flags.


Trace output

Enable trace messages for an entity selector:

function debug:trace/enable { k: "@s" }

This does two things:

  • sets _std_is_debug in _reg to 1
  • adds the _debug tag to the selected entity

Internal debug messages are sent to entities with the _debug tag.

Disable trace messages for a selector:

function debug:trace/disable { k: "@s" }

This removes the _debug tag from the selected entity. It does not currently set _std_is_debug back to 0, so debug dispatch remains enabled globally after the first enable call, but no messages are delivered if no entities have _debug.


What trace messages show

Most public and internal functions call z_std:debug with a short message when tracing is enabled.

Examples include:

  • function names and macro argument values
  • register updates such as a=1
  • trigger construction and list entries
  • block placement context creation

Trace output is sent with tellraw in gray italic text.


Cleanup

z_std:uninstall removes _debug tags from entities before deleting mcfstd objectives and trigger state.