Module ExpGamingCore.Command

A full ranking system for factorio.

Info:

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

Functions

format_inputs (command) Returns the inputs of this command as a formated string
validate_args (event) Used to validate the arguments of a command, will understand strings with "" as a single param else spaces divede the params
get_commands (player) Used to return all the commands a player can use
add_command (name[, description='No Description'][, inputs=an infite string], callback) Used to define commands

Tables

validate Collection of funcations that can be used to validate inputs

Fields

error Used as an error constant for validation
data Index of all command data


Functions

format_inputs (command)
Returns the inputs of this command as a formated string

Parameters:

  • command string, table or event the command to get the inputs of

Returns:

    string the formated string for the inputs

Usage:

    commands.format_inputs('interface') -- returns <code> (if you have ExpGamingCore.Server)
validate_args (event)
Used to validate the arguments of a command, will understand strings with "" as a single param else spaces divede the params

Parameters:

  • event table this is the event created by add_command not on_console_command

Returns:

    string the error that happend while parsing the args

Or

    table the args for this command

Or

    command.error

Usage:

    commands.validate_args(event) -- returns args table
get_commands (player)
Used to return all the commands a player can use

Parameters:

  • player index, name or player the player to test as

Returns:

    table a table containg all the commands the player can use

Usage:

    get_commands(1) -- return table of command data for each command that the player can use
add_command (name[, description='No Description'][, inputs=an infite string], callback)
Used to define commands

Parameters:

  • name string the name of the command
  • description string the description of the command (default 'No Description')
  • inputs table a table of the inputs to be used, last index being true makes the last parameter open ended (longer than one word) (default an infite string)
  • callback function the function to call on the event

Usage:

    --see examples in file

Tables

validate
Collection of funcations that can be used to validate inputs

Fields:

  • __comment replace _ with - the ldoc did not like me using - in the names
  • string basicly does nothing but a type filed is required
  • string_inf same as string but is infite in length, must be last arg
  • string_len same as string but can define a max lengh
  • number converts the input into a number
  • number_int conerts the input to a number and floors it
  • number_range allows a number in a range after it has been floored min < math.floor(X) <= max
  • number_range allows a number in a range after it has been floored min < math.floor(X) <= max
  • player converts the input into a valid player
  • player_online converts the input to a player if the player is online
  • player_alive converts the input to a player if the player is online and alive
  • player_rank -online converts the input to a player if the player is a lower rank than the user and online
  • player_rank -online converts the input to a player if the player is a lower rank than the user and online
  • player_rank_alive converts the input to a player if the player is a lower rank than the user and online and alive
  • type string the type that the value should be
  • value the value that will be tested
  • ... any other data that can be passed to the function

Usage:

    commands.validate[type](value,event,...)

Fields

error
Used as an error constant for validation

Usage:

  • return commands.error, 'err message'
  • return commands.error('err message')
data
Index of all command data
  • key string, table or event the command that will be returned: string is the name, table is the command data, event is event from add_command

Usage:

  • commands.command_name -- returns command data
  • commands.data -- returns all data
generated by LDoc 1.4.6 Last updated 2018-06-07 12:58:23