Module ExpGamingCore.Sync

Allows syncing with an outside server and info panle.

Info:

  • License: https://github.com/explosivegaming/scenario/blob/master/LICENSE
  • Author: Cooldude2606

Functions

tick_format (tick) Used to standidise the tick format for any sync info
print (player_message, player_name[, player_tag[, player_colour[, prefix]]]) Prints to chat as if it were a player
emit_embedded (args) Logs an embed to the json.data we use a js script to add things we cant here
count_admins () Used to get the number of admins currently online
count_afk ([time=7200]) Used to get the number of afk players defined by 2 min by default
count_ranks () Used to get the number of players in each rank and currently online; if ExpGamingCore/Ranking is present then it will give more than admin and user
count_players (online) Used to get a list of every player name with the option to limit to only online players
count_player_times () Used to get a list of every player name with the amount of time they have played for
update () Called to update values inside of the info
add_update (key, callback) Adds a callback to be called when the info is updated
emit_data () Outputs the curent server info into a file

Tables

global Global Table
global.players Player sub-table
EmitEmbededParamaters Outline of the paramaters accepted by Sync.emit_embedded

Fields

info used to get the global list that has been defined, also used to set that list
time Used to return and set the current IRL time; not very good need a better way to do this

modules.expgamingcore.sync.src.gui Functions

_comment () This file will be loaded when ExpGamingCore.Gui is present
add_to_gui (element) Adds a emeltent to the sever info gui
server-info Creates a center gui that will appear on join

modules.expgamingcore.sync.src.ranking Functions

_comment () This file will be loaded when ExpGamingCore.Role is present
set_ranks (...) Used as a redirect to Ranking._base_preset that will set the rank given to a player apon joining
count_ranks () Used to get the number of players in each rank and currently online


Functions

tick_format (tick)
Used to standidise the tick format for any sync info

Parameters:

  • tick

Returns:

    {number,string} table containg both the raw number and clean version of a time

Usage:

    Sync.tick_format(60) -- return {60,'1.00M'}
print (player_message, player_name[, player_tag[, player_colour[, prefix]]])
Prints to chat as if it were a player

Parameters:

  • player_message string the message to be printed in chat
  • player_name string the name of the player sending the message
  • player_tag string the tag apllied to the player's name (optional)
  • player_colour string the colour of the message, either hex or named colour (optional)
  • prefix string add a prefix before the chat eg [IRC] (optional)

Usage:

    Sync.print('Test','Cooldude2606')
emit_embedded (args)
Logs an embed to the json.data we use a js script to add things we cant here

Parameters:

  • args table a table which contains everything that the embedded will use

See also:

Usage:

    Sync.emit_embedded{title='BAN',color='0x0',description='A player was banned' ... }
count_admins ()
Used to get the number of admins currently online

Returns:

    number the number of admins online

Usage:

    Sync.count_admins() -- returns number
count_afk ([time=7200])
Used to get the number of afk players defined by 2 min by default

Parameters:

  • time int in ticks that a player is called afk (default 7200)

Returns:

    number the number of afk players

Usage:

    Sync.count_afk()
count_ranks ()
Used to get the number of players in each rank and currently online; if ExpGamingCore/Ranking is present then it will give more than admin and user

Returns:

    table contains the ranks and the players in that rank

Usage:

    Sync.count_ranks()
count_players (online)
Used to get a list of every player name with the option to limit to only online players

Parameters:

  • online boolean true will get only the online players

Returns:

    table table of player names

Usage:

    Sync.count_players()
count_player_times ()
Used to get a list of every player name with the amount of time they have played for

Returns:

    table table indexed by player name, each value contains the raw tick and then the clean string

Usage:

    Sync.count_player_times()
update ()
Called to update values inside of the info

Returns:

    all of the new info

Usage:

    Sync.update()
add_update (key, callback)
Adds a callback to be called when the info is updated

Parameters:

  • key string the key that the value will be stored in
  • callback function the function which will return this value

Usage:

    Sync.add_update('players',function() return #game.players end)
emit_data ()
Outputs the curent server info into a file

Usage:

    Sync.emit_data()

Tables

global
Global Table

Fields:

  • server_name the server name
  • server_description a short description of the server
  • reset_time the reset time of the server
  • time the last knowen irl time
  • time_set the last in game time that the time was set
  • last_update the last time that this info was updated
  • time_period how often this infomation is updated
  • players a list of different player related states
  • ranks a list of player ranks
  • rockets the number of rockets launched
  • mods the mods which are loaded
global.players
Player sub-table

Fields:

  • online list of all players online
  • n_online the number of players online
  • all list of all player on or offline
  • n_all the number of players who have joined the server
  • admins_online the number of admins online
  • afk_players the number of afk players
  • times the play times of every player
EmitEmbededParamaters
Outline of the paramaters accepted by Sync.emit_embedded

Fields:

  • title the tile of the embed
  • color the color given in hex you can use Color.to_hex{r=0,g=0,b=0}
  • description the description of the embed
  • server_detail sting to add onto the pre-set server detail
  • fieldone the filed to add to the embed (key is name) (value is text) (start value with <<inline>> to make inline)
  • fieldtwo the filed to add to the embed (key is name) (value is text) (start value with <<inline>> to make inline)

Fields

info
used to get the global list that has been defined, also used to set that list
  • set table keys to be replaced in the server info (default nil)

Usage:

  • Sync.info{server_name='Factorio Server 2'} -- returns true
  • Sync.info -- table of info
time
Used to return and set the current IRL time; not very good need a better way to do this
  • set string the date time to be set (default nil)

Usage:

  • Sync.time('Sun Apr  1 18:44:30 UTC 2018')
  • Sync.time -- string

modules.expgamingcore.sync.src.gui Functions

_comment ()
This file will be loaded when ExpGamingCore.Gui is present
add_to_gui (element)
Adds a emeltent to the sever info gui

Parameters:

  • element see examples before for what can be used, it can also be a return from Gui.inputs.add

Returns:

    bolean based on weather it was successful or not

Usage:

    Sync.add_to_gui('string') -- return true
server-info
Creates a center gui that will appear on join

modules.expgamingcore.sync.src.ranking Functions

_comment ()
This file will be loaded when ExpGamingCore.Role is present
set_ranks (...)
Used as a redirect to Ranking._base_preset that will set the rank given to a player apon joining

Parameters:

  • ...

Usage:

    Sync.set_ranks{player_name=rank_name,...}
count_ranks ()
Used to get the number of players in each rank and currently online

Returns:

    table contains the ranks and the players in that rank

Usage:

    Sync.count_ranks()
generated by LDoc 1.4.6 Last updated 2018-06-07 12:58:23