35. Debugging in the editor
1. Validate first. Double-click a diagnostic to go to its line. Read the first error before chasing later errors that may be consequences.
2. Add log() calls at the start of important branches. Log the value you are testing, not just “here”. Use to_json() for a dictionary of ordinary data.
3. Use the code editor breakpoint gutter, then run with the runtime debugger available. When paused, inspect locals, globals and context in the watch pane.
4. Use Step to advance and Continue to resume. Remove or disable a diagnostic breakpoint before the final player-facing build.
5. Test the unsuccessful branch, the successful branch, a second click, room re-entry and save/load. A puzzle that works only on its first attempt is unfinished.
global powered = false
function run()
let report = {"powered": powered, "scene": current_scene()}
log(to_json(report))
if powered
return "The machine is already running."
end
return "No power yet."
endFigure 13. The script editor’s watch pane shows state while execution is paused.
The statement breakpoint is a debugger pause point when debugging is enabled. The function helper breakpoint() is a diagnostic compatibility helper; use the statement or gutter for stepping. A breakpoint does not replace a condition or set a story variable.
