Discord

Preparing your files

Please wait until the download is ready.

Luka's Scripting Utilities

Luka's Scripting Utilities

by Luka S.J.

A pack full of various scripting utilities to ease your development!

v4.1.135,194
Download144 KB

Logger & Error Messages

Logger

LUTS::Logger writes timestamped, levelled messages to both the console and a
log file (luts_log.txt). Each level has its own console colour.

LUTS::Logger.info("Plugin loaded")
LUTS::Logger.warn("Missing optional asset")
LUTS::Logger.error("Failed to read data file")
LUTS::Logger.debug("verbose detail")        # only when $DEBUG
LUTS::Logger.critical("Unrecoverable!")      # logs, then raises
  • LUTS::Logger.info(msg, options = {}) INFO level (console colour: cyan)
  • LUTS::Logger.warn(msg, options = {}) WARN level (brown)
  • LUTS::Logger.error(msg, options = {}) ERROR level (red)
  • LUTS::Logger.debug(msg, options = {}) DEBUG level — only emits when $DEBUG is truthy
  • LUTS::Logger.critical(msg, options = {}) logs at ERROR level and raises LUTS::ScriptError to halt the game
  • LUTS::Logger.log_msg(msg, options = {}) the underlying logger that all levels call (writes timestamp + level to console and file)

The options hash controls formatting (colour, headers, indentation, and
:skip_console to suppress console output). Helpers: timestamp,
console_color(type), log_path.

Error Messages

LUTS::ErrorMessages defines a family of ready-made error classes. Each builds
a descriptive message and reports it at an appropriate log level when you call
raise on the instance (routing through LUTS::Logger).

  • ImageNotFound.new(path) — a bitmap could not be found (level: error)
  • SpriteError.new(name) — no such Sprites::* class to instantiate (level: warn)
  • ComponentError.new(name) — a component could not be loaded (level: warn)
  • MissingFunctionError.new(klass, function) — an undefined method was called (level: warn)
  • VertexError.new(vertices = 3) — too few polygon vertices (level: error)
LUTS::ErrorMessages::ImageNotFound.new("Graphics/Pictures/foo").raise

All of these derive from BaseError; LUTS::ScriptError is the
StandardError subclass that Logger.critical raises to crash the game.