From 4d05f13cb39245404ba2eb9e26f98157e8c2968d Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 1 Jun 2018 16:30:32 +0100 Subject: [PATCH] Updated Doc --- config.ld | 1 + doc/index.html | 10 +- doc/modules/ExpGamingCore.Server.html | 835 ++++++++++++++++++ doc/modules/ExpGamingCore.Sync.html | 122 ++- doc/modules/ExpGamingLib.html | 5 +- doc/modules/FSM.html | 43 +- doc/modules/StdLib.Color.html | 4 +- doc/modules/StdLib.Game.html | 4 +- doc/modules/StdLib.String.html | 4 +- doc/modules/StdLib.Table.html | 4 +- doc/modules/StdLib.Time.html | 4 +- ...odules.expgamingcore.commands.control.html | 4 +- .../modules.expgamingcore.gui.control.html | 4 +- ...les.expgamingcore.gui.guiparts.center.html | 4 +- ...les.expgamingcore.gui.guiparts.inputs.html | 4 +- ...dules.expgamingcore.gui.guiparts.left.html | 4 +- ...ules.expgamingcore.gui.guiparts.popup.html | 4 +- ...es.expgamingcore.gui.guiparts.toolbar.html | 4 +- ...modules.expgamingcore.ranking.control.html | 4 +- .../modules.expgamingcore.server.control.html | 566 ------------ modules/ExpGamingCore/Server/control.lua | 29 +- modules/ExpGamingCore/Server/src/commands.lua | 3 + modules/ExpGamingCore/Sync/control.lua | 58 +- 23 files changed, 1082 insertions(+), 642 deletions(-) create mode 100644 config.ld create mode 100644 doc/modules/ExpGamingCore.Server.html delete mode 100644 doc/modules/modules.expgamingcore.server.control.html diff --git a/config.ld b/config.ld new file mode 100644 index 00000000..9efa37a4 --- /dev/null +++ b/config.ld @@ -0,0 +1 @@ +new_type('command','Commands',false,'param') \ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 7dbc8d4a..9feb5b9d 100644 --- a/doc/index.html +++ b/doc/index.html @@ -40,7 +40,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -95,12 +95,12 @@ Returns a rank object given a player or rank name - modules.expgamingcore.server.control - Returns a un-used uuid (better system needed) + ExpGamingCore.Server + Adds a thread system and event listening and a admin bypass (recommend to disable /c and use optional /interface) ExpGamingCore.Sync - Description - A small description that will be displayed on the doc + Allows syncing with an outside server and info panle. ExpGamingLib @@ -132,7 +132,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/ExpGamingCore.Server.html b/doc/modules/ExpGamingCore.Server.html new file mode 100644 index 00000000..e6a302f3 --- /dev/null +++ b/doc/modules/ExpGamingCore.Server.html @@ -0,0 +1,835 @@ + + + + + Reference + + + + +
    + +
    + +
    +
    +
    + + +
    + + + + + + +
    + +

    Module ExpGamingCore.Server

    +

    Adds a thread system and event listening and a admin bypass (recommend to disable /c and use optional /interface)

    +

    +

    Info:

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

    Functions

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    new_thread (obj)Generates a new thread object
    get_thread (mixed)Used to get a thread via uuid or name (if one is assied)
    queue_thread (thread_to_queue)Adds a thread into the resolve queue, can be used to lower lag
    close_all_threads (with_force)Closes all active threads, can use force if it causes errors
    run_tick_threads ()Runs all the theads which have opened with an on_tick event
    check_timeouts ()Checks the timeout on all active timeout threads
    _thread_debuger (player, event[, state=toggle])Used to print event info to a player
    interface (callback[, use_thread[, env[, ...]]])Acts as a bypass for running functions, can accept a string
    +

    Tables

    + + + + + +
    globalGlobal Table
    +

    Fields

    + + + + + + + + + +
    uuidUsed to generate a new uuid for the thread system
    threadsRedirect to the thread index
    +

    Class Thread

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Server._thread:create ([obj={}])Returns a new thread object
    Server._thread:queue ()Opens and queses a thread
    Server._thread:valid ([skip_location_check=false])Test if the thread has all requied parts
    Server._thread:open ()Opens the thread; indexs this thread in the global index
    Server._thread:close ()Inverse of thread:open() - Removes all indexs to this thread, most cases this will cause it to become inassible
    Server._thread:resolve ([...])Trigger the on_resolve function and closes the thread - error and success called based on result of pcall (useful for async)
    Server._thread:check_timeout ()Checks the timeout on a thread - if timed out then it calles on_timeout and closes
    Server._thread:error (err)Used to check and raise the error handler of the thread, if not present it raises an error
    Server._thread:on_event (event, callback)Set function to run then an event is triggered, none of them are 'needed' but you are advised to have atleast one
    +

    modules.expgamingcore.server.src.commands Functions

    + + + + + + + + + +
    _comment ()This file will be loaded when ExpGamingCore.Commands is present
    interfaceRuns the given input from the script
    + +
    +
    + + +

    Functions

    + +
    +
    + + new_thread (obj) +
    +
    + Generates a new thread object + + +

    Parameters:

    +
      +
    • obj + table + the atributes to give to the thread +
    • +
    + +

    Returns:

    +
      + + Server._thread + the new thread created +
    + + + +

    Usage:

    +
      +
      Server.new_thread{name='foo',data={}}
      +
    + +
    +
    + + get_thread (mixed) +
    +
    + Used to get a thread via uuid or name (if one is assied) + + +

    Parameters:

    +
      +
    • mixed + either a uuid or the name given to a thread +
    • +
    + +

    Returns:

    +
      + + Server._thread + the thread by that name or uuid +
    +

    Or

    +
      + + boolean + if false is returned then no thread existes +
    + + + +

    Usage:

    +
      +
      Server.get_thread('decon') -- return thread
      +
    + +
    +
    + + queue_thread (thread_to_queue) +
    +
    + Adds a thread into the resolve queue, can be used to lower lag + + +

    Parameters:

    +
      +
    • thread_to_queue + Server._thread + the thread to be added to the queue, must be open and have a on_resolve function +
    • +
    + +

    Returns:

    +
      + + boolean + was it added successfuly +
    + + + +

    Usage:

    +
      +
      Server.queue_thread(thread) -- return true/false
      +
    + +
    +
    + + close_all_threads (with_force) +
    +
    + Closes all active threads, can use force if it causes errors + + +

    Parameters:

    +
      +
    • with_force + bolean + use force when closing +
    • +
    + + + + +

    Usage:

    +
      +
    • Server.close_all_threads() -- asks all threads to close
    • +
    • Server.close_all_threads(true) -- forcefuly close all threads
    • +
    + +
    +
    + + run_tick_threads () +
    +
    + Runs all the theads which have opened with an on_tick event + + + + + + +

    Usage:

    +
      +
      Server.run_tick_threads()
      +
    + +
    +
    + + check_timeouts () +
    +
    + Checks the timeout on all active timeout threads + + + + + + +

    Usage:

    +
      +
      Server.check_timeouts()
      +
    + +
    +
    + + _thread_debuger (player, event[, state=toggle]) +
    +
    + Used to print event info to a player + + +

    Parameters:

    +
      +
    • player + name, index or LuaPlayer + the player that the info will be returned to +
    • +
    • event + name or index + the event that info will be returned fo +
    • +
    • state + boolean + will info be returned, nil to toggle current state + (default toggle) +
    • +
    + + + + +

    Usage:

    +
      +
      Server._thread_debuger('Cooldude2606','on_player_died',true) -- will output event info to 'Cooldude2606' for 'on_player_died'
      +
    + +
    +
    + + interface (callback[, use_thread[, env[, ...]]]) +
    +
    + Acts as a bypass for running functions, can accept a string + + +

    Parameters:

    +
      +
    • callback + string or function + function to be ran +
    • +
    • use_thread + Server._thread or true + run the command on a premade thread or let it make its own + (optional) +
    • +
    • env + table + run the env to run the command in must have _env key as true to be + (optional) +
    • +
    • ... + any args you want to pass to the function + (optional) +
    • +
    + +

    Returns:

    +
      + + if no thread then it will return the value(s) returned by the callback +
    + + + +

    Usage:

    +
      +
    • Server.interface('local x = 1+1 print(x) return x') -- return 2
    • +
    • Server.interface('local x = 1+1 print(x)',true) -- will creat a thread to run as root (this is the bypass)
    • +
    + +
    +
    +

    Tables

    + +
    +
    + + global +
    +
    + Global Table + + +

    Fields:

    +
      +
    • all + a list of every thread (indexed by uuid) +
    • +
    • queue + an index for threads which will be resolved (contains uuids) +
    • +
    • tick + an index for threads which will run every tick (contains uuids) +
    • +
    • timeout + an index for threads which will timeout (contains uuids) +
    • +
    • events + an index of threads based on event ids (contains uuids) +
    • +
    • paused + an index of pasued threads (contains uuids) +
    • +
    • named + a name index for thread uuids +
    • +
    • print_to + contains players that event details will be printed to +
    • +
    • uuid + contains the random number generator for the uuid system +
    • +
    + + + + + +
    +
    +

    Fields

    + +
    +
    + + uuid +
    +
    + Used to generate a new uuid for the thread system + + + + + + +

    Usage:

    +
      +
      local uuid = tostring(Server.uuid) -- calling tostring locks the value
      +
    + +
    +
    + + threads +
    +
    + Redirect to the thread index + + + + + + +

    Usage:

    +
      +
    • Server.threads -- return #global.all
    • +
    • Server.threads -- return global.all
    • +
    + +
    +
    +

    Class Thread

    + +
    + The class for the server threads, allows abbilty to run async function +
    +
    +
    + + Server._thread:create ([obj={}]) +
    +
    + Returns a new thread object + + +

    Parameters:

    +
      +
    • obj + table + all values are opt {timeout=int,name=str,data=any} + (default {}) +
    • +
    + +

    Returns:

    +
      + + Server._thread + the new thread object +
    + + + +

    Usage:

    +
      +
      new_thread = thread:create()
      +
    + +
    +
    + + Server._thread:queue () +
    +
    + Opens and queses a thread + + + +

    Returns:

    +
      + + boolean + was the thread queued successfuly +
    + + +

    See also:

    + + +

    Usage:

    +
      +
      Server._thread:queue() -- returns true/false
      +
    + +
    +
    + + Server._thread:valid ([skip_location_check=false]) +
    +
    + Test if the thread has all requied parts + + +

    Parameters:

    +
      +
    • skip_location_check + bolean + true to skip the location checking + (default false) +
    • +
    + +

    Returns:

    +
      + + boolean + is the thread valid +
    + + + +

    Usage:

    +
      +
      if thread:valid() then end -- basic test for valid
      +
    + +
    +
    + + Server._thread:open () +
    +
    + Opens the thread; indexs this thread in the global index + + + +

    Returns:

    +
      + + bolean + if the thread was opened successfuly +
    + + + +

    Usage:

    +
      +
      thread:open() -- return true
      +
    + +
    +
    + + Server._thread:close () +
    +
    + Inverse of thread:open() - Removes all indexs to this thread, most cases this will cause it to become inassible + + + +

    Returns:

    +
      + + boolean + if the thread had a on_close function +
    + + + +

    Usage:

    +
      +
      thread:close() -- return true
      +
    + +
    +
    + + Server._thread:resolve ([...]) +
    +
    + Trigger the on_resolve function and closes the thread - error and success called based on result of pcall (useful for async) + + +

    Parameters:

    +
      +
    • ... + any arguments you want to pass to the resolve function + (optional) +
    • +
    + +

    Returns:

    +
      + + bolean + true if the thread called on_success or on_error +
    + + + +

    Usage:

    +
      +
      thread:resolve(x,y,z) -- return true
      +
    + +
    +
    + + Server._thread:check_timeout () +
    +
    + Checks the timeout on a thread - if timed out then it calles on_timeout and closes + + + +

    Returns:

    +
      + + bolean + if the thread timed out +
    + + + +

    Usage:

    +
      +
      thread:check_timeout() -- return true
      +
    + +
    +
    + + Server._thread:error (err) +
    +
    + Used to check and raise the error handler of the thread, if not present it raises an error + + +

    Parameters:

    +
      +
    • err + string + the err to be rasied +
    • +
    + +

    Returns:

    +
      + + boolean + did the thread have an error handler +
    + + + +

    Usage:

    +
      +
      thread:error(err) -- return true
      +
    + +
    +
    + + Server._thread:on_event (event, callback) +
    +
    + Set function to run then an event is triggered, none of them are 'needed' but you are advised to have atleast one + + +

    Parameters:

    +
      +
    • event + string or index + the name of the event that the function should be called on +
    • +
    • callback + function + the function which is called by the event trigger +
    • +
    + +

    Returns:

    +
      + + table + returns self so that they can be chained together +
    + + + +

    Usage:

    +
      +
    • thread:on_event('close',function) -- if event is not one below then a game event is used
    • +
    • thread_only_events = ['close','timeout','tick','resolve','success','error']
    • +
    + +
    +
    +

    modules.expgamingcore.server.src.commands Functions

    + +
    +
    + + _comment () +
    +
    + This file will be loaded when ExpGamingCore.Commands is present + + + + + + + +
    +
    + + interface +
    +
    + Runs the given input from the script + + +

    param:

    +
      +
    • code + The code that will be ran +
    • +
    + + + + + +
    +
    + + +
    +
    +
    +generated by LDoc 1.4.6 +Last updated 2018-06-01 16:29:39 +
    +
    + + diff --git a/doc/modules/ExpGamingCore.Sync.html b/doc/modules/ExpGamingCore.Sync.html index 7f2b0843..20c91a7f 100644 --- a/doc/modules/ExpGamingCore.Sync.html +++ b/doc/modules/ExpGamingCore.Sync.html @@ -35,8 +35,8 @@
  • Functions
  • Tables
  • Fields
  • -
  • modules.expgamingcore.sync.lib.gui Functions
  • -
  • modules.expgamingcore.sync.lib.ranking Functions
  • +
  • modules.expgamingcore.sync.src.gui Functions
  • +
  • modules.expgamingcore.sync.src.ranking Functions
  • @@ -51,7 +51,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -66,7 +66,7 @@

    Module ExpGamingCore.Sync

    -

    Description - A small description that will be displayed on the doc

    +

    Allows syncing with an outside server and info panle.

    Info:

    + + +

    Fields

    + +
    +
    + + global +
    +
    + Used to avoid conflicts in the global table + + +
      +
    • default + table or true + the default value of global, if true then default is restored + (default {}) +
    • +
    + + + + +

    Usage:

    +
      +
    • global[key] -- used like the normal global table
    • +
    • global{'foo','bar'} -- sets the default value
    • +
    • global(true) -- restores global to default
    • +
    +
    @@ -407,7 +446,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/StdLib.Color.html b/doc/modules/StdLib.Color.html index 7cc11d31..e2efad66 100644 --- a/doc/modules/StdLib.Color.html +++ b/doc/modules/StdLib.Color.html @@ -48,7 +48,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -553,7 +553,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/StdLib.Game.html b/doc/modules/StdLib.Game.html index 5b4f4488..a3d7da7a 100644 --- a/doc/modules/StdLib.Game.html +++ b/doc/modules/StdLib.Game.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -214,7 +214,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/StdLib.String.html b/doc/modules/StdLib.String.html index 4d2128bc..b2924c8a 100644 --- a/doc/modules/StdLib.String.html +++ b/doc/modules/StdLib.String.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -294,7 +294,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/StdLib.Table.html b/doc/modules/StdLib.Table.html index d2a41200..5a85e0e7 100644 --- a/doc/modules/StdLib.Table.html +++ b/doc/modules/StdLib.Table.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -1123,7 +1123,7 @@ some_func(1,2)
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/StdLib.Time.html b/doc/modules/StdLib.Time.html index b42b0935..9b5dd816 100644 --- a/doc/modules/StdLib.Time.html +++ b/doc/modules/StdLib.Time.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -131,7 +131,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/modules.expgamingcore.commands.control.html b/doc/modules/modules.expgamingcore.commands.control.html index f3323613..bd16c3b0 100644 --- a/doc/modules/modules.expgamingcore.commands.control.html +++ b/doc/modules/modules.expgamingcore.commands.control.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -124,7 +124,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/modules.expgamingcore.gui.control.html b/doc/modules/modules.expgamingcore.gui.control.html index 4f951cc4..ab3125b7 100644 --- a/doc/modules/modules.expgamingcore.gui.control.html +++ b/doc/modules/modules.expgamingcore.gui.control.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -160,7 +160,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/modules.expgamingcore.gui.guiparts.center.html b/doc/modules/modules.expgamingcore.gui.guiparts.center.html index 7dd28f1a..124667d9 100644 --- a/doc/modules/modules.expgamingcore.gui.guiparts.center.html +++ b/doc/modules/modules.expgamingcore.gui.guiparts.center.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -278,7 +278,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/modules.expgamingcore.gui.guiparts.inputs.html b/doc/modules/modules.expgamingcore.gui.guiparts.inputs.html index 82977f9e..7e375716 100644 --- a/doc/modules/modules.expgamingcore.gui.guiparts.inputs.html +++ b/doc/modules/modules.expgamingcore.gui.guiparts.inputs.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -434,7 +434,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/modules.expgamingcore.gui.guiparts.left.html b/doc/modules/modules.expgamingcore.gui.guiparts.left.html index 2d78fe94..c08d35f9 100644 --- a/doc/modules/modules.expgamingcore.gui.guiparts.left.html +++ b/doc/modules/modules.expgamingcore.gui.guiparts.left.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -181,7 +181,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/modules.expgamingcore.gui.guiparts.popup.html b/doc/modules/modules.expgamingcore.gui.guiparts.popup.html index 6309f7b2..e73fe754 100644 --- a/doc/modules/modules.expgamingcore.gui.guiparts.popup.html +++ b/doc/modules/modules.expgamingcore.gui.guiparts.popup.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -126,7 +126,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/modules.expgamingcore.gui.guiparts.toolbar.html b/doc/modules/modules.expgamingcore.gui.guiparts.toolbar.html index 483c4c9f..e27ca143 100644 --- a/doc/modules/modules.expgamingcore.gui.guiparts.toolbar.html +++ b/doc/modules/modules.expgamingcore.gui.guiparts.toolbar.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -117,7 +117,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/modules.expgamingcore.ranking.control.html b/doc/modules/modules.expgamingcore.ranking.control.html index 690fa714..8e203aae 100644 --- a/doc/modules/modules.expgamingcore.ranking.control.html +++ b/doc/modules/modules.expgamingcore.ranking.control.html @@ -47,7 +47,7 @@
  • modules.expgamingcore.gui.guiparts.toolbar
  • modules.expgamingcore.gui.control
  • modules.expgamingcore.ranking.control
  • -
  • modules.expgamingcore.server.control
  • +
  • ExpGamingCore.Server
  • ExpGamingCore.Sync
  • ExpGamingLib
  • StdLib.Color
  • @@ -374,7 +374,7 @@
    generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 +Last updated 2018-06-01 16:29:39
    diff --git a/doc/modules/modules.expgamingcore.server.control.html b/doc/modules/modules.expgamingcore.server.control.html deleted file mode 100644 index 603165ee..00000000 --- a/doc/modules/modules.expgamingcore.server.control.html +++ /dev/null @@ -1,566 +0,0 @@ - - - - - Reference - - - - -
    - -
    - -
    -
    -
    - - -
    - - - - - - -
    - -

    Module modules.expgamingcore.server.control

    -

    Returns a un-used uuid (better system needed)

    -

    -

    Usage:

    -
      -
      obj.uuid = Server.new_uuid()
      -
      -
    - - -

    Functions

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Server.threads ([count=nil])Returns either the number of threads or a able of threads
    Server.get_thread (mixed)Used to get a thread via it's uuid or by name if one is given
    Server.queue_thread (thread_to_queue)Adds a thread into the resolve queue, can be used to lower lag
    Server.close_all_threads (with_force)Closes all active threads, can use force if it causes errors
    Server.run_tick_threads ()Runs all the theads which have opened with an on_tick event
    Server.check_timeouts ()Checks the timeout on all active timeout threads
    Server._thread_handler (event)Calles all threads on a certain game event (used with script.on_event)
    Server.interface (callback[, use_thread[, ...]])Given a string or function it will run that function and return any values
    Server._thread:valid (skip_location_check)Test if the thread has all requied parts
    Server._thread:open ()Opens the thread by storing it in a place the server object can find it
    Server._thread:close ()Inverse of thread:open() - it removes the thread and calles on_close
    Server._thread:resolve ([...])Trigger the on_resolve function and closes the thread - error and success called based on result of pcall (useful for async)
    Server._thread:check_timeout ()Checks the timeout on a thread - if timedout then it calles on_timeout and closes
    Server._thread:error (err)Rasies an error on this thread
    Server._thread:on_event (event, callback)Set function to run then an event is called on a thread, none of them are 'needed' but you are advised to have atleast one
    - -
    -
    - - -

    Functions

    - -
    -
    - - Server.threads ([count=nil]) -
    -
    - Returns either the number of threads or a able of threads - - -

    Parameters:

    -
      -
    • count - bolean - true to return the number of threads - (default nil) -
    • -
    - -

    Returns:

    -
      - - either a list of threads or a number -
    - - - -

    Usage:

    -
      -
      Server.threads() -- return {...}
      - Server.threads(true) -- return int
      -
    - -
    -
    - - Server.get_thread (mixed) -
    -
    - Used to get a thread via it's uuid or by name if one is given - - -

    Parameters:

    -
      -
    • mixed - either a uuid or the name given to a thread -
    • -
    - -

    Returns:

    -
      - - table - the thread by that name or uuid -
    - - - -

    Usage:

    -
      -
      Server.get_thread('decon') -- return thread
      -
    - -
    -
    - - Server.queue_thread (thread_to_queue) -
    -
    - Adds a thread into the resolve queue, can be used to lower lag - - -

    Parameters:

    -
      -
    • thread_to_queue - table - the thread to add to the queue must have a resolve function (must be open) -
    • -
    - -

    Returns:

    -
      - - boolean - was the thread added -
    - - - -

    Usage:

    -
      -
      Server.queue_thread(thread) -- return true/false
      -
    - -
    -
    - - Server.close_all_threads (with_force) -
    -
    - Closes all active threads, can use force if it causes errors - - -

    Parameters:

    -
      -
    • with_force - bolean - use force when closing -
    • -
    - - - - -

    Usage:

    -
      -
      Server.close_all_threads()
      - Server.close_all_threads(true) -- use if no force makes errors
      -
    - -
    -
    - - Server.run_tick_threads () -
    -
    - Runs all the theads which have opened with an on_tick event - - - - - - -

    Usage:

    -
      -
      Server.run_tick_threads()
      -
    - -
    -
    - - Server.check_timeouts () -
    -
    - Checks the timeout on all active timeout threads - - - - - - -

    Usage:

    -
      -
      Server.check_timeouts()
      -
    - -
    -
    - - Server._thread_handler (event) -
    -
    - Calles all threads on a certain game event (used with script.on_event) - - -

    Parameters:

    -
      -
    • event - table - the event that is called -
    • -
    - - - - - -
    -
    - - Server.interface (callback[, use_thread[, ...]]) -
    -
    - Given a string or function it will run that function and return any values - - -

    Parameters:

    -
      -
    • callback - either a function or string which will be ran via pcall -
    • -
    • use_thread - give a thread for the interface to run on (does not need to be open, but cant use on_resolve) - (optional) -
    • -
    • ... - any args you want to pass to the function - (optional) -
    • -
    - - - - -

    Usage:

    -
      -
      Server.interface('local x = 1+1 print(x) return x') -- return 2
      - Server.interface('local x = 1+1 print(x)',thread) -- no return
      -
    - -
    -
    - - Server._thread:valid (skip_location_check) -
    -
    - Test if the thread has all requied parts - - -

    Parameters:

    -
      -
    • skip_location_check - bolean - true to skip the location check -
    • -
    - -

    Returns:

    -
      - - bolean - is the thread valid -
    - - - -

    Usage:

    -
      -
      if thread:valid() then end
      -
    - -
    -
    - - Server._thread:open () -
    -
    - Opens the thread by storing it in a place the server object can find it - - - -

    Returns:

    -
      - - bolean - if the thread was opened -
    - - - -

    Usage:

    -
      -
      thread:open() -- return true
      -
    - -
    -
    - - Server._thread:close () -
    -
    - Inverse of thread:open() - it removes the thread and calles on_close - - - -

    Returns:

    -
      - - bolean - if the thread had a on_close function -
    - - - -

    Usage:

    -
      -
      thread:close() -- return true
      -
    - -
    -
    - - Server._thread:resolve ([...]) -
    -
    - Trigger the on_resolve function and closes the thread - error and success called based on result of pcall (useful for async) - - -

    Parameters:

    -
      -
    • ... - any arguments you want to pass to the resolve function - (optional) -
    • -
    - -

    Returns:

    -
      - - bolean - true if the thread called on_success or on_error -
    - - - -

    Usage:

    -
      -
      thread:resolve(x,y,z) -- return true
      -
    - -
    -
    - - Server._thread:check_timeout () -
    -
    - Checks the timeout on a thread - if timedout then it calles on_timeout and closes - - - -

    Returns:

    -
      - - bolean - if the thread timedout -
    - - - -

    Usage:

    -
      -
      thread:check_timeout() -- return true
      -
    - -
    -
    - - Server._thread:error (err) -
    -
    - Rasies an error on this thread - - -

    Parameters:

    -
      -
    • err - the err to be rasied -
    • -
    - -

    Returns:

    -
      - - bolean - did the thread handdle the error -
    - - - -

    Usage:

    -
      -
      thread:error(err) -- return true
      -
    - -
    -
    - - Server._thread:on_event (event, callback) -
    -
    - Set function to run then an event is called on a thread, none of them are 'needed' but you are advised to have atleast one - - -

    Parameters:

    -
      -
    • event - string - the name of the event that it is called on -
    • -
    • callback - function - the function which is called on the event -
    • -
    - -

    Returns:

    -
      - - table - returns self so that there can be chained -
    - - - -

    Usage:

    -
      -
      thread:on_event('close',function) -- return true
      -events = ['close','timeout','tick','resolve','success','error']
      -if event is a number then it is asumed to be a game event
      -
    - -
    -
    - - -
    -
    -
    -generated by LDoc 1.4.6 -Last updated 2018-05-31 00:41:31 -
    -
    - - diff --git a/modules/ExpGamingCore/Server/control.lua b/modules/ExpGamingCore/Server/control.lua index 5e9b9522..15a9114a 100644 --- a/modules/ExpGamingCore/Server/control.lua +++ b/modules/ExpGamingCore/Server/control.lua @@ -8,16 +8,25 @@ local Server = {} --- Global Table -- @table global +-- @field all a list of every thread (indexed by uuid) +-- @field queue an index for threads which will be resolved (contains uuids) +-- @field tick an index for threads which will run every tick (contains uuids) +-- @field timeout an index for threads which will timeout (contains uuids) +-- @field events an index of threads based on event ids (contains uuids) +-- @field paused an index of pasued threads (contains uuids) +-- @field named a name index for thread uuids +-- @field print_to contains players that event details will be printed to +-- @field uuid contains the random number generator for the uuid system local global = global{ - all={_n=0}, -- a list of every thread (indexed by uuid) - queue={}, -- an index for threads which will be resolved (contains uuids) - tick={}, -- an index for threads which will run every tick (contains uuids) - timeout={}, -- an index for threads which will timeout (contains uuids) - events={}, -- an index of threads based on event ids (contains uuids) - paused={}, -- an index of pasued threads (contains uuids) - named={}, -- a name index for thread uuids - print_to={}, -- contains players that event details will be printed to - uuid=nil -- contains the random number generator for the uuid system + all={_n=0}, + queue={}, + tick={}, + timeout={}, + events={}, + paused={}, + named={}, + print_to={}, + uuid=nil } --- Used to generate a new uuid for the thread system @@ -220,7 +229,7 @@ function Server.interface(callback,use_thread,env,...) end --- The class for the server threads, allows abbilty to run async function --- @class Thread +-- @type Thread -- @alias Server._thread Server._thread = {} diff --git a/modules/ExpGamingCore/Server/src/commands.lua b/modules/ExpGamingCore/Server/src/commands.lua index ce8ccd35..7f83ebd5 100644 --- a/modules/ExpGamingCore/Server/src/commands.lua +++ b/modules/ExpGamingCore/Server/src/commands.lua @@ -7,6 +7,9 @@ --- This file will be loaded when ExpGamingCore.Commands is present -- @function _comment +--- Runs the given input from the script +-- @command interface +-- @param code The code that will be ran commands.add_command('interface', 'Runs the given input from the script', {'code',true}, function(event,args) local callback = args.code -- looks for spaces, if non the it will prefix the command with return diff --git a/modules/ExpGamingCore/Sync/control.lua b/modules/ExpGamingCore/Sync/control.lua index d1ee6a31..5158bff9 100644 --- a/modules/ExpGamingCore/Sync/control.lua +++ b/modules/ExpGamingCore/Sync/control.lua @@ -6,30 +6,52 @@ local Sync = {} local Sync_updates = {} + --- Global Table -- @table global +-- @field server_name the server name +-- @field server_description a short description of the server +-- @field reset_time the reset time of the server +-- @field time the last knowen irl time +-- @field time_set the last in game time that the time was set +-- @field last_update the last time that this info was updated +-- @field time_period how often this infomation is updated +-- @field players a list of different player related states +-- @field ranks a list of player ranks +-- @field rockets the number of rockets launched +-- @field mods the mods which are loaded local global = global{ - server_name='Factorio Server', -- the server name - server_description='A factorio server for everyone', -- a short description of the server - reset_time='On Demand', -- the reset time of the server - time='Day Mth 00 00:00:00 UTC Year', -- the last knowen irl time - time_set={0,'0.00M'}, -- the last in game time that the time was set - last_update={0,'0.00M'}, -- the last time that this info was updated - time_period={18000,'5.00M'}, -- how often this infomation is updated + server_name='Factorio Server', + server_description='A factorio server for everyone', + reset_time='On Demand', + time='Day Mth 00 00:00:00 UTC Year', + time_set={0,'0.00M'}, + last_update={0,'0.00M'}, + time_period={18000,'5.00M'}, players={ - online={'Offline'}, -- list of all players online - n_online=0, -- the number of players online - all={'Offline'}, -- list of all player on or offline - n_all=0, -- the number of players who have joined the server - admins_online=0, -- the number of admins online - afk_players=0, -- the number of afk players - times={'Offline'} -- the play times of every player - }, -- a sub list of players in the game - ranks={'Offline'}, -- a list of player ranks - rockets=0, -- the number of rockets launched - mods={'Offline'} -- the mods which are loaded + online={'Offline'}, + n_online=0, + all={'Offline'}, + n_all=0, + admins_online=0, + afk_players=0, + times={'Offline'} + }, + ranks={'Offline'}, + rockets=0, + mods={'Offline'} } +--- Player sub-table +-- @table global.players +-- @field online list of all players online +-- @field n_online the number of players online +-- @field all list of all player on or offline +-- @field n_all the number of players who have joined the server +-- @field admins_online the number of admins online +-- @field afk_players the number of afk players +-- @field times the play times of every player + --- Used to standidise the tick format for any sync info -- @usage Sync.tick_format(60) -- return {60,'1.00M'} -- @treturn {number,string} table containg both the raw number and clean version of a time