debug_event

This function generates a custom debug event that will be shown in the Graph View of The Debugger when a game is being run in Debug Mode. If you require messages to be displayed when not in debug mode, use show_debug_message.

The function will also take five reserved strings to help perform debugging using external applications like Visual Studio. These strings are:

 

ResourceCountsResourceCounts

When you call debug_event with the "ResourceCounts" argument, it returns a struct with information about all the active resources in your game.

Each resource is represented with three properties:

The struct has the following members:

 

DumpMemory DumpMemory

When you call debug_event with the "DumpMemory" argument, it returns a struct with information about your game's memory usage.

The members of the struct will differ based on the platform, however all platforms will at least have the following values in the struct (in bytes):

The way these values are measured is different on each platform.

 

Syntax:

debug_event(string, [silent]);

Argument Type Description
string String The custom debug event string to use or one of the five reserved strings.
silent Boolean OPTIONAL This parameter makes the function silently return the result to the runner in a struct rather than printing the value to the console. Defaults to false.

 

Returns:

Struct (for some options) or N/A

 

Example 1: Custom String

if !surface_exists(global.EffectsSurface)
{
    debug_event("Recreating Effects Surface");
    global.EffectsSurface = surface_create(room_width, room_height);
}

The above code checks to see if a surface exists and if it does not, a debug event is triggered in the graph view of the debugger (the game must have been run in Debug Mode for this to be visible) and the surface is recreated.

 

Example 2: Reserved Strings

var _counts = debug_event("ResourceCounts");

The above code triggers a debug event with the message "ResourceCounts". As this is a reserved string, resource counts are output to the console and also returned in a struct. This struct is stored in a temporary variable _counts. To suppress the output to the console, set the second parameter to true

var _counts = debug_event("ResourceCounts", true);