Watching variables in a script
When debugging a script, it's sometimes valuable to check the value of a variable, or the contents of a structure or array. This can be done quite easily in FRED's scripting editor.
However, the one thing to note is that you have to specify each item "to watch" individually - you can't just browse the whole of an array or structure
- Open the script editor
- Left-click in the gray margin at the left side to add a breakpoint at a line of your choosing
- Run the script
- In the area at the top, note that there is a tab on the left side labelled "Watch", click this.
- Then, in the blank window, write in the variables that you wish to keep an eye on. In the picture at the top of this page there are three examples:
- a single variable: lens
- a member of the T_ENTITY structure: ent.name
- the contents of one cell of an array: myArray(2)
- Then as you step through the script (e.g. by using the "step into" button) the value of these variables will be dynamically updated at the top.
Note: if you don't see this mini toolbar at the top of the script debug window, then select from the FRED main menu select Tools / Preferences... / Format tab/ Script Editor Window / Show toolbar