Commands - tayjay/SCriPt GitHub Wiki
- Aliases:
lua
,script
- Description: Lua command for executing Lua scripts and commands within the SCriPt environment.
- Alias:
exec
,execute
- Description: Executes some lua code directly.
- Peremission:
script.execute
- Usage:
lua execute <code>
- Alias:
reload
,rl
- Description: Reloads the Lua scripts in the LabAPI plugin. This is useful for development purposes when you want to test changes without restarting the server.
- Permission:
script.reload
- Usage:
lua reload
- Alias:
list
,ls
- Description: Lists all loaded scripts
- Permission:
script.list
- Usage:
lua list
- Alias:
docs
,documentation
,docgen
- Description: Generates documentation for the SCriPt API in the
SCriPt/Docs
directory. - Permission:
script.docs
- Usage:
lua docs
SCriPt allows you to create custom commands that players can use in-game. These commands can be used to perform any action you would like.
When creating a command, make sure it is inside a module. It can be a shared module with the rest of your code or its own. The command is registered when the module is loaded.
cmd_module = SCriPt.Mod('MyCommandModule')
cmd_module.command = SCriPt.Command(
CommandType.RemoteAdmin, -- Command Type
'mycommand', -- Name
{'mycmd'}, -- Alternate names
'Description of my command', -- Description
'script.mycommand', -- Permission required
function(args, sender) -- Function to run when called
return {
response = "Hello from my command!",
result = true
}
end
)
- Available Command Types:
CommandType.Console
CommandType.RemoteAdmin
CommandType.Client
- Name:
- Any string that doesn't conflict with existing commands.
- Aliases:
- A list of strings that can be used as alternative names for the command.
- Description:
- A string that describes what the command does. Is returned in the help command.
- Permission:
- A string that specifies the permission required to run the command.
- Leave empty if no permission is required.
- Execute:
- Define or reference a function that takes two arguments:
-
args
: A table containing the arguments passed to the command. -
sender
: The player who sent the command (CommandSender).
-
- Must return a table with:
-
response
: A string that will be sent back to the player. -
result
: A boolean indicating whether the command was successful or not.
-
- Define or reference a function that takes two arguments: