Co-authored by:
- Tiki Taka tt@ii.coop
- Hippie Hacker hh@ii.coop
We use two separate mods for crash resilience:
| Mod | Purpose | If 0aid crashes... |
|---|---|---|
0aid |
AI assist logic | Disables itself |
zeroab |
Toggle button UI | Still works! |
This way, if you break 0aid.js, the button still works to re-enable it.
/var/srv/0aid/
├── mod.json # 0aid mod metadata
├── gui/
│ └── session/
│ └── 0aid.js # Main AI assist code
├── zeroab/ # Separate button mod
│ ├── mod.json
│ └── gui/
│ └── session/
│ ├── zeroab.js # Button logic
│ └── zeroab.xml # Button UI
├── autociv/ # Reference: autociv mod patterns
├── extracted/ # Reference: extracted 0 A.D. components
└── layout.md # This file
flatpak override --user --filesystem=/var/srv/0aid com.play0ad.zeroad# Main mod
ln -sfn /var/srv/0aid ~/.var/app/com.play0ad.zeroad/data/0ad/mods/0aid
# Button mod
ln -sfn /var/srv/0aid/zeroab ~/.var/app/com.play0ad.zeroad/data/0ad/mods/zeroabgit config --global --add safe.directory /var/srv/0aidflatpak run com.play0ad.zeroad- Main Menu -> Settings -> Mod Selection
- Enable both "0aid" and "Zero AI Button"
- Click "Save Configuration"
- Restart when prompted
- Start a single-player game
- Console shows:
[0aid] Loaded!and[zeroab] Loaded! - Button appears in top-right showing "0aid: ON"
- Click button to toggle, or use console commands
0aid.jswraps its main loop in try/catch- If an error occurs, it logs it and increments error count
- After 3 errors, 0aid disables itself
- The game keeps running!
- Fix your code, then re-enable via button or console
| Error Type | What Happens | Recovery |
|---|---|---|
| Runtime error | 0aid catches it, logs, may disable | Click button or zeroaid_Enable() |
| Syntax error | JS won't parse, mod fails to load | Fix code, hot-reload retries |
| Infinite loop | Game freezes | Must restart game |
zeroaid_Enable() // Re-enable after errors
zeroaid_Disable() // Turn off
zeroaid_Toggle() // Toggle on/off
zeroaid_ToggleAuto() // Toggle auto-assign villagersEdit gui/session/0aid.js while playing - changes reload automatically!
- Keep game running
- Edit code in your editor
- Save file
- Check console (F9) for errors
- If errors, fix and save again
- If disabled, click button to re-enable
When using Zed's real-time collaboration:
- Both see edits instantly in the editor
- Files save to the host's machine only
- Whoever runs the game sees hot-reload
- Commit & push so other machine can pull
Workflow:
- Host shares Zed project
- Both edit together
- Host tests in-game
- Commit & push when working
- Other machine:
git pull
- 0 A.D. Mod Guide: https://trac.wildfiregames.com/wiki/Modding_Guide
- autociv mod:
./autociv/(patterns for error handling, UI) - Extracted components:
./extracted/(ResourceGatherer, UnitAI)