Skip to content

Steps that do it ​

Build the steps of alta.quests/0.3 (inputs, run, check, human) and check them alone, before they go into a quest.

Example ​

example.mjs
js
// Build steps that do it (alta.quests/0.3) and check them alone, before they go into a quest.
import { actionStep, executorParams, fromInput, humanStep, stepProblems } from "@altasystem/sdk";

console.log(executorParams("channel.connect").map(p => `${p.name}:${p.kind}`).join(" "));

const connect = actionStep({
  id: "connect",
  title: { en: "Connect Telegram", fr: "Branche Telegram" },
  inputs: [{ id: "token", kind: "secret", label: { en: "Bot token", fr: "Jeton du bot" } }],
  run: "channel.connect",
  args: { channel: "telegram", token: fromInput("token") },
  check: { type: "channel", id: "telegram" },
});
const hello = humanStep({ id: "hello", title: { en: "Say hello from your phone", fr: "Dis bonjour depuis ton téléphone" }, human: "device", provenBy: "connect" });

console.log(stepProblems([connect, hello]).length);

connect.inputs[0].saves = "answers.token";
for (const p of stepProblems([connect, hello])) console.log(p.rule, p.context?.hint);

examples/sdk/steps.mjs

Run it from a folder where the package is installed: node example.mjs.

Output
text
channel:choice token:secret
0
step.input-secret remove "saves" from this input: the player types a secret each time, and the program keeps it in its own store

Functions ​

actionStep ​

ts
function actionStep(o: ActionStepOptions): Step

A step the game does: inputs (a form in the plan card) → run → a read-only check.

humanStep ​

ts
function humanStep(o: HumanStepOptions): Step

A step only the player can do, with why (human), and how the game still helps (a helper, a proof).

fromInput ​

ts
const fromInput = (id: string): { input: string }

{ "input": id }: the value of one of the step's inputs.

fromAnswer ​

ts
const fromAnswer = (key: string): { answer: string }

{ "answer": "answers.<key>" }: an answer already given (the prefix is added when missing).

stepProblems ​

ts
function stepProblems(steps: Step | Step[]): Problem[]

The problems of steps on their own: they are put in one quest of a 0.3 fragment and checked with the same rules as alta lint (no game needed). provenBy may name any of the steps given.

executorParams ​

ts
function executorParams(id: string): ParamInfo[] | undefined

The arguments an executor takes from a step's run.args, in order. Undefined for an unknown executor.

executorTable ​

ts
function executorTable(): (ExecutorInfo & { does: string; params: ParamInfo[] })[]

The executors as a table: each executor of the closed list, with what it does in one sentence and its arguments.

See also ​

Alta OS is open source (MIT).