utils.core module

Measures distance between pos1 and pos2

Functions

Module.cant_run (name) Prints a message letting the player know they cannot run a command
Module.format_time (ticks) Takes a time in ticks and returns a string with the time in format "x hour(s) x minute(s)"
Module.get_actor () Returns a valid string with the name of the actor of a command.
Module.log_command (actor, command, parameters) Logs the use of a command and its user
Module.print_admins (msg, source) Prints a message to all online admins
Module.print_except (msg, player, color) Takes msg and prints it to all players except provided player
Module.random_RGB () Returns a random RGB color as a table
Module.set_and_return (tbl, key, value) Sets a table element to value while also returning value.
Module.verify_mult_types (arg, arg_types) Asserts the argument is one of type arg_types

Fields

Module.is_module_available Takes the string of a module and returns whether is it available or not
Module.move_position Moves a position according to the parameters given Notice: only accepts cardinal directions as direction
Module.opposite_direction Takes a direction and gives you the opposite

Functions

# Module.cant_run (name)

Prints a message letting the player know they cannot run a command

Parameters:
  • name : string name of the command
# Module.format_time (ticks)

Takes a time in ticks and returns a string with the time in format "x hour(s) x minute(s)"

Parameters:
  • ticks
# Module.get_actor ()

Returns a valid string with the name of the actor of a command.

# Module.log_command (actor, command, parameters)

Logs the use of a command and its user

Parameters:
  • actor : string with the actor's name (usually acquired by calling get_actor)
  • command : the command's name as table element
  • parameters : the command's parameters as a table (optional)
# Module.print_admins (msg, source)

Prints a message to all online admins

Parameters:
  • msg : table if locale is used
  • source : string must be the name of a player, nil for server.
# Module.print_except (msg, player, color)

Takes msg and prints it to all players except provided player

Parameters:
  • msg : table if locale is used
  • player : the player not to send the message to
  • color : the color to use for the message, defaults to white
    # Module.random_RGB ()

    Returns a random RGB color as a table

    # Module.set_and_return (tbl, key, value)

    Sets a table element to value while also returning value.

    Parameters:
    • tbl : table to change the element of
    • key : string
    • value : nil|boolean|number|string|table to set the element to
    Returns:
    • value
    # Module.verify_mult_types (arg, arg_types)

    Asserts the argument is one of type arg_types

    Parameters:
    • arg : the variable to check
    • arg_types : the type as a table of sings
    Returns:
    • boolean

    Fields

    # Module.is_module_available

    Takes the string of a module and returns whether is it available or not

    • name : the name of the module (ex. 'utils.core')
    # Module.move_position

    Moves a position according to the parameters given Notice: only accepts cardinal directions as direction

    • position :
    table containing a map position
  • direction : north, east, south, west
  • distance :
  • # Module.opposite_direction

    Takes a direction and gives you the opposite

    • direction : north, east, south, west, northeast, northwest, southeast, southwest