Game Website: Caves of Qud
Official Twitter/X: @cavesofqud
Qud State Extractor is a Harmony-based mod for Caves of Qud that logs all in-game player messages and player state to disk in plaintext and JSON formats.
- Copy the template:
cp .env.template .env-
Update
BASE_FILE_PATHand any per-file output paths. -
Keep
ENABLE_VERBOSE_LOGS=falsefor normal play. Set it totrueonly when troubleshooting.
core/EnvHelper.cs locates .env in the mod root (not ModAssemblies/) and expands variables like ${HOME} and ${BASE_FILE_PATH}.
- Copy this mod folder into your Qud
Mods/directory. - Keep the
.cssource files in place (core/exporters/patches/scrapers). - Launch the game; Qud compiles source mods at runtime into
ModAssemblies/.
You can precompile a DLL locally with either:
./build.sh /path/to/CavesOfQudor:
export CAVES_OF_QUD_DIR=/path/to/CavesOfQud
./build.shThe script validates required references in:
$GAME_DIR/CoQ_Data/Managed/
Assembly-CSharp.dll0Harmony.dllUnityEngine.CoreModule.dll
Output DLL:
ModAssemblies/QudStateExtractor.dll
For deployment, copy ModAssemblies/QudStateExtractor.dll into your mod folder’s ModAssemblies/ directory in the Qud Mods/ path.
All Unity logging is routed through core/Log.cs:
Log.Info(...): verbose-only, gated byENABLE_VERBOSE_LOGS=trueLog.Warn(...): always loggedLog.Error(...): always logged
This keeps normal gameplay logs quiet while preserving warnings/errors.
core/QudStateExtractorInit.cs: Harmony mod bootstrap that initializes env/config and applies patches.core/ReflectionHelpers.cs: shared reflection helpers for safe property/field/method access against Qud runtime objects.core/EnvHelper.cs:.envloader and variable expansion.core/Log.cs: centralized Unity logging wrapper with verbose gating.core/ExportWriter.cs: shared JSON read/write helpers for exporter output paths from.env.
exporters/UIStateExporter.cs: emitscurrent_view.jsonsnapshots describing active UI/game view state.exporters/GameStateExporters.cs: exports player/world/quest/journal/dialogue/POI state snapshots.exporters/MenuExporters.cs: exports menu-oriented snapshots (ability, equipment, skills, status, tinkering, pick-item, trade).exporters/MergeHelpers.cs: merges scraped quick-key/bottom-bar data into exporter JSON records.- Dependency flow: scrapers gather window/menu/key data,
MergeHelpersaligns it to export rows, and all final writes go throughcore/ExportWriter.cs. - Export logs are summary-only in verbose mode; failures are emitted as errors.
patches/CoreLifecyclePatches.cs: hooks core lifecycle/game events (startup, stats, quests, dialogue, player message queue) and triggersGameStateExportersoutputs.patches/MenuScreenPatches.cs: hooks menu/screen lifecycles (ability, equipment, skills, status, tinkering, trade, nearby items) and drivesMenuExportersplusMergeHelpersupdates.patches/StatusScreensHubPatch.cs: hooks modernStatusScreensScreenhub/tab updates and routes bottom-bar + quick-key merges for skills/status/equipment/tinkering exports.patches/DialogueAndPopupPatches.cs: hooks popup/dialog-style UI and pick-item flows to export popup payloads and pick-screen menu/key data.patches/UIStatePatches.cs: hooksUIManager.Updateand triggersUIStateExporter.ExportCurrentView()to keepcurrent_view.jsonin sync with active UI state.- Patch flow: Harmony hooks -> scraper capture (
QuickKeyScraper/BottomBarScraper) -> merge/export (MergeHelpers/MenuExporters/GameStateExporters) ->ExportWriter. - Patch logging is failure-focused with no per-call informational spam.
scrapers/WindowScraper.cs: resolves the current modern UI window component for downstream exporters/scrapers.scrapers/BottomBarScraper.cs: extracts normalized bottom-bar actions (text/hotkey) from active windows for exporter payloads.scrapers/QuickKeyScraper.cs: extracts per-row quick-key bindings and related identifiers (for abilities/items/equipment lists).scrapers/MenuItemHelpers.cs: shared menu-option normalization/dedup and command-to-hotkey resolution used by scraper pipelines.scrapers/StringHelpers.cs: strips Qud markup from scraped UI text before export.- Usage: exporters can call
WindowScraper.GetCurrentWindow()and pass the result toBottomBarScraper.ScrapeFromWindow(...)when building UI snapshots.
core/MiniJSON.csis a vendored MiniJSON implementation (Calvin Rien, MIT license) used for lightweight JSON parsing/serialization.- The original license header is preserved in the source file.
.envmust exist and be correctly formatted- Currently Linux-only (Windows support untested)
MIT-style. Fork it, adapt it, use it.
Created by: piestyx First released: 2025-06-24
