Debugging and saved scripts
Stepping through a program (debugging)
When a program does something odd, watch it one line at a time:
- Breakpoints: in Text, click just left of a line number (a red dot appears); in Blocks, click the small circle at the left of a block. When the program reaches that line it pauses before running it.
- Pause (while running) stops before the next line. Step runs one line and pauses again (it goes into your functions too). Continue runs on to the next breakpoint, or the end.
-
While paused, a box under the editor shows the line it's about to run and your variables (the ones inside a function show as
name (in function)). - Breakpoints aren't saved; they last until you load another game. Online this all runs on the server, just the same.
Saved scripts
The row above the editor is Poncho's script library (up to 10 scripts, saved with your character): type a name (letters, digits, _) and press Save as to keep a copy of the program; pick one in the list and press Load to put it back in the editor (it replaces what's there), or Delete it.
With the Engineering perk Subroutines (tier 2), a program can run a saved script like a function: run_script("harvest_row"). It runs the whole script, then carries on with the next line. Variables and functions the script makes are shared with your program, so a script full of defs works as a library. Each saved script has to fit the motherboard on its own, but its lines don't count against the program that runs it: that's how big jobs fit on a small board. When stepping, a run_script() line runs as one step; an error inside a script says which script and line.