Module expcore.server

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-29 20:15:05