Crate amble_script

Crate amble_script 

Source
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 .amble sources for game config, rooms, items, triggers, spinners, NPCs, and goals, catching unresolved references early.
  • Compile the DSL into WorldDef (RON) that the amble_engine crate 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§

ActionStmt
Top-level action statement with optional priority metadata.
ConsumableAst
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.
ItemAbilityAst
Single item ability entry declared within an item.
ItemAst
AST node describing an item definition.
ItemPatchAst
Data patch applied to an item when executing a modify item action.
NpcAst
AST node describing an NPC definition.
NpcDialoguePatchAst
NPC dialogue line update used inside a modify npc action.
NpcMovementAst
Movement configuration emitted for NPCs.
NpcMovementPatchAst
Movement configuration updates for an NPC.
NpcPatchAst
Data patch applied to an NPC when executing a modify npc action.
OverlayAst
Conditional overlay text applied to a room.
PlayerAst
Player definition contained inside the game block.
RoomAst
Minimal AST for a room definition. AST node describing a compiled room definition.
RoomExitPatchAst
Exit data emitted inside a modify room action patch.
RoomPatchAst
Data patch applied to a room when executing a modify room action.
ScoringAst
Scoring definition emitted from the DSL.
ScoringRankAst
Single scoring rank entry.
SpinnerAst
Spinner definition containing weighted text wedges.
SpinnerWedgeAst
Individual wedge (value + weight) inside a spinner.
TriggerAst
A minimal AST for a single trigger.

Enums§

ActionAst
Minimal action variants.
AstError
Errors that can happen when parsing the DSL input.
ConditionAst
Trigger condition variants.
ConsumableWhenAst
Behavior when a consumable item is depleted.
ContainerStateAst
Container states expressible in the DSL.
GoalCondAst
Conditions that can activate, complete, or fail a goal.
GoalGroupAst
Logical grouping for goals used when rendering score breakdowns.
IngestModeAst
Ingestion modes supported by the DSL; mirrors engine IngestMode.
ItemLocationAst
Possible item locations in the DSL.
MovabilityAst
Movability options for items, mirroring the engine Movability.
NpcLocationAst
Location specifier used for NPC placement.
NpcMovementTypeAst
Movement types supported for NPC definitions.
NpcStateValue
NPC state reference used in overlays and patches.
NpcTimingPatchAst
Movement timing update for an NPC.
OnFalseAst
Policy to apply when a scheduled condition evaluates to false at fire time.
OverlayCondAst
Overlay predicate used when computing room description variants.
WorldDefError
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.