Frictional Games Forum (read-only)

Full Version: Script debug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can somebody explain how ScriptDebugOn(); is used? I know what it does but not how to use it.
Checks whether the debug mode is enabled.
See Setting up Development Environment to setup debug mode on your own computer.
To clarify a bit more: debugging is, well, the process of finding bugs in your code so that you can get rid of them. Sometimes, you write a script, and it looks like everything checks out, it compiles fine and the level loads, but then you find out that it does something completely unexpected, or mysteriously stops working, or something along those lines.

If that happens, you can try and investigate what's happening with the values of variables as your code is running, and what methods get called when, etc.

If you set up your development environment as explained in the link above, the ScriptDebugOn() will return true. On the other hand, when you deliver your custom story, when the non-dev users run the script, ScriptDebugOn() will return false. This means that you can use debugging as you're developing the CS or FC, print out diagnostic messages etc., and when a non-dev user runs your level, nothing of it will be shown (or executed).

PHP Code:
// let's say you just used some variable called "i"

if(ScriptDebugOn()) // the code below will only execute if ScriptDebugOn() returns true
{
    
AddDebugMessage("Value of i is: " ifalse);    // here false just means not to check for duplicate debug messages