Apply a scenario to a fork
curl --request POST \
--url http://localhost:3917/fork/{id}/scenario \
--header 'Content-Type: application/json' \
--data '
{
"entities": [
{
"health": 100,
"position": [
-3,
1,
0
],
"team": 1
},
{
"health": 60,
"position": [
3,
1,
0
],
"team": 2
}
],
"name": "demo",
"rules": [
{
"actions": [
{
"action": "heal",
"amount": 20,
"target": "this"
}
],
"filter": "any",
"when": {
"kind": "health_below",
"threshold": 50
}
}
],
"version": 2
}
'import requests
url = "http://localhost:3917/fork/{id}/scenario"
payload = {
"entities": [
{
"health": 100,
"position": [-3, 1, 0],
"team": 1
},
{
"health": 60,
"position": [3, 1, 0],
"team": 2
}
],
"name": "demo",
"rules": [
{
"actions": [
{
"action": "heal",
"amount": 20,
"target": "this"
}
],
"filter": "any",
"when": {
"kind": "health_below",
"threshold": 50
}
}
],
"version": 2
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
entities: [
{health: 100, position: [-3, 1, 0], team: 1},
{health: 60, position: [3, 1, 0], team: 2}
],
name: 'demo',
rules: [
{
actions: [{action: 'heal', amount: 20, target: 'this'}],
filter: 'any',
when: {kind: 'health_below', threshold: 50}
}
],
version: 2
})
};
fetch('http://localhost:3917/fork/{id}/scenario', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3917",
CURLOPT_URL => "http://localhost:3917/fork/{id}/scenario",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'entities' => [
[
'health' => 100,
'position' => [
-3,
1,
0
],
'team' => 1
],
[
'health' => 60,
'position' => [
3,
1,
0
],
'team' => 2
]
],
'name' => 'demo',
'rules' => [
[
'actions' => [
[
'action' => 'heal',
'amount' => 20,
'target' => 'this'
]
],
'filter' => 'any',
'when' => [
'kind' => 'health_below',
'threshold' => 50
]
]
],
'version' => 2
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:3917/fork/{id}/scenario"
payload := strings.NewReader("{\n \"entities\": [\n {\n \"health\": 100,\n \"position\": [\n -3,\n 1,\n 0\n ],\n \"team\": 1\n },\n {\n \"health\": 60,\n \"position\": [\n 3,\n 1,\n 0\n ],\n \"team\": 2\n }\n ],\n \"name\": \"demo\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"action\": \"heal\",\n \"amount\": 20,\n \"target\": \"this\"\n }\n ],\n \"filter\": \"any\",\n \"when\": {\n \"kind\": \"health_below\",\n \"threshold\": 50\n }\n }\n ],\n \"version\": 2\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:3917/fork/{id}/scenario")
.header("Content-Type", "application/json")
.body("{\n \"entities\": [\n {\n \"health\": 100,\n \"position\": [\n -3,\n 1,\n 0\n ],\n \"team\": 1\n },\n {\n \"health\": 60,\n \"position\": [\n 3,\n 1,\n 0\n ],\n \"team\": 2\n }\n ],\n \"name\": \"demo\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"action\": \"heal\",\n \"amount\": 20,\n \"target\": \"this\"\n }\n ],\n \"filter\": \"any\",\n \"when\": {\n \"kind\": \"health_below\",\n \"threshold\": 50\n }\n }\n ],\n \"version\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3917/fork/{id}/scenario")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"entities\": [\n {\n \"health\": 100,\n \"position\": [\n -3,\n 1,\n 0\n ],\n \"team\": 1\n },\n {\n \"health\": 60,\n \"position\": [\n 3,\n 1,\n 0\n ],\n \"team\": 2\n }\n ],\n \"name\": \"demo\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"action\": \"heal\",\n \"amount\": 20,\n \"target\": \"this\"\n }\n ],\n \"filter\": \"any\",\n \"when\": {\n \"kind\": \"health_below\",\n \"threshold\": 50\n }\n }\n ],\n \"version\": 2\n}"
response = http.request(request)
puts response.read_body{
"assertions": 0,
"entities_spawned": 3,
"fork_id": "fork-1",
"ok": true,
"rules": 1,
"templates": 0
}Scenes and scenarios
Apply a scenario to a fork
apply a scenario to a fork. Wipes the fork’s current state and loads the scenario fresh; the main world is untouched.
POST
/
fork
/
{id}
/
scenario
Apply a scenario to a fork
curl --request POST \
--url http://localhost:3917/fork/{id}/scenario \
--header 'Content-Type: application/json' \
--data '
{
"entities": [
{
"health": 100,
"position": [
-3,
1,
0
],
"team": 1
},
{
"health": 60,
"position": [
3,
1,
0
],
"team": 2
}
],
"name": "demo",
"rules": [
{
"actions": [
{
"action": "heal",
"amount": 20,
"target": "this"
}
],
"filter": "any",
"when": {
"kind": "health_below",
"threshold": 50
}
}
],
"version": 2
}
'import requests
url = "http://localhost:3917/fork/{id}/scenario"
payload = {
"entities": [
{
"health": 100,
"position": [-3, 1, 0],
"team": 1
},
{
"health": 60,
"position": [3, 1, 0],
"team": 2
}
],
"name": "demo",
"rules": [
{
"actions": [
{
"action": "heal",
"amount": 20,
"target": "this"
}
],
"filter": "any",
"when": {
"kind": "health_below",
"threshold": 50
}
}
],
"version": 2
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
entities: [
{health: 100, position: [-3, 1, 0], team: 1},
{health: 60, position: [3, 1, 0], team: 2}
],
name: 'demo',
rules: [
{
actions: [{action: 'heal', amount: 20, target: 'this'}],
filter: 'any',
when: {kind: 'health_below', threshold: 50}
}
],
version: 2
})
};
fetch('http://localhost:3917/fork/{id}/scenario', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3917",
CURLOPT_URL => "http://localhost:3917/fork/{id}/scenario",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'entities' => [
[
'health' => 100,
'position' => [
-3,
1,
0
],
'team' => 1
],
[
'health' => 60,
'position' => [
3,
1,
0
],
'team' => 2
]
],
'name' => 'demo',
'rules' => [
[
'actions' => [
[
'action' => 'heal',
'amount' => 20,
'target' => 'this'
]
],
'filter' => 'any',
'when' => [
'kind' => 'health_below',
'threshold' => 50
]
]
],
'version' => 2
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:3917/fork/{id}/scenario"
payload := strings.NewReader("{\n \"entities\": [\n {\n \"health\": 100,\n \"position\": [\n -3,\n 1,\n 0\n ],\n \"team\": 1\n },\n {\n \"health\": 60,\n \"position\": [\n 3,\n 1,\n 0\n ],\n \"team\": 2\n }\n ],\n \"name\": \"demo\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"action\": \"heal\",\n \"amount\": 20,\n \"target\": \"this\"\n }\n ],\n \"filter\": \"any\",\n \"when\": {\n \"kind\": \"health_below\",\n \"threshold\": 50\n }\n }\n ],\n \"version\": 2\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:3917/fork/{id}/scenario")
.header("Content-Type", "application/json")
.body("{\n \"entities\": [\n {\n \"health\": 100,\n \"position\": [\n -3,\n 1,\n 0\n ],\n \"team\": 1\n },\n {\n \"health\": 60,\n \"position\": [\n 3,\n 1,\n 0\n ],\n \"team\": 2\n }\n ],\n \"name\": \"demo\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"action\": \"heal\",\n \"amount\": 20,\n \"target\": \"this\"\n }\n ],\n \"filter\": \"any\",\n \"when\": {\n \"kind\": \"health_below\",\n \"threshold\": 50\n }\n }\n ],\n \"version\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3917/fork/{id}/scenario")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"entities\": [\n {\n \"health\": 100,\n \"position\": [\n -3,\n 1,\n 0\n ],\n \"team\": 1\n },\n {\n \"health\": 60,\n \"position\": [\n 3,\n 1,\n 0\n ],\n \"team\": 2\n }\n ],\n \"name\": \"demo\",\n \"rules\": [\n {\n \"actions\": [\n {\n \"action\": \"heal\",\n \"amount\": 20,\n \"target\": \"this\"\n }\n ],\n \"filter\": \"any\",\n \"when\": {\n \"kind\": \"health_below\",\n \"threshold\": 50\n }\n }\n ],\n \"version\": 2\n}"
response = http.request(request)
puts response.read_body{
"assertions": 0,
"entities_spawned": 3,
"fork_id": "fork-1",
"ok": true,
"rules": 1,
"templates": 0
}Path Parameters
Fork id to apply the scenario to.
Body
application/json
A scenario document (same shape as POST /scenario): templates, entities, rules, assertions, camera, game.
The body is of type any.
Response
200 - application/json
Scenario applied to the fork; main world untouched. Returns ok:false with an error when the fork id is unknown.
⌘I