Light State Controller¶
Custom light control system for original tables with RGB support and advanced sequencing.
Repository¶
https://github.com/mpcarr/vpx-light-controller
Overview¶
Light State Controller is a custom class system for controlling lights in original tables. Purpose-built for complex light shows and RGB effects that go beyond standard VPX capabilities.
Best for: Tables starting from scratch with complex lighting needs
Not recommended for: Retrofitting into tables with existing light animations (use Control Light method instead)
Features¶
- Multiple states per light
- RGB inserts with multiple flashing shots in different colors
- Custom sequences on individual banks of lights
- Integration with Lampz for fading and callbacks (3D inserts, toolkit)
- Stores light states and generates array of states to display each frame
- Passes to Lampz for fade handling
- Wave-based effects with gradient palettes
- Mission Pinball Show Creator integration
Basic Setup¶
Initialize Controller¶
Register Lights¶
In InitLampsNF sub where Lampz MassAssign happens:
Note: Keep GI collection for mass assign. Turn all GI on with one command in light controller.
Blink Groups¶
Functions (v0.9.1+)¶
AddLightToBlinkGroup GroupName, Light
RemoveLightFromBlinkGroup GroupName, Light
UpdateBlinkGroupPattern GroupName, pattern
UpdateBlinkGroupInterval GroupName, interval
StartBlinkGroup GroupName
StopBlinkGroup GroupName
Works with existing sequences and pulse commands. Setup groups then start/stop as needed.
Use Case¶
Synchronize multiple lights blinking together: 1. Add lights to named blink group 2. Set pattern and interval 3. Start/stop group as unit
Wave-Based Effects¶
Gradient Palettes¶
- 0-255 color range
- Blend between colors using gradient stops
- Multiple wave functions
- NOT using VPX sequencer - all custom
Applications¶
- Rainbow waves
- Color transitions
- Multi-stop gradients
- Attract mode effects
- Special effects on original tables
Color Fading¶
Fade light to color feature: - Calculates colors between current and target - Fades to target over specified timeframe - Smooth color transitions on RGB inserts
Mission Pinball Show Creator Integration¶
Workflow¶
- Export light layout to Show Creator
- Create light shows in Show Creator (visual tool)
- Import result as YAML
- Parser converts to sequencer format
Show Creator¶
Visual tool for creating light shows with keyframes - much easier than manually coding sequences.
GitHub: https://github.com/missionpinball/showcreator
Tutorial Video: https://youtu.be/y2-qtPXdz7E?t=897
Integration with Lampz¶
Light State Controller works with Lampz system: - Stores light states internally - Generates state array each frame - Passes to Lampz for fade handling - Lampz handles callbacks to 3D inserts, toolkit, etc.
Control Light Method Alternative¶
When to Use Control Light Instead¶
- Table already has all light animations coded
- Retrofitting existing scripted table
- Don't want to refactor existing light code
How Control Light Works¶
- Sync Lampz to control light via GetInPlayState property
- Used in Game of Thrones and Blood Machines
- Less work for tables with existing animations
Comparison¶
Light State Controller: - Better for new tables - More powerful features - Requires building light logic from scratch
Control Light Method: - Better for existing tables - Less refactoring required - Works with standard VPX light sequences
Common Issues¶
LampTimer Not Enabled¶
Symptom: Lights not responding
Cause: LampTimer disabled
Fix: Ensure LampTimer is enabled in table
Attract Mode Continues¶
Symptom: Attract sequence continues after game start
Cause: Missing StopSyncWithVpxLights call
Fix: In EndAttractMode:
Implementation Examples¶
Basic Light Registration¶
' Initialize controller
Dim lController : Set lController = new LStateController
' In InitLampsNF sub
Sub InitLampsNF()
' Register lights with controller
lController.AddLight l1, 1
lController.AddLight l2, 2
lController.AddLight l3, 3
' Lampz MassAssign as usual
Lampz.MassAssign(1)=l1
Lampz.MassAssign(2)=l2
Lampz.MassAssign(3)=l3
End Sub
Blink Group Example¶
' Create blink group for lane lights
AddLightToBlinkGroup "LaneLights", l1
AddLightToBlinkGroup "LaneLights", l2
AddLightToBlinkGroup "LaneLights", l3
' Set pattern and interval
UpdateBlinkGroupPattern "LaneLights", "10101010"
UpdateBlinkGroupInterval "LaneLights", 100
' Start blinking
StartBlinkGroup "LaneLights"
' Later: stop blinking
StopBlinkGroup "LaneLights"
Best Practices¶
Starting Fresh vs Retrofitting¶
Light State Controller requires refactoring existing light code: - Starting new table: Use Light State Controller - Existing table with animations: Use Control Light method - Evaluate refactoring cost vs feature benefit
GI Management¶
Keep GI collection for mass operations: - Register with controller - Turn all GI on/off with single command - Maintains compatibility with toolkit
Integration Checklist¶
- [ ] LampTimer enabled
- [ ] Lights registered with controller AND Lampz
- [ ] StopSyncWithVpxLights in EndAttractMode
- [ ] Blink groups configured before starting
- [ ] Gradient palettes defined for effects
Advanced Features¶
Multiple States Per Light¶
Lights can have multiple named states: - Normal on/off - Flashing patterns - Color variations (RGB) - Custom sequences
Custom Sequences¶
Individual banks of lights can run custom sequences: - Independent timing - Different patterns - Coordinated effects
RGB Support¶
Full RGB control for inserts: - Multiple flashing shots in different colors - Color fading between states - Gradient palette effects - Wave animations
Technical Details¶
State Management¶
- Controller stores light states internally
- Generates state array each frame
- Passes to Lampz for rendering
- Lampz handles fade curves and callbacks
Performance¶
- Efficient state storage
- Minimal per-frame overhead
- Compatible with VPX physics loop
- Works with Lampz timer system
Community Resources¶
GitHub Repository: Full source code and documentation https://github.com/mpcarr/vpx-light-controller
Example Implementation: Blood Machines original table uses Light State Controller for complex RGB light shows
Show Creator Integration: Mission Pinball community tool for visual light show creation