- Denizen Version
- REL-1759
About
Most command scripts have validation checks - remember, don't trust players - but you might find yourself repeating these throughout different commands. These injectable tasks standardize your checks and keep your scripts concise.Tasks
cmd_args
: Add arequired
key to the command script. Injecting this will check if enough args are provided. If not, the script is stopped and the player is shown the proper syntax.cmd_syntax
- This is used internally bycmd_args
, but you can inject this if you want to show the command syntax.cmd_err
- This task takes areason
definition which is then narrated in the error color. The player can hover over their message and see their command input. Additionally, the script checks if the reason definition exists, so you can inject it even if at that point it could be successful.cmd_player
- This task takes auser
definition which is the input name for an online player. If this input returns a match, the player is then saved back to the definition; otherwise, the script injectscmd_err
.cmd_offline_player
- The same ascmd_player
, but it can match either an online or offline player.
Example
Code:
say_hello:
type: command
name: hello
description: Say hello to another user!
usage: /hello <<>player<>>
required: 1
script:
- inject cmd_args
- define user <context.args.first>
- inject cmd_player
- narrate "<player.name> says hello!" targets:<[user]>