Console Command Auto-completion
Auto-Complete
Auto-complete suggests possible continuations for
commands users are typing into their console.
This mechanic not only simplifies using commands
but also teaches users how they can use them.
Completion Function
Commands registered with concommand.Add
can be supplied with an auto-completion function.
This function can return an array of suggestions.
The suggestions will be displayed below the input.
Parameters
The completion function also receives 2 parameters that
allow you to return more context aware suggestions.
command
: String
Name of the command that called the auto-completion function.
parameters
: String
Anything written behind the commands itself.
command
parameter can have anycase (
mY-CoMMaND
) and should be normalized when used with lookup tables.the command's name, as such
parameters
will always start with a space character.Input Examples
Use Cases
The command
parameter can be used to substitude the commands name.
The parameters
string can be process & used for nested suggestions.
Only typing the command suggests two possible sub-commands.
Adding the was
sub-command displays only options specific to it.
Adding the is
sub-command displays only options specific to it.
Examples
Bot Name List
Suggests bot player names based on the current input.
Spawn some bot players with the bot
command.
Their names will be suggested as follows.
Console command replication
Console commands are not replicated. If you'd like to replicate a console command, you'll have to use AddCSLuaFile, or create custom behavior on both the server & the client.
Special thanks to old-time contributors for the images. The code was written by shawnjbragdon.