Tools for Debugging and Testing
This page contains useful tips and tricks for checking for flaws in your script code and making testing in general a bit easier.
The first place to go if you're having a problem or just want to make your life easier is the debug menu, which you can open at any time by pressing Ctrl + D.
You can open any sub menu/execute any function by pressing the corresponding key combination. Below is a list of some of the most commonly useful menus and features.
To check the current state of your dialogues and to lock/unlock certain topics for testing purposes, you can use the dialogue debug menu accessible via Ctrl + H -> Alt + D. This menu provides extensive information about all dialogues and highlights potential problems/reasons why your dialogue might not behave as intended (look for anything that's marked in a bright red).
To display a list of all the global variables currently in use along with their values, you can use the the menu under Ctrl + G -> Alt + V.
If a creature does not behave the way you expect them to, you can tell the game to print a detailed history of their actions and received commands to the dev console. To do so, open the creature debug menu using Ctrl + C, then display the creature's action and animation details using Alt + B.
Finally, locate the creature whose actions you want to track and click on the "Track" button above it. In the dev console, you should then see the confirmation New target set for history log: <Creature Name> (id: xxx). To display only the creature's action history in the console, use the cr filter at the top.
If you want to access a script object and you're not sure what it's called, use Ctrl + G -> Alt + S to have the game display the names of all objects accessible via script.
The dev console can be opened by pressing the ^ key. It will show all recent log entries and allows you to issue commands to the game for debugging purposes. You can filter the information displayed in the console by pressing the buttons at the top right of the screen (double right-click a button to restrict output only to that category).
You can tap the Tab key once to autocomplete whatever command you are currently typing and double-tap it to display a list of possible commands and their parameters.
For script debugging, you can use the print command in order to track which functions are being called as well as the values of your variables.
Anything printed using this function will appear in the dev console under the sc filter. This will also display any error messages caused by the script along with a callstack to tell you where the error was caused, so check there first if you are encountering a problem.
One of the most useful console commands for debugging your script is the logic level scriptcall command, which you can use to execute arbitrary AngelScript code. You can use the print function to output the states of your script variables, as well as change them or call arbitrary functions. Within the scriptcall command, you have access to both the game's script interface using the variable Game as well as the level's script class using the variable Script.