Differences to other languages
This page will highlight the differences of Shulkerscript and vanilla mcfunction and mcscript.
Functions
The first difference you can see is that Shulkerscript takes a much different approach to functions than mcfunction and mcscript. The following example declares two functions and calls them second from the first one.
or alternatively
Comments
Comments can be expressed differently in all three languages. Shulkerscript uses //
for single-line comments and /* */
for multi-line comments.
Execute Command
Both Shulkerscript and mcfunction offer an easier way for using execute commands, as they are common when building datapacks.
If-Else Statements
Shulkerscript and mcscript offer a more convenient way to write if-else statements.
Logical operators
Both in Shulkerscript and mcscript, logical operators can be used to combine multiple conditions.
In the following code examples, the conditions are represented by A
, B
, etc. as placeholders for real conditions.
The AND operator takes precedence over the OR operator, so the above code is equivalent to A && (B || C)
.
The code is compiled in such a way, that regardless in which way the expression is true, the command will only run once.
Interfering with conditions
The difference between Shulkerscript and the other two languages is that Shulkerscript compiles to a version where it is not possible to trigger both the if and the else statement at the same time. This could be possible when using the trivial approach to translate the following to mcfunction:
Here the second command will always be executed, because if the condition is true, the command runs and falsifies the condition. When the inverted condition is checked in the second command, it will always be true. Shulkerscript fixes this by using a mix of anonymous functions and data stores.
Embedded Programming Language
Shulkerscript allows running Lua code during compilation and running the returned output in Minecraft, mcscript offers JavaScript modals.