Skip to content
Tom Barham edited this page Sep 14, 2015 · 1 revision

MCA has five types of values that can be used. These are as follows:

  • Number - a numerical value
  • String - a piece of arbitrarily-sized text
  • Command - a Minecraft command-formatted command with arguments
  • Hashtable - an array-like structure for storing multiple values
  • Block - a block of statements

Additionally, the symbolic null value can be used to represent no value.

Number

A double-precision 64-bit binary format IEEE 754 value. There are also two symbolic values for numbers: NaN and Infinity.

MCA provides various comparison operators to deal with numbers, as well as binary operators.

Casting

  • To string - converting a number to a string will result in the number's base-10 value in string form.

String

Strings are a list of characters, put together to form a piece of text. Strings are immutable, meaning their value cannot be changed, however they can be 'cloned' with a change. String values should be surrounded with double or singlequotes.

Casting

  • To number - converting a string to a number will parse the number in IEEE 754-form, until a non-number value is encountered. The result will be NaN if conversion fails.
  • To hashtable - converting a string to a hashtable will create an array where each item corresponds to a character in the string.

Command

A command is a Minecraft-formatted command. They are composed of a forward slash, followed by the command name, followed by each argument separated with a space. Values can be 'injected' into the command with curly braces. For example, the command /say {message} with the variable message equal to "hi", becomes /say hi.

Casting

  • To number - converting a command to a number results in NaN.
  • To string - converting a command to a string will create a string with the raw value of the command (i.e /[command name] [command arguments]).

Hashtable

A hashtable is a set of key/value pairs, where keys can either be numbers or strings, and pairs can be any type of variable. Typically, hashtables are used for arrays or property pairs, and so the MCA core library provides various useful manipulation functions.

Hashtables are defined with square brackets, keys and values are separated with colons, and each pair is separated with a comma. For example,

[
    message1: "Hello",
    message2: "world!"
];

The key name and colon can be omitted, resulting in the key being auto-set to a numerical index, starting with 0. Trailing commas are allowed.

Casting

  • To number - converting a hashtable to a number results in NaN.
  • To string - converting a hashtable to a string will encode the hashtable as JSON.

Block

Blocks are a group of statements. For more information, see Blocks.

Casting

  • To number - converting a block to a number results in NaN.
  • To string - converting a block to a string will create a new string containing the code that makes up the block, including the argument list and curly braces.

null

null is a symbolic value that represents 'no value'. It has no special properties.

Casting

  • To number - converting a null value to a number results in NaN.
  • To string - converting a null value to a string creates a string with the value "null".
Clone this wiki locally