- Created a generic NPC script with conversation handling. - Developed an Alice NPC script demonstrating branching dialogue and state tracking. - Implemented a test NPC script for development purposes. - Added JSON representations for the NPC scripts. - Created an HTML test interface for NPC integration testing. - Included event handling and bark systems for NPC interactions.
2.4 KiB
Test Harness Fixes - October 29, 2025
Issues Resolved
1. Duplicate Class Declaration
Error: Uncaught SyntaxError: Identifier 'InkEngine' has already been declared
Cause: The ink-engine.js file had two export class InkEngine declarations - the minimal test version and a duplicate from planning code.
Fix: Removed the duplicate class declaration (lines 84-410) leaving only the minimal test-compatible InkEngine wrapper.
2. Script Load Order
Error: window.InkEngine is not a constructor
Cause: The module script was trying to call the log() function before it was defined in the subsequent script block.
Fix: Reorganized test-npc-ink.html script blocks:
- Load ink.js library
- Define helper functions (log, updateStatus)
- Load ES modules and initialize systems
- Define test functions
3. System Initialization
Error: Multiple "Cannot read properties of undefined" errors for npcEvents, npcManager, npcBarkSystem
Cause: The initialization code in the module block was running before the log function existed, preventing proper initialization and error reporting.
Fix: Moved the log function definition before the module imports, ensuring proper initialization order.
Files Modified
js/systems/ink/ink-engine.js
- Removed duplicate class declaration (lines 84-410)
- Kept only minimal InkEngine wrapper with methods: loadStory, continue, goToKnot, choose, getVariable, setVariable
- Properties: currentText, currentChoices
test-npc-ink.html
- Reordered script blocks for proper initialization
- log() and updateStatus() now defined before module imports
- Module script can now safely call log() during initialization
Current State
All modules now properly:
- Export default classes as expected by test harness
- Initialize without errors
- Have methods callable from test buttons
The test page should now:
- Load ink.js library ✓
- Initialize all NPC systems ✓
- Allow story loading and interaction ✓
- Support event emission and barks ✓
- Allow NPC registration ✓
Next Steps
Test the page by:
- Serve the repo:
python3 -m http.server 8000 - Open: http://localhost:8000/test-npc-ink.html
- Click through test buttons in order
- Verify console shows "✅ Systems initialized" on page load
- Load test story and interact with it
If all tests pass, proceed to:
- Wire bark click → phone minigame integration
- Implement event cooldowns
- Add automatic event → knot mapping for NPCs