{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://datin.dataobservatory.net/commands.json",
  "title": "Datin script",
  "description": "A Datin animation script. The player also accepts a bare array of commands. Play it at https://datin.dataobservatory.net/embed?j=<percent-encoded JSON>. Instructions: https://datin.dataobservatory.net/agent.md",
  "type": "object",
  "properties": {
    "version": {
      "const": 1
    },
    "name": {
      "type": "string",
      "maxLength": 80
    },
    "description": {
      "type": "string",
      "maxLength": 300
    },
    "loop": {
      "type": "boolean"
    },
    "outfit": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "hat": {
          "enum": [
            "top_hat",
            "baseball_cap",
            "party_hat",
            "crown",
            "beanie",
            "wizard_hat",
            "cowboy_hat",
            "propeller_cap",
            null
          ]
        },
        "glasses": {
          "enum": [
            "round_glasses",
            "sunglasses",
            "nerd_glasses",
            "3d_glasses",
            "heart_glasses",
            "monocle",
            null
          ]
        },
        "extra": {
          "enum": [
            "bow_tie",
            "mustache",
            "headphones",
            null
          ]
        }
      }
    },
    "proportions": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "armLength": {
          "type": "number",
          "minimum": 0.5,
          "maximum": 1.4
        },
        "armThickness": {
          "type": "number",
          "minimum": 0.5,
          "maximum": 1.6
        },
        "legLength": {
          "type": "number",
          "minimum": 0.5,
          "maximum": 2
        },
        "legThickness": {
          "type": "number",
          "minimum": 0.5,
          "maximum": 2
        }
      }
    },
    "commands": {
      "type": "array",
      "description": "\"parallel\": true runs a command together with the previous one; the first command must not be parallel.",
      "minItems": 1,
      "maxItems": 60,
      "items": {
        "anyOf": [
          {
            "type": "object",
            "description": "pose: Go to a named static pose (all joints).",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "pose"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "name": {
                "description": "Pose name.",
                "type": "string",
                "enum": [
                  "rest",
                  "wave_up",
                  "wave_up_L",
                  "point",
                  "point_L",
                  "arms_up",
                  "arms_out",
                  "sit",
                  "thinking",
                  "shrug_up",
                  "greet",
                  "walk_a",
                  "walk_b",
                  "wasted",
                  "facepalm",
                  "t_pose",
                  "zombie",
                  "flex",
                  "dab",
                  "disco_point",
                  "mic_drop",
                  "hands_on_hips",
                  "victory_v",
                  "shy",
                  "sneaky",
                  "robot",
                  "cheer",
                  "sleep_stand",
                  "fainting"
                ]
              }
            },
            "required": [
              "cmd",
              "name"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "setJoint: Rotate one joint (degrees, clamped to its limits) and leave it there.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "setJoint"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "joint": {
                "description": "Joint name.",
                "type": "string",
                "enum": [
                  "shoulder_L",
                  "elbow_L",
                  "wrist_L",
                  "hand_L",
                  "shoulder_R",
                  "elbow_R",
                  "wrist_R",
                  "hand_R",
                  "hip_L",
                  "knee_L",
                  "ankle_L",
                  "foot_L",
                  "hip_R",
                  "knee_R",
                  "ankle_R",
                  "foot_R"
                ]
              },
              "x": {
                "description": "Rotation about X in degrees.",
                "type": "number"
              },
              "y": {
                "description": "Rotation about Y in degrees.",
                "type": "number"
              },
              "z": {
                "description": "Rotation about Z in degrees.",
                "type": "number"
              }
            },
            "required": [
              "cmd",
              "joint"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "expression: Change the face expression.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "expression"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "name": {
                "description": "Expression name.",
                "type": "string",
                "enum": [
                  "neutral",
                  "happy",
                  "very_happy",
                  "surprised",
                  "thinking",
                  "sad",
                  "wink_L",
                  "wink_R",
                  "angry",
                  "sleepy",
                  "dead",
                  "dizzy"
                ]
              }
            },
            "required": [
              "cmd",
              "name"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "lookAt: Move the pupils (-1..1 each axis).",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "lookAt"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "x": {
                "description": "Horizontal gaze, -1..1.",
                "type": "number",
                "minimum": -1,
                "maximum": 1
              },
              "y": {
                "description": "Vertical gaze, -1..1.",
                "type": "number",
                "minimum": -1,
                "maximum": 1
              }
            },
            "required": [
              "cmd",
              "x",
              "y"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "wave: Wave one hand.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "wave"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "hand": {
                "description": "Which hand: \"L\" (Datin's left) or \"R\".",
                "type": "string",
                "enum": [
                  "L",
                  "R"
                ],
                "default": "R"
              },
              "times": {
                "description": "Number of wave oscillations.",
                "type": "integer",
                "minimum": 1,
                "maximum": 20,
                "default": 3
              }
            },
            "required": [
              "cmd"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "point: Point one arm at a world-space position.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "point"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "hand": {
                "description": "Which hand: \"L\" (Datin's left) or \"R\".",
                "type": "string",
                "enum": [
                  "L",
                  "R"
                ],
                "default": "R"
              },
              "target": {
                "description": "World position [x, y, z].",
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 3,
                "maxItems": 3
              }
            },
            "required": [
              "cmd",
              "target"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "walkTo: Turn toward a ground position, walk there, stop, return to idle.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "walkTo"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "x": {
                "description": "World X.",
                "type": "number",
                "minimum": -50,
                "maximum": 50
              },
              "z": {
                "description": "World Z.",
                "type": "number",
                "minimum": -50,
                "maximum": 50
              },
              "speed": {
                "description": "Units per second.",
                "type": "number",
                "minimum": 0.1,
                "maximum": 8,
                "default": 1.2
              }
            },
            "required": [
              "cmd",
              "x",
              "z"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "walk: Walk relative to Datin's facing without turning.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "walk"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "direction": {
                "description": "Direction in Datin's own frame (left = his left, +X when facing +Z).",
                "type": "string",
                "enum": [
                  "forward",
                  "back",
                  "left",
                  "right"
                ]
              },
              "distance": {
                "description": "World units.",
                "type": "number",
                "minimum": 0,
                "maximum": 50
              }
            },
            "required": [
              "cmd",
              "direction",
              "distance"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "turn: Turn in place. Positive = toward Datin's left.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "turn"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "degrees": {
                "description": "Degrees.",
                "type": "number",
                "minimum": -1440,
                "maximum": 1440
              }
            },
            "required": [
              "cmd",
              "degrees"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "jump: Crouch, jump, land with squash.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "jump"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "height": {
                "description": "Apex height in world units.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 3,
                "default": 0.6
              }
            },
            "required": [
              "cmd"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "nod: Nod yes.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "nod"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              }
            },
            "required": [
              "cmd"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "shake: Shake no.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "shake"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              }
            },
            "required": [
              "cmd"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "shrug: Shrug.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "shrug"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              }
            },
            "required": [
              "cmd"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "dance: Dance (default 4.5 s).",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "dance"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              }
            },
            "required": [
              "cmd"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "idle: Ease back to the idle pose (breathing loop resumes when the queue is empty).",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "idle"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              }
            },
            "required": [
              "cmd"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "reset: Rest pose, happy face, back to the origin facing front.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "reset"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              }
            },
            "required": [
              "cmd"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "say: Speech bubble + mouth flap while visible.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "say"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "text": {
                "description": "Text to show (max 500 chars).",
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              }
            },
            "required": [
              "cmd",
              "text"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "wait: Pause the script.",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "wait"
              },
              "duration": {
                "description": "Seconds.",
                "type": "number",
                "minimum": 0,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              }
            },
            "required": [
              "cmd",
              "duration"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "accessory: Wear or remove an accessory (hat, glasses, extra). Instant. name null/omitted/\"none\" removes the slot. (slot \"hat\")",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "accessory"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "slot": {
                "type": "string",
                "const": "hat",
                "description": "Accessory slot."
              },
              "name": {
                "enum": [
                  "top_hat",
                  "baseball_cap",
                  "party_hat",
                  "crown",
                  "beanie",
                  "wizard_hat",
                  "cowboy_hat",
                  "propeller_cap",
                  null
                ],
                "description": "Item to wear in the hat slot, or null to remove it."
              }
            },
            "required": [
              "cmd",
              "slot"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "accessory: Wear or remove an accessory (hat, glasses, extra). Instant. name null/omitted/\"none\" removes the slot. (slot \"glasses\")",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "accessory"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "slot": {
                "type": "string",
                "const": "glasses",
                "description": "Accessory slot."
              },
              "name": {
                "enum": [
                  "round_glasses",
                  "sunglasses",
                  "nerd_glasses",
                  "3d_glasses",
                  "heart_glasses",
                  "monocle",
                  null
                ],
                "description": "Item to wear in the glasses slot, or null to remove it."
              }
            },
            "required": [
              "cmd",
              "slot"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "accessory: Wear or remove an accessory (hat, glasses, extra). Instant. name null/omitted/\"none\" removes the slot. (slot \"extra\")",
            "properties": {
              "cmd": {
                "type": "string",
                "const": "accessory"
              },
              "duration": {
                "description": "Seconds. Rescales the command's motion to this length.",
                "type": "number",
                "minimum": 0.05,
                "maximum": 120
              },
              "parallel": {
                "description": "true = run together with the previous command.",
                "type": "boolean"
              },
              "slot": {
                "type": "string",
                "const": "extra",
                "description": "Accessory slot."
              },
              "name": {
                "enum": [
                  "bow_tie",
                  "mustache",
                  "headphones",
                  null
                ],
                "description": "Item to wear in the extra slot, or null to remove it."
              }
            },
            "required": [
              "cmd",
              "slot"
            ],
            "additionalProperties": false
          }
        ]
      }
    }
  },
  "required": [
    "commands"
  ]
}
