在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Stevertus/mcscript开源软件地址(OpenSource Url):https://github.com/Stevertus/mcscript开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):Minecraft Script Documentation
Minecraft Script is a programming language for developers of mcfunctions, Minecraft maps and packages. The .mcscript files are therefore compiled and generated to the function format. This enables the developer extended possibilities, such as Modals, Loops, Varibles, Constants and Command-Wrapping. Visit the official Website for information, guides and videos: https://mcscript.stevertus.com German documentation here Table of ContentsInstallationThe Compiler gets offered as Node.js/ Package that is installed locally on your machine. It enables much more features than the online version 1.1 Installation of Node.jsThe installation requires the Node.js environment and the Node Package Manager. This is achieved the best way by using the installer: nodejs.org/en/download/ 1.2 Installation of Minecraft ScriptNow open your PCs console. (search CMD). There you have to type in this command:
If a successful answer apears you have done everything right and can start. CLI CommandsYou can now use the tool by launching the Command Line in your datapacks folder 2.1 mcscript newCreates a new datapack for you with all basic files in a scripts folder. Takes as argument the datapack id! 2.2 mcscript compileThis command converts all .mcscript files into .mcfunction format. You can read here what you can do in the mcscript files. Alternatively you can use 2.3 mcscript watchThis will automatically compile your code if you make any changes (save). So you do not have to enter the above command with every change. Again, a path and 2.4 mcscript add [url or package]This command adds a custom datapack to your directory. As argument an url to the resource or a mcScript Extension name can be used. Get a list of all supported packages by running just 2.5 Dev: mcscript modals!!This command is intended only for developers who want to install their modals in the compiler. 3) File system3.1 File setupThe generated files have always the same name as their root. A custom name can be set with Instead of the name, you can enter a whole path where the new file should be:
You can also specify several files:
Also very well combinable with for-loops:
3.2 Extend FilesA already existing file, that is generated before with
3.3 Global FilesVariables (#vars), [constants] (#consts), and [Modals] (#modals) are stored separately for each file. Now you can create a global file with the extension '. gl. mcscript '. The compiler automatically detects globals and uses the declared objects in other files as well. For example, you can write the modals to a separate file. Minecraft Script SyntaxThe code is written in files with the extension .mcscript. It is recommended to manage the files and to highlight the syntax in a code editor (IDE). explore more here. Unlike mcfunction, each command is injected with a "/" or "run:". Comments are announced with "//", if comments should also appear in the new file with "#" Blank lines and skipping lines are ignored. A comment across multiple lines can be expressed with:
4.1 Command Grouping / Wrapping
"as, at, positioned,align,in,dimension,rotated,anchored" can be grouped together:
The Argument / Arguments in the brackets have to be a string! (with ' ' or " ")
It is also possible to use
"Groups can be listed like so:
4.2 Functions
A function generates a new mcfunction with the given name or path. You can also execute the function directly with the e.g:
4.3 VariablesLike every other programming language there are variables. They are initialized as follows:
This value can be changed as often as you like.
Values can be assigned also only to special Minecraft selector like so. Also possible with playernames and placeholders:
Every value is saved in an independent scoreboard with it´s name or selector. So they are accessible with normal methods:
Variables can be merged together:
Bit shorter:
** Save command response to variable: **
The result of the command is written to the variable res.
Example with 4.4 Boolean Variables (Tags)
Boolean values can be declared like this.
With If testable:
4.5 ConstantsAnother type of variable is the constant, declared as following:
You can use it with
Replace constants The value of an constant can still be changed when used. To do this, add '.repl()' to the constant:
In our example, we want to replace
Also a RegEx can be inserted here and can be also accessed with '$&' in the replacement:
MapsMaps are essentially key-value pairs kind of like a dictionary. We define it with the Map-operator: const testMap = Map{
} In the brackets you can define as many pairs as you like: const testMap = Map{
"key1":"value",
"key2":"value2"
} It then can be accessed with /say $(testMap).key1
⇒ /say value ArraysArrays are pretty similar to Maps, but use a list of values instead of pairs: const testArr = Array{
"value", // index 0
"value2" // index 1
} The values can be accessed by the index of the item starting with 0. /say $(testArr).0
⇒ /say value
/say $(testArr).1
⇒ /say value2 4.6 If/Else StatementsIf functions are similar to grouping:
With some additional features:
4.7 Logical operatorsIn combination with grouping and if-else statements logical operators can be used:
4.8 Switch-Cases
Switches makes the case distinction much easier. It´s able to test easily and clearly certain variables. e.g:
Here test is checked for more than 10, if that does not apply to less than 10 and finally outputed as default. Also abbreviable:
4.9 For-LoopsOne of the most helpful features is the for loop. It takes in neutral numbers. From
with $(var_name) the loop variable can be accessed var_name is out of the box defined as "i", but can be changed with the third argument:
That makes especially with two-dimensional loops sence:
4.10 Raycasting
Raycasting is a big thing in Minecraft 1.13 and provides unlimeted opportunities. But it is a bit difficult, so why not making it easier? With Minecraft Script this is really really easy now:
This alone sets everywhere where you look a stone Particles and block limits are also pretty easy:
Now there are beautiful effects and a max range of 10 blocks. The second argument sets the porous blocks.
So the ray only goes through air. You can also negate the porous blocks and set with a "!" the not porous blocks:
The ray goes through all blocks, but white wool. As third optional argument a target can be set:
Now Mcscript knows that the target is a block and executes the command only if the block is white wool.
Now Mcscript knows that the target is an entity and executes as the entity if it´s hitted. So the armor stand would say test. 4.11 while loopsThe while loop is defined like so:
The grouped commands are executed as long as the condition [cond] is true.
As a condition, all operators and arguments of the If conditions can be used. e.g.
For while-loops you can also use stop and continue:
4.12 do-while-Loops
The do-while loop works in a similar way to the while loop, with the small difference that the code block is executed and then the condition is checked. So the loop is executed at least one time. 4.13 forEach-Loop
The forEach Loop is a loop found in almost any programming language. It is similar to Minecraft Script's for-loop, but it works dynamically (it does not run on generate, but in Minecraft) e.g:
The Command is executed 10 times and the current value is saved each in the scoreboard i. Der Command wird also 10mal ausgeführt und der aktuelle Wert jeweils in dem scoreboard i gespeichert. You can also access the value like so. e.g. Faculty:
4.14 ModalsModals are like functions or methods. That means you can define them:
A modal is always introduced with the keyword followed by the name and the arguments in the brackets. The arguments are accessible inside with $(argument_name).
If you use the modal like that, the values are used and it outputs everything.
You are also able to use multiple arguments. There are optional and predefined arguments, too:
Using Maps and Arrays You can also use the Map and Array type of constants in modals: modal defaultMap(args = Map{"key":"value"}){
/say $(args).key
}
defaultMap()
defaultMap(Map{
"key":"value2"
})
⇒ /say value
⇒ /say value2 Override Modals Modals that have already been created can be overridden within the process:
Arguments and actions are exchanged completely and used for the ongoing process. Replace arguments The value of an argument can still be changed when used. To do this, add '.repl()' to the argument:
In our example, we want to replace an entered test:
Also a RegEx can be inserted here and can be also accessed with '$&' in the replacement:
4.15 JavaScript ModalsJavaScript Modals are modals, you can write in JavaScript. You can define them like other modals:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论