Overview
Modules are powerful because they:- Persist across states: Continue running when the player navigates between menus and gameplay
- Receive all events: Can respond to any game event without needing specific context
- Support priorities: Control the order in which modules receive events
- Can be toggled: Activate/deactivate dynamically based on conditions
- State-scoped: Optionally limit events to specific game states
Creating a Module
Modules are created as.hxc script files in your mod’s scripts directory.
Basic Module Structure
Module Parameters
Unique identifier for your module. Use kebab-case by convention. priority (default: 1000)
Determines event processing order. Lower numbers = higher priority (processed first). params (optional)
Configuration object:
state: Limit module to only receive events when in this specific state
Example: State-Scoped Module
Module Properties
Active State
Priority
State Association
Core Lifecycle Events
onCreate
It may not be safe to reference other modules in
onCreate since they may not be loaded yet.onDestroy
onUpdate
onScriptEvent
Gameplay Events
Modules implementIPlayStateScriptedClass and receive all gameplay events.
Note Events
Song Events
Countdown Events
BPM-Synced Events
Game State Events
Song Events
State Management Events
Modules implementIStateChangingScriptedClass for state transition events.
UI State Events
Freeplay Events
Character Select Events
Module Management
TheModuleHandler class manages all loaded modules.
Get Module by ID
Activate/Deactivate Modules
Call Events Manually
Complete Example: Combo Tracker
Best Practices
Choose Appropriate Priorities
- 1-100: Critical mods that must run first (core gameplay changes)
- 100-500: UI and visual mods
- 500-1000: Tracking and analytics mods
- 1000+: Low-priority cosmetic mods
Use State Scoping
Limit modules to specific states when possible to improve performance:Handle Null Safely
Clean Up Resources
Related
- IScriptedClass - Interface definitions for all events
- PolymodHandler - Mod loading system
- Song Events - Song event reference
