Syntax
With Ghost Commands, certain rules must be followed in order to succesfully execute commands.
- Input always start with the name of the command, followed by it's arguments.
- Arguments are separated with an empty space, unless they are enclosed in containers or quotations.
- Arguments can have multiple values, which are separated by a comma. Such as
Vector3
. - Custom type arguments should be enclosed in parantheses.
- Arrays are enclosed in square brackets.
So let's break it down.
A simple command
The first rule is, that any input must begin with the name of the command. Let's simply print a message to the console.
Initially, we would type: print
. Following this, we need to specify the message we wish to display. As the command anticipates a string
argument, we could input: print Hello
.
For a simple message, this would be sufficient. However, since arguments are separated by an empty space, the command would become invalid if we were to type: print Hello World
.
This is because we have technically supplied the print command with two distinct arguments when it only accepts one. In such instances, we simply enclose our argument in quotation marks: print "Hello World"
.
It is also possible to use '
to enclose strings.
Arguments with multiple values
Types can consist of multiple values, such as Vector3
. In code we'd make a Vector3
like so: new Vector3(5, 10, 20)
. Whereas in the command field, we would specify a Vector3
like this: (5, 10, 20)
. Alternatively, you could omit the parentheses, but in doing so, you must ensure there are no empty spaces between the values.
Specifying arrays
Imagine an arbitrary command called choose
that expects an array of numbers. To specify an array, we must enclose the values in square brackets: choose [1, 2, 3, 4, 5]
.
Another more advanced example would be an array of types. Let's pretend the choose
command anticipated an array of Vector3
, it would look like this: choose [(0, 0, 0), (-50, -10, 12), (10, 20, 30)]
.
Nested arrays are also supported.