Read-only demo.Generated sample data. Changes cannot be saved.

inventory_craft

inventory_craft POST YAML steps Enabled Public

Calls this month
0
Errors
0
Error rate
No calls yet
Avg response
No calls yet

This month, UTC.

Definition preview

Read-only outline of the saved source. Edit it under the Edit tab.

Input fields

recipe_id
string

Pipeline (4)

  1. player read collection inventory_state
  2. recipe lookup table inventory_recipes
  3. has_materials condition
  4. craft write collection inventory_state

Response

Status
200
Body
keys: success, crafted
Full source
sourceVersion: 1
kind: endpoint
id: inventory_craft
name: Craft item
description: Spends recipe materials and adds the crafted item. Missing ingredients fail with MISSING_MATERIALS.
method: POST
enabled: true
input:
  type: object
  properties:
    recipe_id:
      type: string
  required:
  - recipe_id
steps:
- id: player
  type: read
  collection: inventory_state
  key: '{{steamId}}'
- id: recipe
  type: lookup
  source: values
  table: inventory_recipes
  where:
    field: recipe_id
    op: ==
    value: '{{input.recipe_id}}'
  required: true
  onMissing:
    status: 404
    errorCode: UNKNOWN_RECIPE
    message: Unknown recipe {{input.recipe_id}}.
- id: has_materials
  type: condition
  check:
    field: player.materials.{{recipe.material}}
    op: '>='
    value: '{{recipe.material_cost}}'
  onFail:
    status: 400
    error: MISSING_MATERIALS
    message: You need {{recipe.material_cost}} {{recipe.material}}.
- id: craft
  type: write
  collection: inventory_state
  key: '{{steamId}}'
  ops:
  - op: inc
    path: materials.{{recipe.material}}
    value: '{{-recipe.material_cost}}'
    source: crafting
    reason: Crafted {{recipe.output_name}}
  - op: push
    path: inventory
    value:
      item_id: '{{recipe.output_item}}'
      name: '{{recipe.output_name}}'
response:
  status: 200
  body:
    success: true
    crafted: '{{recipe.output_name}}'
module: inventory

New endpoint

Choose an id using letters, numbers, underscore or hyphen. A fresh draft opens with this id; nothing is published until you save.

Confirm