storescript.* (StoreTrainer) & crossroads.* (Story Crossroads)
RaggieScript v1.3 brings first-class, RSW702 capability-sandboxed domain profiles to two flagship RaggieSoft consumer experiences: StoreScript (use storescript;) for RaggieSoft StoreTrainer, and Story Crossroads (use crossroads;) for interactive branching novels in RaggieSoft Book Reader and https://crossroads.raggiesoft.com.
storescript.* — StoreScript Save-File & Config Trainer DSL (20 Methods)
Origin Story: Hello, StoreScript!
Long before RaggieScript unified all eight RaggieSoft Studio developer tools, Michael P. Ragsdale envisioned StoreScript as a dedicated scripting language for RaggieSoft StoreTrainer (storetrainer.raggiesoft.com—originally created in the pre-AI Visual Basic 6.0 TStore.vbp era as an offline single-player PC game save-file and trainer utility).
In RaggieScript v1.3, StoreScript is officially part of RaggieScript:
- The host application (StoreTrainer on
.NETviaRsscManagedRuntime.StoreScriptor C++20 viaRaggieScriptVm::LoadStoreScriptBuffer) loads only the single save file or JSON configuration explicitly selected by the user into an isolated in-memory workspace. - StoreScript provides automatic undo snapshots (
storescript.backupSave/restoreBackup), wildcard hex-signature scanning ("43 52 45 44 ?? ??"), bounds-checked and min/max-clamped little-endian binary reads/writes (U8,I16LE,I32LE,F32LE,Ascii), IEEE 802.3 CRC-32 save-checksum recalculation (crc32Range), and dot-path JSON config editing (getJson/setJson).
Complete storescript.* API Reference
| Method | Signature | Return | Description |
|---|---|---|---|
storescript.profile | storescript.profile(id: string, title?: string, saveGlob?: string) | map | Declares trainer metadata ({ id, title, saveGlob }) for StoreTrainer's library shelf. |
storescript.backupSave | storescript.backupSave(tag?: string) | string | Captures an instant snapshot of the active save buffer and returns its backupId. |
storescript.restoreBackup | storescript.restoreBackup(backupId?: string) | bool | Restores the active save buffer from backupId (or the most recent snapshot when omitted). |
storescript.size | storescript.size() | int | Returns the byte length of the active binary save buffer. |
storescript.readU8 | storescript.readU8(offset: int) | int | Reads an unsigned 8-bit integer (0..255) at offset (bounds-checked). |
storescript.writeU8 | storescript.writeU8(offset: int, value: int, min?: int, max?: int) | bool | Clamps value to [min, max] (0..255) and writes 1 byte at offset. |
storescript.readI16LE | storescript.readI16LE(offset: int) | int | Reads a signed 16-bit little-endian integer (-32768..32767) at offset. |
storescript.writeI16LE | storescript.writeI16LE(offset: int, value: int, min?: int, max?: int) | bool | Clamps value and writes a 16-bit little-endian integer at offset. |
storescript.readI32LE | storescript.readI32LE(offset: int) | int | Reads a signed 32-bit little-endian integer at offset. |
storescript.writeI32LE | storescript.writeI32LE(offset: int, value: int, min?: int, max?: int) | bool | Clamps value to [min, max] and writes a 32-bit little-endian integer at offset. |
storescript.readU32LE | storescript.readU32LE(offset: int) | int | Reads an unsigned 32-bit little-endian integer (0..4294967295) at offset. |
storescript.writeU32LE | storescript.writeU32LE(offset: int, value: int, min?: int, max?: int) | bool | Clamps value (0..4294967295) and writes an unsigned 32-bit little-endian integer (ideal for CRC-32 checksums). |
storescript.readF32LE | storescript.readF32LE(offset: int) | float | Reads a 32-bit IEEE 754 little-endian float at offset. |
storescript.writeF32LE | storescript.writeF32LE(offset: int, value: float, min?: float, max?: float) | bool | Clamps value and writes a 32-bit IEEE 754 little-endian float at offset. |
storescript.readAscii | storescript.readAscii(offset: int, maxLen: int) | string | Reads a null-padded fixed-width ASCII string of up to maxLen bytes at offset. |
storescript.writeAscii | storescript.writeAscii(offset: int, text: string, maxLen?: int) | bool | Writes text at offset and zero-pads any remaining bytes up to maxLen. |
storescript.findPatternHex | storescript.findPatternHex(patternHex: string, startOffset?: int) | int | Scans the save buffer for a hex byte signature supporting ?? wildcards ("43 52 45 44 ?? ??"); returns 0-based byte offset or -1. |
storescript.crc32Range | storescript.crc32Range(startOffset?: int, length?: int) | int | Computes standard unsigned IEEE 802.3 CRC-32 over [startOffset, startOffset + length) so patched saves pass integrity checks! |
storescript.getJson | storescript.getJson(dotPath: string, fallback?: any) | any | Reads a nested key ("audio.subtitleScale") from the loaded JSON save/config document. |
storescript.setJson | storescript.setJson(dotPath: string, value: any) | bool | Updates or creates a nested dot-path key inside the loaded JSON save/config document. |
use storescript;
const meta = storescript.profile("cedar-run-tactics", "Cedar Run Tactics — Save Utility", "*.sav");
fn applyCreditsBoost(requestedCredits: int) : map {
const snap = storescript.backupSave("pre-credits");
const sigOffset = storescript.findPatternHex("43 52 45 44 ?? ??");
if (sigOffset < 0) {
return { ok: false, reason: "Signature not found" };
}
// Write clamped 32-bit little-endian credits right after the 6-byte header
storescript.writeI32LE(sigOffset + 6, requestedCredits, min: 0, max: 999999);
// Recompute IEEE CRC-32 over payload bytes [4..size) and store at offset 0
const crc = storescript.crc32Range(4, storescript.size() - 4);
storescript.writeU32LE(0, crc);
return { ok: true, backupId: snap, newCredits: storescript.readI32LE(sigOffset + 6), crc32: crc };
}
crossroads.* — RaggieSoft Story Crossroads Interactive Novel Engine (8 Methods)
RaggieSoft Story Crossroads (crossroads.raggiesoft.com, in-universe Architects: Rowan & Iris Hawthorne) is RaggieSoft's independent interactive-fiction imprint. A single use crossroads; .rssc file executes natively inside RaggieSoft Book Reader (.NET) and compiles via raggiescript.exe transpile-es2022 (or RsscEs2022Transpiler.TryTranspile) into a zero-eval() ES2022 JavaScript module for the web!
| Method | Signature | Return | Targets | Description |
|---|---|---|---|---|
crossroads.visit | crossroads.visit(nodeId: string) | int | C++20, .NET, ES2022 | Marks narrative route node nodeId visited and returns the updated visit count (1 on first visit). |
crossroads.visited | crossroads.visited(nodeId: string) | bool | C++20, .NET, ES2022 | Returns true if the reader has previously visited nodeId. |
crossroads.visitCount | crossroads.visitCount(nodeId: string) | int | C++20, .NET, ES2022 | Returns how many times the reader has visited nodeId. |
crossroads.setFlag | crossroads.setFlag(key: string, value?: any) | bool | C++20, .NET, ES2022 | Stores a persistent branching narrative flag (value defaults to true). |
crossroads.getFlag | crossroads.getFlag(key: string, fallback?: any) | any | C++20, .NET, ES2022 | Reads narrative flag key (or fallback, default false). |
crossroads.adjustStat | crossroads.adjustStat(statKey: string, delta: int, min?: int, max?: int) | int | C++20, .NET, ES2022 | Adds delta to statKey, clamps within [min, max], and returns the updated value. |
crossroads.offerOption | crossroads.offerOption(label: string, targetNode: string, enabled?: bool, note?: string) | bool | C++20, .NET, ES2022 | Registers an interactive route option card ({ label, target, enabled, note }) for the current scene. |
crossroads.options | crossroads.options() | array | C++20, .NET, ES2022 | Returns all offered route option maps for the active Story Crossroads scene. |
use crossroads;
fn evaluateKeystoneBridgeScene(hasLanternKey: bool) : array {
const visits = crossroads.visit("cpi-keystone-bridge-dusk");
if (hasLanternKey) {
crossroads.setFlag("unlockedArchivistVault", true);
}
crossroads.offerOption(
"Inspect the Ironstone keystone inscription with Iris",
"cpi-pendleton-archive",
true,
visits > 1 ? "Revisit with new clues" : "First inspection"
);
crossroads.offerOption(
"Unlock the lower Commonwealth Mall lantern passage",
"cpi-lantern-vault",
crossroads.getFlag("unlockedArchivistVault", false) == true,
"Requires the Archivist's brass lantern key"
);
return crossroads.options();
}
storescript.profile / backupSave / restoreBackup / sizeStoreScript
storescript.readU8 / writeU8 / readI16LE / writeI16LE / readI32LE / writeI32LE / readU32LE / writeU32LE / readF32LE / writeF32LEStoreScript
storescript.findPatternHex / crc32Range / readAscii / writeAscii / getJson / setJsonStoreScript
crossroads.visit / visited / visitCount / setFlag / getFlag / adjustStat / offerOption / optionsStory Crossroads