Sudo core

Core Module - Sudo - An extention of task and token to allow a single require to register and run functions bypassing all permissions.

Usage


    -- To use sudo you must register the allowed functions when the files are loaded, often this will just be giving access to
    -- some functions within a module if you expect that some parts may be blocked by in game permissions or a custom system you have made

    -- This will be blocked if the current player (from a command or gui) is not admin
    local function make_admin(player)
        player.admin = true
    end

    -- Here we give sudo access to the function under the name "make-admin"
    Sudo.register('make-admin',make_admin)

    -- This will allow us to bypass this by running one tick later outside of any player scope
    Sudo.run('make-admin',game.player)

Dependencies

utils.task
utils.token

Functions

register(name, callback) Registers a new callback under the given name, used to avoid desyncs
get(name) Gets the function that is registered under the given name
run(name[, ...]) Runs the function that is registered under the given name, you may supply any number of params as needed

Dependencies

# utils.task
# utils.token

Functions

# register(name, callback)

Registers a new callback under the given name, used to avoid desyncs

Parameters:
  • name : (string) the name that will be used to call this function
  • callback : (function) the function that will be called by this name
# get(name)

Gets the function that is registered under the given name

Parameters:
  • name : (string) the name of the function you want to get
# run(name[, ...])

Runs the function that is registered under the given name, you may supply any number of params as needed

Parameters:
  • name : (string) the name of the function you want to run
  • ... : (any) the other params that you want to pass to your function (optional)