Custom Commands
Kohl's Admin is currently in development. Everything in these docs is subject to change.
Custom commands are a powerful feature that lets you personalize Kohl's Admin, automate tasks, streamline your workflows, and create unique interactions within your experience.
Prerequisites
- Make sure you have Kohl's Admin: Ensure that Kohl's Admin is present in your experience.
- Addons Folder: Confirm that Kohl's Admin has a folder named
Addons
. This is where you'll place your custom command scripts.
Addon Setup
All custom commands are part of an Addon. For this section we will create addons that only create custom commands, but in later parts we will show the extent of what addons can do.
All addons are a ModuleScript that returns a function. To start, create a module script and inside of it write the following:
return function(_K)
-- Addon code goes here!
end
Inside of this function is where we will be adding our custom commands. The name of the addon can be anything, but for this example we encourage "customCommands".
Adding Client
or Server
an Addon file's name will make it only run in that context. This will make the other context unaware of the command!
Creating a Custom Command
To create a custom command, you must register it with the Registry, using registerCommand().
Using this, our module becomes:
return function(_K)
_K.Registry.registerCommand(_K, commandDefinition)
end
commandDefinition
is a placeholder for the real contents of our command! Commands require a lot of information, structured in a commandDefinition.
type commandDefinition {
name: string, -- Name of the command.
aliases: { string }?, -- Table of aliases.
description: string, -- Description of what the command does.
group: string, -- What group the command belongs to.
noLog: boolean?, -- If the command should be hidden from logs.
args: { ArgumentDefinition }?, -- A table of argument definitions.
permissions: { [string]: boolean }? -- A table of role permissions required to run the command.
envClient: {} | () -> {}?, -- Sets up an environment for the command.
env: {} | () -> {}?, -- Sets up an environment for the command.
runClient: (...any) -> ()?, -- What runs on the client of the player that ran the command.
run: (...any) -> ()? -- What the command runs on the server.
}
Look at the Example Addon to learn how to customize a commandDefinition.
You can put multiple custom commands in one addon! All you need to do is register multiple commands in the same module.