Core Module - External - A module used to make accessing externally set data easier.
-- Printing all server to chat
local External = require 'expcore.external' --- @dep expcore.external
local message = 'id: %s name: %s version: %s status: %s'
for server_id, server in pairs(External.get_servers()) do
local status = External.get_server_status(server_id)
game.print(message:format(server_id, server.name, server.version, status))
end
valid() | Checks that local links are valid, will try to add the links if invalid |
get_servers() | Gets a table of all the servers, key is the server id, value is the server details |
get_servers_filtered(search) | Gets a table of all the servers filtered by name, key is the server id, value is the server details |
get_current_server() | Gets the details of the current server |
get_server_details(server_id) | Gets the details of the given server |
get_server_status(server_id, raw) | Gets the status of the given server |
get_server_ups() | Gets the ups of the current server |
request_connection(player, server_id[, self_requested=false]) | Connect a player to the given server |
Checks that local links are valid, will try to add the links if invalid
Returns:-- Check that external data is valid
if not External.valid() then
-- error code here
end
Gets a table of all the servers, key is the server id, value is the server details
Returns:-- Get all servers
local servers = External.get_servers()
Gets a table of all the servers filtered by name, key is the server id, value is the server details
Parameters:-- Get all servers with public in the name
local servers = External.get_servers_filtered(public)
Gets the details of the current server
Returns:-- Get the details of the current server
local server = External.get_current_server()
Gets the details of the given server
Parameters:-- Get the details of the given server
local server = External.get_server_details('eu-01')
Gets the status of the given server
Parameters:-- Get the status of the given server
local status = External.get_server_status('eu-01')
Gets the ups of the current server
Usage:-- Get the ups of the current server
local server_ups = External.get_server_ups()
Connect a player to the given server
Parameters:-- Request that a player joins a different server
External.request_connection(player, 'eu-01')
-- Request that a player joins a different server, by own request
External.request_connection(player, 'eu-01', true)