Docs/API
Server
The server table in rtv-mp scenarios: server.players, server.area, server.broadcast, server.console, server.time and the other server-wide functions.
server.players()#
Returns: list of players
Every connected player, including ones still loading, by ascending ID. Use player.ready to keep only players in the world.
server.player(id or name)#
Returns: player, or nil, err
Finds a connected player by peer ID or exact name (any case), like the console. Fails if no player matches or the name is ambiguous.
server.areas()#
Returns: list of areas
Every loaded area instance, private hideouts included, sorted by key.
server.area(name or key)#
Returns: area, or nil, err
A loaded public map by name (any case), or any instance by its exact key ("Cabin@<identity>"). Fails if it is not loaded.
server.broadcast(message, [color])#
Returns: —
Sends a message to every player's chat, like /say. See chat messages.
server.console(line)#
Returns: list of lines, or nil, err
Runs a console command with full console authority and returns its output lines. The leading / is optional. /scenario cannot be run this way.
server.fetch_prefabs()#
Returns: list of strings
Sorted prefab names, including generated defaults. See Object placement.
server.fetch_assets()#
Returns: list of strings
Sorted references for use with asset. Returns short names where unique and exact Godot paths where names collide.
server.time()#
Returns: number
Server wall-clock time in seconds (Unix time).
server.game_time()#
Returns: table, or nil, err
The shared in-game clock, as a table:
| Field | Description |
|---|---|
hour, minute | The time of day. |
minutes | Minutes since midnight. |
day | The day number. |
text | The time as "HH:MM". |
scale | The time_scale from world.json. |
server.set_game_time(hour, [minute])#
Returns: message, or nil, err
Sets the shared time of day in every area, like /time. Pass an hour (0 to 23) and an optional minute (0 to 59), or a single "HH:MM" string: server.set_game_time(9, 30) and server.set_game_time("09:30") are the same.
The day number is unchanged, and the clock keeps running at time_scale. Set time_scale to 0 in world.json to hold the time you set.
server.weather()#
Returns: table, or nil, err
The shared weather, as a table with type (Neutral, Overcast, Wind, Rain, Storm, Aurora or Fog) and minutes_left, the real minutes until it changes by itself.
server.set_weather(type, [minutes])#
Returns: message, or nil, err
Sets the shared weather in every area, like /weather.
typeisNeutral,Overcast,Wind,Rain,Storm,AuroraorFog, in any case, or"clear"forNeutral.minutesis how long it lasts before random weather resumes: 0.1 to 1440, default 10.
server.log(...)#
Returns: —
Same as print.
| Field | Type | Description |
|---|---|---|
server.scenario | string | The running scenario's folder name. |
server.api | number | The API version, currently 1. |
Chat messages#
server.broadcast, player:tell and area:tell take either a string or an array of colored segments.
- A string is at most 160 characters; control characters are removed. An optional
#RRGGBBcolor applies to the whole line. An empty message raises an error. - Segments are an ordered array of
{text=..., color="#RRGGBB"}records, up to 32, with at most 160 characters in all. They keep spaces and render eachtextliterally. Omitcolorfor the default chat color. server.broadcastis sent as the server: it shows[server]in front of the message and is written to the server log, like/say.player:tellandarea:tellare private and show only the message text, with no prefix. To send a line to everyone without[server], calltellon each player fromserver.players().
Segments example:
server.broadcast({
{text = "[Event] ", color = "#ff7373"},
{text = "A convoy arrived at "},
{text = "the old station", color = "#ffd166"},
})
server.console reaches everything the console can do that has no dedicated function yet: time and weather (/time 22:00, /weather), seasons, /respawnloot, /respawnai, moderation and more. Treat its output as text meant for people; its wording may change.
Found a mistake or missing detail? Tell us in the Discord.
rtv-mp