World
Base: /api/world
The world section shows and controls the time of day and the weather. You read what time it is in the game world, set the time to midnight, sunrise, noon or sunset, and force weather either for the whole world or for single zones 0 to 4. This fits event scripts, a weather display on your website or a panel with weather tiles. Time and weather apply to the first loaded world, and for weather you can pick another one with the world parameter.
Endpoints
/api/world
Get world
Returns world_count, world_name and tick of the first loaded world, plus currentHour, dayProgress, sunlightFactor and moonPhase of the time of day as well as weather, forced_weather and zone_weather.
Response Example
{
"world_count": 2,
"world_name": "default",
"tick": 123456,
"currentHour": 14,
"dayProgress": 0.6,
"sunlightFactor": 0.9,
"moonPhase": 2,
"weather": "clear"
}
cURL
curl -X GET 'http://localhost:5550/api/world' \
-H 'X-Admin-Token: YOUR_TOKEN'
Internal Behavior
/api/world/time
Set time
Sets the time of day.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
time
|
string | Yes | midnight, sunrise, noon or sunset |
Response Example
{
"success": true,
"time": "noon"
}
cURL
curl -X POST 'http://localhost:5550/api/world/time' \
-H 'X-Admin-Token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"time": "noon"}'
Internal Behavior
/api/world/weather
Weather per zone
Returns the current surface weather of zones 0 to 4, the weathers each zone can have, the weather fixed per zone and which players are where.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
world
|
string | No | World name, default is the first world |
Response Example
{
"success": true,
"world": "default",
"zones": [
{
"zone": "Zone2",
"override": "Zone2_Sand_Storm",
"current": "Zone2_Sand_Storm",
"weathers": ["Zone2_Sunny", "Zone2_Sand_Storm", "Zone2_Thunder_Storm"],
"players": ["Steve"]
}
],
"players": [
{
"name": "Steve",
"environment": "Env_Zone2_Deserts",
"zone": "Zone2",
"weather": "Zone2_Sand_Storm"
}
]
}
cURL
curl -X GET 'http://localhost:5550/api/world/weather?world=default' \
-H 'X-Admin-Token: YOUR_TOKEN'
Internal Behavior
/api/world/weather/zone
Set weather of a zone
Fixes the weather of one zone or gives it back to the game forecast with natural.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
zone
|
string | Yes | Zone0 to Zone4 |
weather
|
string | Yes | A weather ID such as Zone2_Sand_Storm, or natural |
world
|
string | No | World name, default is the first world |
Response Example
{
"success": true,
"world": "default",
"zone": "Zone2",
"weather": "Zone2_Sand_Storm"
}
cURL
curl -X POST 'http://localhost:5550/api/world/weather/zone' \
-H 'X-Admin-Token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"zone": "Zone2", "weather": "Zone2_Sand_Storm"}'
Internal Behavior
/api/world/weather
Force weather for the whole world
Forces one weather for the whole world, overriding every zone. natural lifts it again.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
weather
|
string | Yes | A weather ID such as Zone1_Rain, or natural. The old short names clear, rain, storm and snow still work. |
world
|
string | No | World name, default is the first world |
Response Example
{
"success": true,
"weather": "Zone3_Snow_Storm"
}
cURL
curl -X POST 'http://localhost:5550/api/world/weather' \
-H 'X-Admin-Token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"weather": "rain"}'