Advanced Variable Commands
Beyond simple addition, subtraction, and the likes of it, there are commands dedicated to some more advanced usages that will be touched on in detail here.
String Manipulation
There are three commands dedicated to modifying the way strings look. These are useful when fine-tuning some text that will be displayed to a user. These commands are good because MCCompiled doesn't feature a good way to manipulate strings character by character. Each command takes in two parameters; first, the identifier of the preprocessor variable that will hold the result. Second, the identifier of the input data.
If only one identifier is specified, the language assumes you want to destructively modify the input variable. It's better to do this only if you're no longer going to use the original data.
All of these commands perform their operation on all values in the preprocessor variable. So, running $strupper
on a set of hello
world
would result in HELLO
WORLD
. If one of the values in the input is not a string, it is left untouched.
- Preprocessor String Uppercase
Transforms the given input string(s) to
UPPERCASE
.
- Preprocessor String Lowercase
Transforms the given input string(s) to
lowercase
.
- Preprocessor String Friendly Name
Transforms the given input string(s) to
Title Case
, which is more user-friendly. Additionally, converts any characters like_
or-
to spaces for user display.
Data Manipulation
These commands focus on extrapolating info from data (generally numbers) inside an array of objects. Each of them takes in two parameters; first, the identifier of the preprocessor variable that will hold the result. Second, the identifier of the input data.
If only one identifier is specified, the language assumes you want to destructively modify the input variable. It's better to do this only if you're no longer going to use the original data.
- Preprocessor Array Sum
Retrieve the sum of all elements in the given array.
- Preprocessor Array Median
Retrieve the middle element of the given data, or the average of the two middle values if even.
- Preprocessor Array Mean
Retrieve the mean (average) of all the elements in the given array.
- Preprocessor Array Length
Retrieve the number of elements (length) in the given array.
Array-Specific Manipulation
These commands are dedicated to manipulating preprocessor arrays and don't really serve a purpose on variables with single values. All of these commands destructively modify a single parameter, which is the identifier of the variable to modify.
- Preprocessor Array Sort
Sorts the values in the given array either ascending or descending.
Use the syntax:$sort [ascending|descending] [id: variable]
- Preprocessor Array Reverse
Reverse the order of the elements in the given array.
- Preprocessor Array Unique Values
Prune all non-unique values from the given array; as in, any value which == another value in the array.
- Preprocessor Array Append
Adds the given item(s) to the end of the given preprocessor variable, or contents of another preprocessor variable if specified.
- Preprocessor Array Prepend
Adds the given item(s) to the start of the given preprocessor variable, or contents of another preprocessor variable if specified.