Skip to main content

Overview

The DragonRealms experience monitoring system provides real-time tracking of skill experience gains with configurable display options. The DRExpMonitor module manages background reporting threads and inline experience displays.

DRExpMonitor

The DRExpMonitor module provides methods to control experience gain tracking.

start

Starts the background experience reporter thread.
DRExpMonitor.start
Behavior:
  • Creates a background thread that reports skill gains every second
  • Displays info message if already active
  • Returns early with error if exp-monitor.lic script is running (conflicts)
  • Thread automatically reports aggregated skill gains until stopped
Example:
# Start monitoring experience gains
DRExpMonitor.start
# => "DRExpMonitor: Experience gain reporting is already active" (if already running)

# Skill gains will be reported as:
# => "DRExpMonitor: Evasion(+2), Athletics(+1)"

stop

Stops the background experience reporter thread.
DRExpMonitor.stop
Behavior:
  • Terminates the reporter thread gracefully
  • Displays info message if already inactive
  • Thread cleanup happens automatically
Example:
DRExpMonitor.stop
# => "DRExpMonitor: Experience gain reporting is already inactive" (if not running)

active?

Checks if the experience reporter is currently running.
DRExpMonitor.active?
Returns:
  • true if the reporter thread is running
  • false if stopped
Example:
if DRExpMonitor.active?
  echo "Experience monitoring is active"
else
  DRExpMonitor.start
end

inline_display?

Checks if inline experience display is enabled.
DRExpMonitor.inline_display?
Returns:
  • true if inline display is enabled
  • false if disabled (default)
Behavior:
  • Lazy-loaded from database on first access
  • Defaults to false - must be explicitly enabled
  • Uses persistent storage (survives restarts)
  • Includes SQLite retry logic with max 10 attempts
Example:
if DRExpMonitor.inline_display?
  echo "Inline experience display is ON"
end

inline_display=

Enables or disables inline experience display.
DRExpMonitor.inline_display = value
value
boolean
required
Enable (true, "on", "yes") or disable (false, "off", "no") inline display
Behavior:
  • Accepts boolean or string values (“on”, “true”, “yes” for true)
  • Persists setting to database for future sessions
  • Modifies EXP output to include cumulative gained experience
  • Includes SQLite retry logic with max 10 attempts
Example:
# Enable inline display
DRExpMonitor.inline_display = true

# Disable inline display
DRExpMonitor.inline_display = "off"

# Experience output will show:
# BRIEFEXP ON:  "     Aug:  565 39%  [ 2/34] 0.12"
# BRIEFEXP OFF: "    Augmentation:  565 39% learning      0.12"

format_briefexp_on

Formats a BRIEFEXP ON line to include cumulative gained experience.
DRExpMonitor.format_briefexp_on(line, skill)
line
string
required
The original BRIEFEXP ON format line
skill
string
required
The skill name to look up gained experience
Returns:
  • Modified line with gained experience appended
  • Original line unchanged if inline display is disabled
Example:
original = "     Aug:  565 39%  [ 2/34]"
formatted = DRExpMonitor.format_briefexp_on(original, "Augmentation")
# => "     Aug:  565 39%  [ 2/34] 0.12"

format_briefexp_off

Formats a BRIEFEXP OFF line to include cumulative gained experience.
DRExpMonitor.format_briefexp_off(line, skill, rate_word)
line
string
required
The original BRIEFEXP OFF format line
skill
string
required
The skill name to look up gained experience
rate_word
string
required
The learning rate word (e.g., “learning”, “pondering”)
Returns:
  • Modified line with gained experience appended
  • Original line unchanged if inline display is disabled
Example:
original = "    Augmentation:  565 39% learning     "
formatted = DRExpMonitor.format_briefexp_off(original, "Augmentation", "learning")
# => "    Augmentation:  565 39% learning      0.12"

Constants

MAX_SQLITE_RETRIES

Maximum number of SQLite retry attempts before giving up.
DRExpMonitor::MAX_SQLITE_RETRIES # => 10
Prevents infinite loops when database is locked.

BOOLEAN_TRUE_PATTERN

Regular expression for matching boolean true values.
DRExpMonitor::BOOLEAN_TRUE_PATTERN # => /\A(on|true|yes)\z/i
Anchored pattern prevents partial matches (e.g., won’t match “money” or “trust”).

Command Line Usage

The experience monitor can be controlled via the display command:
;display expgains          # Toggle on/off
;display expgains on       # Turn on
;display expgains off      # Turn off
Cannot run simultaneously with exp-monitor.lic script. Use ;kill exp-monitor first if needed.

Integration with DRSkill

The experience monitor integrates with the DRSkill module to access skill data:
# Get cumulative gained experience for a skill
gained = DRSkill.gained_exp("Evasion")
# => 2.45

# Access the gained skills queue
DRSkill.gained_skills
# => [{skill: "Evasion", change: 2}, {skill: "Athletics", change: 1}]

Thread Safety

The experience monitor is thread-safe:
  • Uses class variables for state management
  • Reporter thread runs in background
  • Cleanup handler registered via at_exit
  • Automatic stop on disconnect or exit

Error Handling

Robust error handling includes:
  • SQLite busy exception retry logic (max 10 attempts)
  • Conflict detection with exp-monitor.lic script
  • Graceful degradation on database lock
  • Error logging for debugging ($DREXPMONITOR_DEBUG)

Build docs developers (and LLMs) love