## External core

Core Module - External - A module used to make accessing externally set data easier.

### Usage

    -- 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

### Functions

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

### Functions

# valid()

  Checks that local links are valid, will try to add the links if invalid

  Returns:
  - (boolean) If the external data is valid, if false you should not call any other methods from External
  Usage:

      -- Check that external data is valid
      if not External.valid() then
          -- error code here
      end

# get_servers()

  Gets a table of all the servers, key is the server id, value is the server details

  Returns:
  - (table) A table containing all the servers, key is the server id, value is the server details
  Usage:

      -- Get all servers
      local servers = External.get_servers()

# get_servers_filtered(search)

  Gets a table of all the servers filtered by name, key is the server id, value is the server details

  Parameters:
  - search : (string) The string to search for, names, short_names and ids are checked for this string.
  Returns:
  - (table) A table containing all the servers filtered by name, key is the server id, value is the server details
  Usage:

      -- Get all servers with public in the name
      local servers = External.get_servers_filtered(public)

# get_current_server()

  Gets the details of the current server

  Returns:
  - (table) The details of the current server
  Usage:

      -- Get the details of the current server
      local server = External.get_current_server()

# get_server_details(server_id)

  Gets the details of the given server

  Parameters:
  - server_id : (string) The internal server if for the server you want the details of
  Returns:
  - (table) The details of the given server
  Usage:

      -- Get the details of the given server
      local server = External.get_server_details('eu-01')

# get_server_status(server_id, raw)

  Gets the status of the given server

  Parameters:
  - server_id : (string) The internal server if for the server you want the status of
  - raw : (boolean) When true Current will not be returned as status but rather the raw status for the server
  Returns:
  - (string) The status of the given server, one of: Online, Modded, Protected, Current, Offline
  Usage:

      -- Get the status of the given server
      local status = External.get_server_status('eu-01')

# get_server_ups()

  Gets the ups of the current server

  Usage:

      -- Get the ups of the current server
      local server_ups = External.get_server_ups()

# request_connection(player, server_id[, self_requested=false])

  Connect a player to the given server

  Parameters:
  - player : (LuaPlayer) The player that you want to request to join a different server
  - server_id : (string) The internal id of the server to connect to, can also be any address but this will show Unknown Server
  - self_requested : (boolean) If the player requested the join them selfs, this will hide the message about being asked to switch (default: false)
  Usage:

      -- 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)