Expand description
amble_script – authoring-focused DSL, parser, and compiler for building
Amble worlds.
The crate powers the amble_script CLI but is fully usable as a library.
Major capabilities:
- Parse and lint
.amblesources for game config, rooms, items, triggers, spinners, NPCs, and goals, catching unresolved references early. - Compile the DSL into
WorldDef(RON) that theamble_enginecrate consumes. - Provide AST types so tooling can analyze or transform worlds before serialization.
ⓘ
use amble_script::{parse_program_full, worlddef_from_asts};
let src = r#"
game {
title "Demo"
intro "Welcome to the demo."
player {
name "The Candidate"
desc "a seasoned adventurer."
max_hp 20
start room foyer
}
}
room foyer {
name "Foyer"
desc "An inviting entryway."
}
"#;
let (game, triggers, rooms, items, spinners, npcs, goals) = parse_program_full(src).expect("valid DSL");
let worlddef = worlddef_from_asts(game.as_ref(), &triggers, &rooms, &items, &spinners, &npcs, &goals)
.expect("compiles");
let ron = ron::ser::to_string_pretty(&worlddef, ron::ser::PrettyConfig::default()).expect("serializes");
println!("{ron}");For a full language tour see amble_script/docs/dsl_creator_handbook.md in
the repository.
Structs§
- Action
Stmt - Top-level action statement with optional priority metadata.
- Consumable
Ast - Consumable configuration attached to an item.
- ExitAst
- Connection between rooms emitted within a room AST.
- GameAst
- Game-level configuration AST.
- GoalAst
- High-level representation of a single goal definition in the DSL.
- Item
Ability Ast - Single item ability entry declared within an item.
- ItemAst
- AST node describing an item definition.
- Item
Patch Ast - Data patch applied to an item when executing a
modify itemaction. - NpcAst
- AST node describing an NPC definition.
- NpcDialogue
Patch Ast - NPC dialogue line update used inside a
modify npcaction. - NpcMovement
Ast - Movement configuration emitted for NPCs.
- NpcMovement
Patch Ast - Movement configuration updates for an NPC.
- NpcPatch
Ast - Data patch applied to an NPC when executing a
modify npcaction. - Overlay
Ast - Conditional overlay text applied to a room.
- Player
Ast - Player definition contained inside the game block.
- RoomAst
- Minimal AST for a room definition. AST node describing a compiled room definition.
- Room
Exit Patch Ast - Exit data emitted inside a
modify roomaction patch. - Room
Patch Ast - Data patch applied to a room when executing a
modify roomaction. - Scoring
Ast - Scoring definition emitted from the DSL.
- Scoring
Rank Ast - Single scoring rank entry.
- Spinner
Ast - Spinner definition containing weighted text wedges.
- Spinner
Wedge Ast - Individual wedge (value + weight) inside a spinner.
- Trigger
Ast - A minimal AST for a single trigger.
Enums§
- Action
Ast - Minimal action variants.
- AstError
- Errors that can happen when parsing the DSL input.
- Condition
Ast - Trigger condition variants.
- Consumable
When Ast - Behavior when a consumable item is depleted.
- Container
State Ast - Container states expressible in the DSL.
- Goal
Cond Ast - Conditions that can activate, complete, or fail a goal.
- Goal
Group Ast - Logical grouping for goals used when rendering score breakdowns.
- Ingest
Mode Ast - Ingestion modes supported by the DSL; mirrors engine
IngestMode. - Item
Location Ast - Possible item locations in the DSL.
- Movability
Ast - Movability options for items, mirroring the engine
Movability. - NpcLocation
Ast - Location specifier used for NPC placement.
- NpcMovement
Type Ast - Movement types supported for NPC definitions.
- NpcState
Value - NPC state reference used in overlays and patches.
- NpcTiming
Patch Ast - Movement timing update for an NPC.
- OnFalse
Ast - Policy to apply when a scheduled condition evaluates to false at fire time.
- Overlay
Cond Ast - Overlay predicate used when computing room description variants.
- World
DefError - Errors emitted while lowering AST data into the WorldDef model.
Functions§
- parse_
goals - Parse only goal definitions from the given source.
- parse_
items - Parse only items from a source (helper/testing). Parse only item definitions from the given source.
- parse_
npcs - Parse only npcs from a source (helper/testing). Parse only NPC definitions from the given source.
- parse_
program - Parse multiple triggers from a full source file (triggers only view).
- parse_
program_ full - Parse a full program returning triggers, rooms, items, and spinners.
- parse_
rooms - Parse only rooms from a source (helper/testing). Parse only room definitions from the given source.
- parse_
spinners - Parse only spinners from a source (helper/testing). Parse only spinner definitions from the given source.
- parse_
trigger - Parse a single trigger source string; returns the first trigger found.
- worlddef_
from_ asts - Convert parsed AST collections into a serialized
WorldDef.