Module ExpGamingCore.Command
A full ranking system for factorio.
Info:
- License: https://github.com/explosivegaming/scenario/blob/master/LICENSE
- Author: Cooldude2606
validate |
Collection of funcations that can be used to validate inputs |
error |
Used as an error constant for validation |
data |
Index of all command data |
-
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')
-
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)
-
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)
-
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:
-
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,...)
-
error
-
Used as an error constant for validation
Usage:
-
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
commands.data