Module expcore.sync
Used as a faster way to get to the ranking function, overrides previous
Usage:
Sync.set_ranks{name=rank_name}
Functions
| Sync.tick_format (tick) | Used to standidise the tick format for any sync info |
| Sync.print (player_message, player_name[, player_tag[, player_colour[, prefix]]]) | Prints to chat as if it were a player |
| Sync.emit_embeded (args) | Logs an embed to the json.data we use a js script to add things we cant here |
| Sync.count_admins () | used to get the number of admins currently online |
| Sync.count_afk ([time=7200]) | used to get the number of afk players defined by 2 min by default |
| Sync.count_ranks () | used to get the number of players in each rank and currently online |
| Sync.count_players (online) | used to get the number of players either online or all |
| Sync.count_player_times () | used to get the number of players resulting in there play times |
| Sync.info ([set=nil]) | used to return the global list and set values in it |
| Sync.time ([set=nil]) | used to return the global time and set its value |
| Sync.update () | called to update values inside of the info |
| Sync.add_update (key, callback) | Adds a callback to be called when the info is updated |
| Sync.emit_data () | outputs the curent server info into a file |
| Sync.add_to_gui (element) | Adds a emeltent to the sever info gui |
Functions
- Sync.tick_format (tick)
-
Used to standidise the tick format for any sync info
Parameters:
- tick
Usage:
Sync.tick_format(60) -- return {60,'1.00M'}
- Sync.print (player_message, player_name[, player_tag[, player_colour[, prefix]]])
-
Prints to chat as if it were a player
Parameters:
- player_message the message to be printed in chat
- player_name the name of the player sending the message
- player_tag the tag apllied to the player's name (optional)
- player_colour the colour of the message (optional)
- prefix add a prefix before the chat eg [IRC] (optional)
Usage:
Sync.print('Test','Cooldude2606')
- Sync.emit_embeded (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 embeded will use
Usage:
Sync.emit_embeded{title='BAN',color='0x0',description='A player was banned' ... } - Sync.count_admins ()
-
used to get the number of admins currently online
Returns:
-
int
the number of admins online
Usage:
Sync.count_admins()
- Sync.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:
-
int
the number of afk players
Usage:
Sync.count_afk()
- Sync.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()
- Sync.count_players (online)
-
used to get the number of players either online or all
Parameters:
- online bolean if true only get online players
Returns:
-
table
contains player names
Usage:
Sync.count_players()
- Sync.count_player_times ()
-
used to get the number of players resulting in there play times
Returns:
-
table
contains players and each player is given a tick amount and a formated string
Usage:
Sync.count_player_times()
- Sync.info ([set=nil])
-
used to return the global list and set values in it
Parameters:
- set table keys to be replaced in the server info (default nil)
Returns:
-
either returns success when setting or the info when not setting
Usage:
Sync.info{server_name='Factorio Server 2'} - Sync.time ([set=nil])
-
used to return the global time and set its value
Parameters:
- set string the date time to be set (default nil)
Returns:
-
either true false if setting or the date time and tick off set
Usage:
Sync.time('Sun Apr 1 18:44:30 UTC 2018') - Sync.update ()
-
called to update values inside of the info
Returns:
-
all of the new info
Usage:
Sync.update()
- Sync.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)
- Sync.emit_data ()
-
outputs the curent server info into a file
Usage:
Sync.emit_data()
- Sync.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 trues