Outils pour utilisateurs

Outils du site


en:yaml:modeles

Ceci est une ancienne révision du document !


Language / Langue : FR | EN

Models (YAML)

A model contains reusable rooms. Each instance binds its variable and exit names to those of the scenario.

Example: a healing room

This scenario opens the model, lets the player heal, then returns to the calling room's choices.

title: Infirmary
vars:
  hp: 10
models:
  healing:
    variables:
      health: 0
    rooms:
      - id: sheet
        text: 'Health: v_health_v'
        auto_refresh: true
        actions:
          - verb: heal
            target: all
            button: Heal
            do: health + 5
        choices:
          - button: Leave
            to: end_model
rooms:
  - id: start
    text: You enter the infirmary.
    models:
      - model: healing
        variables:
          health: hp
    choices:
      - button: Finish
        to: victory

The models: definitions are keyed by name, here healing. The start room contains a list of instances: model: healing selects the definition and health: hp binds its generic variable to hp, declared in the scenario.

Internal rooms receive a prefix to avoid ID collisions. end_model resumes after the model: here, the Finish choice becomes available. A generic exit declared in exits: can also be bound to a scenario room in the instance.

Bound lists and collections (4.17)

A model can declare generic lists and collections. Bind them to scenario data in the instance, without copying:

lists:
  products: world.shop.bag
collections:
  hero: world.state

Targets must exist. Paths cross collections only, without list indices. Required properties are checked when a parent is replaced or a saved game is resumed.

See Lists and collections, Tags and Events.

en/yaml/modeles.1792359967.txt.gz · Dernière modification : de cyrilfiesta