StudioHow-toFor authorsApplies from 4.2.1
Language and objectives
Cette page en françaisThis page on the GitHub wiki
The Language tab shows the game as the tools see it: its objectives first, editable through forms generated from
their schema, then its IR, the game's logic as data with the file:line that writes each piece.
What you get
An objective added or changed in the game file from a form, previewed as a diff, validated before it is written; and the place in the code of every room, rule, topic, listener and script.
Context and versions
The local Studio, engine repository or created project. True from 4.2.1 (the write is judged before it is written). What objectives are and how a game uses them: Chapters and objectives.
Prerequisites
- The Studio running (overview).
- A game file with
defineGame({...}); a folder without one answersno defineGame({...}) in the game folder(404).
Where to run the commands
In the browser, on the Language tab. npm run ir runs in the engine repository.
Steps
- Read the objectives. Each with its id, title, condition (
done), parent, whether it is optional, and thefile:linethat writes it.
- Edit an objective, or + objective. The form is generated from the objective's schema
(
src/studio/forms-gen.ts): each field with its description, the parent's id with the game's objectives as suggestions, the condition with the DSL's editor. A problem is named by file, id and field before anything is sent.
- Preview the change shows the diff of the game file. Apply writes it: the server validates the game as it
would be, and refuses the write when it adds an error, so an objective whose
donecan never hold is refused. The validator's errors are shown after. The header's Undo takes an applied change back (Preview, apply, undo).
-
Read the IR. Under the objectives: the rooms, entities, rules, topics, listeners and scripts, each with where it is written, and the whole IR as JSON. The same JSON comes from the command line:
# in the engine repository npm run ir -- --json
Expected result, and how to check it
The objective appears in the list with its new file:line; git diff shows the change in the game file; the Check
tab still validates and solves.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| A field is named in red before sending | The form's own check (file, id, field) | Fix that field |
refused: the edit adds N validation error(s): … (422) | The objective breaks the game (a done that can never hold, an unknown parent) | Read the errors and change the objective |
400 on a path other than objectives | Only objectives are written in the game file | Edit other fields in code |
Files or data changed
The game file that holds defineGame({...}) (games/<id>/game.ts or where the game defines it).
Recovery or going back
The header's Undo, during the session; otherwise git.