Debug

The Debug file holds any files used for SRL debugging and logging. Debug usage guidelines are as follows:

  • Use print(‘TRSMinimap.getDots()’, TDebug.HEADER) to initilize a function header.
  • Use print(‘TRSMinimap.getDots(): ‘+toStr(result), TDebug.FOOTER) to signal the end of the function.
  • WARNING: If TDebug.HEADER is used, a TDebug.FOOTER MUST be called once before exiting the function.
  • Use print(‘Function/procedure name here’, TDebug.SUB) for short functions that don’t need a header/footer.
  • HINT: Always include the function’s name in a TDebug.SUB to make it easier for developers.
  • Use print(‘Message’, TDebug.ERROR) for error messages.
  • Use print(‘Message’, TDebug.WARNING) for warnings. If a lot of warnings are expected in a row, use print() once, followed by print(‘Message’ TDebug.LOG).
  • Use print(‘Message’) for informational messages (i.e. “Checking if...” or “Found...”).
  • Use print(‘Message’, TDebug.LOG) for specific information the user won’t want to see, but will be useful for scripters to debug (i.e. “Found 20 pixels of the color 12345678 with tolerance 15”).
  • Use print(‘Message’, TDebug.HINT) for scripting hints.
  • Use print(‘Message’, TDebug.FATAL) to terminate the script.

The source for this file can be found here.

type TDebug

A set of enums used to distinguish between the types of SRL debugging.

Example:

print('Failed to open bank', TDebug.ERROR);

var External Debug

External SRL debug variables that can be set scripts:

  • logPath: string; The path the save the SRL log file. Default path is SRL-6/logs/.
  • disableSRLLog: boolean; Disables saving debug to a log file. Default false.
  • disableSRLDebug: boolean; Disables SRL functions from printing to the debug box. Default false.

print

procedure print(txt: string; debugType: TDebug = TDebug.DEBUG);

Prints txt to the debug box if debugType doesn’t equal TDebug.LOG. Will always print to the log file unless disableSRLLog is set to true. Valid arguements for debugType:

  • DEBUG (default)
  • LOG
  • HINT
  • WARNING
  • ERROR
  • HEADER
  • FOOTER
  • SUB

Note

  • by Coh3n & masterBB
  • Last Modified: 24 May 2013 by Coh3n

Example:

print(TheDate);

printf

procedure printf(txt: string; args: TVariantArray; debugType: TDebug = TDebug.DEBUG);

Sister function for print, will use the function “format” to print the string + data.

Note

  • by Olly
  • Last Modified: 22 April 2014 by Olly

Example:

printf('hello %d', [50]);

debugATPA

procedure debugATPA(atpa: T2DPointArray; bmpName: string);

Draws the points of a T2DPointArray in the debug image window. It will plot each element of the array in a different color.

Note

  • by Wizzup?
  • Last Updated: 24 July 2013 by Olly

Example:

debugATPA(atpa);

debugATPABounds

procedure debugATPABounds(const ATPA: T2DPointArray);

Draws the bounds of each element of a T2DPointArray in the debug image window.

Note

  • by Wizzup?
  • Last Updated: 24 July 2013 by Olly

Example:

debugATPABounds(atpa);

debugTPA

procedure debugTPA(tpa: TPointArray; bmpName: string);

Draws a TPointArray on the debug image window.

Note

  • by Wizzup?
  • Last Updated: 24 July 2013 by Olly

Example:

debugTPA(tpa);

takeScreenshot

procedure takeScreenshot(fileName: string);

Saves a screenshot ‘fileName’ to the SRL log directory. It also adds the script’s run time to avoid replacing images.

Note

  • by Harry & Coh3n
  • Last updated: 9 February, 2013 by Coh3n

Example:

takeScreenshot('example.png');

debugBitmap

procedure debugBitmap(bmp: integer);

Draws a bitmap on the debug image window.

Note

  • by Olly
  • Last Updated: 24 July 2014 by Olly

Example:

debugTPA(tpa);