Date: 2014/03/30 20:36:56 UTC-07:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# +--------------------
# | On Command Event tutorial
# |
# | Denizen contains the ability to run script entries in the form
# | of a Bukkit /command. Here's an example script that shows basic usage.
On Command Event Tutorial:
type: world
# +-- EVENTS: Node --+
# To 'hook' into the on command event, just create a 'on <command_name> command'
# node as a child of the events node in any world script. Change out <command_name>
# with the desired name of the command. This can only be one word.
events:
# The following example will trigger on the use of '/testcommand'
on testcommand command:
# Why not state the obvious? Just to be sure!
- narrate 'You just used the /testcommand command!'
# You can utilize any arguments that come along with the command, too!
# <context.args> returns a list of the arguments, run through the Denizen argument
# interpreter. Using quotes will allow the use of multiple word arguments,
# just like Denizen!
# Just need what was typed after the command? Use <context.raw_args> for a String
# Element containing the uninterpreted arguments.
- define arg_size <context.args.size>
- narrate "'%arg_size%' arguments were used."
- if %arg_size% > 0 {
- narrate "wait how does if's work"
}
# Commands won't be checked for <replaceable tags> So if you type /testcommand <player.name>
# It won't be read as /testcommand mcmonkey
# If you want tags to be parsed (read and translated), you can instead use '<context.parsed_args>'
- narrate "With tag parsing, you input <context.parsed_args>"
- if %arg_size% > 0 {
- narrate "'<context.parsed_args.get[1]>' was the first argument."
}
# When a command isn't found, Bukkit reports an error. To let Bukkit know
# that the command was handled, use the 'determine fulfilled' command/arg.
- determine fulfilled