diff --git a/.gitignore b/.gitignore index 1c94789..f0ede44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ node_modules package-lock.json lib/modals/cam.mcscript +# examples +# Nodepad++ Highlighter.xml +# _changelog.md +# Core Modals.md +# *.html +# README-DE.md diff --git a/Core Modals.md b/Core Modals.md index 7cbffeb..9f2948b 100644 --- a/Core Modals.md +++ b/Core Modals.md @@ -1,7 +1,10 @@ # Minecraft Script Core Modals `- parameter -` + ` [optional] ` + ` ` + ` this | or that` ### console > `log( - text - , [entity] )` diff --git a/README-DE.md b/README-DE.md index fb3a65f..84a5264 100644 --- a/README-DE.md +++ b/README-DE.md @@ -80,6 +80,13 @@ Alternativ kannst mit `mcscript compile *filepath*` einen speziellen Pfad oder s Hiermit wird dein Code automatisch compiled, wenn du irgendwelche Änderungen machst (speicherst). So musst du nicht bei jeder Änderung den obigen Command eingeben. Auch hier kann ein Pfad angegeben werden. + +### 2.4 mcscript add [url or package] +Dieser Conmmand kann ein datapack zu deiner Welt hinzufügen. +Als Argument kann entweder eine Url direkt zur Datei oder der Name einer mcScript Extension genutzt werden. + +Eine Liste aller McScript Extensions kann bekommen werden mit `mcscript add` + ### 2.4 Dev: mcscript modals diff --git a/README.md b/README.md index 0b28a18..598a064 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + ![](https://i.imgur.com/YedWe7W.png) Minecraft Script Documentation @@ -17,6 +18,7 @@ German documentation [here](https://github.com/Stevertus/mcscript/blob/master/RE - [mcscript new](#cli-new) - [mcscript compile](#cli-compile) - [mcscript watch](#cli-watch) + - [mcscript add](#cli-add) 3) [Syntax](#syntax) - [file setup](#files) - [expand files](#extend) @@ -74,15 +76,22 @@ Creates a new datapack for you with all basic files in a scripts folder. Takes a This command converts all .mcscript files into .mcfunction format. You can read [here](#syntax) what you can do in the mcscript files. The console displays all generated files or throws an error if something was not correct. -Alternatively you can use `mcscript-compile *filepath*` to set an custom directory or file. +Alternatively you can use `mcscript compile *filepath*` to set an custom directory or file. ### 2.3 mcscript watch This 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 can be specified. + +### 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`mcscript add` + -### 2.4 Dev: mcscript modals +### 2.5 Dev: mcscript modals !!This command is intended only for developers who want to install their modals in the compiler. A file must be specified and then the modals out of this file are written to a configuration file. diff --git a/_changelog.md b/_changelog.md index 7843a0c..5652bec 100644 --- a/_changelog.md +++ b/_changelog.md @@ -11,6 +11,10 @@ Minecraft Script Changes * changed: . are now allowed in variable names * changed: the mcscript folder will be automaticly deleted! save important files!! * fixed: the forWeb.js file + +** v0.1.3.1** +* added: a `mcscript add` package command +* reduced file size ### v0.1.2 * changed: fixed asat to "at @s" * changed: raycasting is more accurate diff --git a/bin/add.js b/bin/add.js new file mode 100644 index 0000000..f59765c --- /dev/null +++ b/bin/add.js @@ -0,0 +1,54 @@ +var http = require('https'); +var fs = require('fs'); + +exports.addPack = function(name){ + let patt = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/) + if(patt.test(name)){ + download(name, "external") + } else http.get("https://download1350.mediafire.com/q7aa9e774jug/oyrbdi6fbpqo1bl/mcscri%27%2B%27pt+packages.json", (res) => { + res.setEncoding('utf8'); + res.on('data', function (chunk) { + let packs = JSON.parse(chunk) + let obj = packs.find(obj => obj.name === name.toLowerCase()) + if(obj && obj.url){ + console.log(obj.url.slice(0, 17)) + if(obj.url.slice(0, 17) == "https://github.com" || obj.url.slice(0, 16) == "http://github.com") downloadFromRedirectLink(obj.url, obj.name) + else download(obj.url, obj.name) + } else { + let packStr = "" + packs.forEach((e, i) => { + packStr += e.name + if(i != packs.length - 1) packStr += ", " + }) + console.log("\x1b[31m","Your pack was not found! Please use one of these: ","\x1b[0m") + console.log("\x1b[36m",packStr,"\x1b[0m") + } + }); + + }).on('error', function(e) { + console.log("\x1b[31m","Got error: " + e.message,"\x1b[0m"); + }); +} +var download = function (url, name){ + console.log("\x1b[36m","Downloading "+name+".zip ...","\x1b[0m") + let file = fs.createWriteStream(name + '.zip'); + let request = http.get(url, function(response) { + response.pipe(file) + response.on('end', () => { + console.log("\x1b[32m","Download of "+name+".zip finished!","\x1b[0m") + }); + }).on('error', function(e) { + console.log("\x1b[31m","Got error: " + e.message,"\x1b[0m"); + }); +} +function downloadFromRedirectLink(url, file) { + http.get(url, function(res) { + if(res.statusCode != 302){ + console.log("error: no redirect found"); + return; + } + download(res.headers.location,file); + }).on('error', function(e) { + console.log("\x1b[31m", "Got error: " + e.message,"\x1b[0m"); + }); +} diff --git a/bin/test-module.js b/bin/test-module.js index 97ee3f7..1910f3d 100644 --- a/bin/test-module.js +++ b/bin/test-module.js @@ -1,6 +1,7 @@ #!/usr/bin/env node var lib= require('../lib/index.js'); +var addPack = require('./add.js'); var gen_new = require('../lib/gen_new.js'); // lib.compile(process.argv[2] || './') switch(process.argv[2]){ @@ -15,5 +16,8 @@ switch(process.argv[2]){ if(process.argv[3]) gen_new.new(process.argv[3]) else console.log("\x1b[31m","You have to enter a datapack id!","\x1b[0m") break + case 'add': + addPack.addPack(process.argv[3] || "") + break default: console.log("\x1b[31m","Please select a sub command","\x1b[0m") } diff --git a/documentation.html b/documentation.html index d8159b9..2794897 100644 --- a/documentation.html +++ b/documentation.html @@ -1,17 +1,17 @@

-

Minecraft Script Dokumentation

+

Minecraft Script Documentation

-

Update 0.1.3: Alle Änderungen

+

Update 0.1.3: All Changes

-

Minecraft Script ist eine Programmiersprache für Entwickler der mcfunctions, sowie für die Minecraft Map und Package Erschaffer. Die .mcscript Dateien werden dabei zu mcfunction compiled und generiert. Dies bietet dem Entwickler erweiterte Möglichkeiten, wie zum Beispiel Modals, Loops, Variablen, Konstanten und Command-Wrapping.

-

Wer das ausprobieren möchte oder Beispiele anschauen möchte, kann meinen playground stevertus.ga/tools/mcscript besuchen und etwas herumspielen.

-

English documentation here

+

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.

+

Everyone who wants to try, can visit my playground stevertus.ga/tools/mcscript and can play with its function.

+

German documentation here

Table of Contents

  1. Installation
  2. Cli Commands @@ -19,129 +19,133 @@

    Table of Contents

  3. mcscript new
  4. mcscript compile
  5. mcscript watch
  6. +
  7. mcscript add
  8. Syntax
  9. -
  10. IDEs und Syntax Highlighting
    +
  11. IDEs and Syntax Highlighting
-

1) Installation

-

Der Compiler wird auch als Node.js/ Package angeboten, das lokal auf dem PC installiert wird und viele Features mehr hat: als die Online-Version hat.
-z.B: Alle Dateien in einem Ordner gleichzeitig compilen, direkter Output in neuen Dateien, auf Dateiänderungen “watchen”, uvm.
+

Installation

+

The Compiler gets offered as Node.js/ Package that is installed locally on your machine. It enables much more features than the online version
+For example: compile all files in a directory, direct output in new files, watch your files on changes, etc.

-

1.1 Installation von Node.js

-

Für die Installation wird die Node.js Umgebung und der Node Package Manager benötigt.

-

Diese installiert man am besten über den Installer: nodejs.org/en/download/
-Den einfach ausführen und installieren lassen.
+

1.1 Installation of Node.js

+

The 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/
+Just run it and install.

-

1.2 Installation von Minecraft Script

-

Öffne nun die Konsole deines PCs (Am besten über Suche unter CMD zu erreichen).

-

Hier muss nun dieser Command eingegeben werden:

+

1.2 Installation of Minecraft Script

+

Now open your PCs console. (search CMD).

+

There you have to type in this command:

npm install -g mcscript

-

Bei einer erfolgreichen Antwort hast du alles richtig gemacht und kannst durchstarten.
+

If a successful answer apears you have done everything right and can start.

-

2) CLI Commands

-

Das Tool kannst du nun anwenden, indem du die Command Line in deinen Datapacks Ordner startest
-(über Shift + Rechtsklick auf Ordner -> Eingabeaufforderung hier öffnen)
-Nun kannst du die Kommandos benutzen:
+

CLI Commands

+

You can now use the tool by launching the Command Line in your datapacks folder
+(with Shift + rightclick on directory -> open command line)
+Now you can use the commands like that:

2.1 mcscript new

-

Dieser Command generiert dir ein vorgefertigtes Datapack mit allen basic Dateien und einem Scripts-Ordner. Als Argument muss die Id des Packs angegeben werden!
+

Creates a new datapack for you with all basic files in a scripts folder. Takes as argument the datapack id!

2.2 mcscript compile

-

Dieser Command wandelt alle .mcscript Dateien in .mcfunction Format um. Was in den mcscript Dateien möglich ist, kannst du hier nachlesen.
-In der Konsole werden alle generierten Dateien angezeigt oder ein Fehler ausgeworfen, falls etwas nicht korrekt war.

-

Alternativ kannst mit mcscript compile *filepath* einen speziellen Pfad oder spezielle Datei angeben.
+

This command converts all .mcscript files into .mcfunction format. You can read here what you can do in the mcscript files.
+The console displays all generated files or throws an error if something was not correct.

+

Alternatively you can use mcscript compile *filepath* to set an custom directory or file.

2.3 mcscript watch

-

Hiermit wird dein Code automatisch compiled, wenn du irgendwelche Änderungen machst (speicherst). So musst du nicht bei jeder Änderung den obigen Command eingeben.

-

Auch hier kann ein Pfad angegeben werden.
-

-

2.4 Dev: mcscript modals

-

!!Dieser Command ist nur für Entwicker gedacht, die ihre Modals in den Compiler einbauen wollen.
-Es muss eine Datei angegeben werden und die Modals aus dieser Datei werden dann in eine Konfigurationsdatei geschrieben.
+

This 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 can be specified.
+

+

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 justmcscript add

+

+

2.5 Dev: mcscript modals

+

!!This command is intended only for developers who want to install their modals in the compiler.
+A file must be specified and then the modals out of this file are written to a configuration file.

Minecraft Script Syntax

-

Der Code wird in Dateien mit der Endung .mcscript geschrieben. Es wird ein Code-Editor(IDE) empfohlen, um die Dateien zu verwalten und den Syntax farbig zu markieren. Mehr hier

-

Anders als bei mcfunction wird jeder Command mit einem “/” oder "run: " injektiert.

-

Kommentare werden mit “//” angekündigt, falls Kommentare auch in der neuen Datei auftauchen sollen mit “#”

-

Leerzeilen und Zeilensprünge werden nicht beachtet.
-Falls eine Leerzeile aus Struktur in der mcfunction gewünscht ist, dies mit einem # ohne Kommentar ausdrücken.
-Zwei Leerzeilen können mit “##” erreicht werden.
+

The 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.
+If a blank line is desired in the mcfunction, express this with a ‘#’ without a comment.
+Two blank lines are reached with “##”.

3.1 File setup

-

In einem Minecraft Datapack können alle Datein in ein scripts Ordner gepackt werden, um dann in /functions den Output zu generieren.
-Es werden immer Dateien mit gleichem Namen, wie ihr Root generiert.

-

Ein benutzerdefinierter Name kann mit #file: *name* gesetzt werden.
-Bitte ohne .mcfunction!!

-

Statt des Namen kann auch gleich ein ganzer Pfad, an dem die neue Datei sein soll, angegeben werden:

+

The generated files have always the same name as their root.

+

A custom name can be set with #file: *name*.
+Please without .mcfunction!!

+

Instead of the name, you can enter a whole path where the new file should be:

-

Es können auch mehrere Dateien spezifiziert werden:

-
#file: neu
-//commands hier
-#file: zwei
-//Commands für zwei hier
-
-

Auch sehr gut mit for-loops kombinierbar:

-
#file: neu
-//commands hier
+

You can also specify several files:

+
#file: new
+//commands here
+#file: two
+//Commands for two
+
+

Also very well combinable with for-loops:

+
#file: new
+//commands here
 for(1,5){
 	#file: test$(i)
-	//Commands für jede Datei hier
+	//Commands for every file here
 }
 

-

3.2 Dateien erweitern

-

Eine bereits bestehende Datei, vorher mit #file:, kann nun auch aus anderen Dateien erweitert werden und neuer Code einfach hinten drangehängt werden:

+

3.2 extend files

+

A already existing file, that is generated before with #file:, can be expanded in other files and new code is easily attached:

#extend: ./test
-/commands kommen hier.
+/commands here
 

-

3.3 Command Gruppen / Wrapping

+

3.3 Command Grouping / Wrapping

[subcommand]([argument]){ [wrapped actions] }

-

“as, at, positioned,align,dimension,rotated,anchored” können zusammengefasst werden:

-
as('@a'){
+

“as, at, positioned,align,dimension,rotated,anchored” can be grouped together:

+
as(@a){
 	/commands 	=> /execute positioned ~ ~ ~ run command
 }
 
-

In den Klammern muss das jeweilige Argument als String, sprich " " oder ’ ’ stehen!
-Auch ist der eigende asat() möglich

+

The Argument / Arguments in the brackets have to be a string! (with ’ ’ or " ")
+It is also possible to use asat() for this:

asat(@s){
     /commands => execute as @s at @s run commands
 }
 
-

"Gruppen können auch aufgelistet werden:

-
as('@p'), at('@s'), positioned('~ ~1 ~'){
+

"Groups can be listed like so:

+
as(@p), at(@s), positioned('~ ~1 ~'){
 	/say command
 }
 ==> /execute as @p at @s positioned ~ ~-1 ~ run say command
@@ -154,93 +158,91 @@ 

3.3 Command Gruppen / Wrapping

3.4 Variablen

-

Wie jede Programmiersprache hat auch Minecraft Script Variablen. Sie müssen wiefolgt initialisiert werden:
+

Like every other programming language there are variables. They are initialized as follows:
var test
-Der Variablen kann ein Wert hinzugewiesen werden:

+The variable can take in a value:

var test = 5
-# oder
+# or
 var test
 test = 6
 
-

Dieser Wert kann beliebig oft wieder verändert werden.

+

This value can be changed as often as you like.

var test
 test @s = 10
 
-

So können Werte auch nur speziellen Minecraft Selektoren zugewiesen werden.
-Auch mit Spielernamen oder Placeholdern möglich:

-
test Spielername = 10
+

Values can be assigned also only to special Minecraft selector like so.
+Also possible with playernames and placeholders:

+
test player = 10
 
-

Alle Werte werden in einem scoreboard mit dem Variablennamen gespeichert. Also können die Werte auch ganz standart mäßig verändert und ausgelesen werden:

+

Every value is saved in an independent scoreboard with it´s name or selector. So they are accessible with normal methods:

var test
 test @s = 10
 /scoreboard players get @s test ==> 10
 /scoreboard players set @s test 5
 # etc
 
-

Variablen können auch mit anderen zusammen gerechnet und zusammengefügt werden:

+

Variables can be merged together:

var test = 10
-var neu = 5
-# Achtung: Der Einfachkeit halber starte ich immer wieder mit diesen Werten. Das Programm macht es nartürlich anders!
+var new = 5
+#  For the sake of simplicity, I start again and again with these values. The program makes it naturally different!
 
 test += 2 ==> 12
 test -= 2 ==> 8
 
-

Etwas gekürzt:

+

Bit shorter:

test++ ==> test += 1
 test-- ==> test -= 1
 
-test += neu ==> 15
-test -= neu ==> 5
-test *= neu ==> 50
-test /= neu ==> 2
-test %= neu ==> 0
+test += new ==> 15
+test -= new ==> 5
+test *= new ==> 50
+test /= new ==> 2
+test %= new ==> 0
 

-

3.5 Boolean Variablen (Tags)

+

3.5 Boolean Variables (Tags)

bool [name] [selector](optional) = true|false

-

So können Wahrheitswerte deklariert werden.
+

Boolean values can be declared like this.
bool isCool = true => tag [global] add isCool
-Eine Boolean Variable kann später noch verändert werden:
+The variable can be changed later:
isCool = false => tag [global] remove isCool

-

Mit If testbar:

+

With If testable:

if(isCool){
     /commands => execute if entity [global][tag=isCool] run commands
 }
 

-

3.6 Konstanten

-

Eine andere Art Variable ist die Konstante, so deklariert:

-
-

const [name] = [value]

-
-

Diese Art kann nicht verändert werden!
-Du kannst sie mit $(var_name) irgendwo in deinem Code benutzen um lange Strings und wiederholende Phrasen zu vermeiden:

-
const einString = "Hier könnte sehr viel Schrott stehen."
-const eineNum = 5
+

3.6 Constants

+

Another type of variable is the constant, declared as following:
+const test = [value]
+This type cannot be changed!

+

You can use it with $ (var_name) somewhere in your code to avoid long strings and repetitive phrases:

+
const aString = "Here can be a string"
+const aNum = 5
 
-/say $(einString)       ==> /say Hier könnte sehr viel Schrott stehen.
-var test = $(eineNum)   ==> var test = 5
+/say $(aString)       ==> /say Here can be a string
+var test = $(aNum)   ==> var test = 5
 

-

3.7 If/Else Statements

-

If funktioniert ähnlich wie das Command Wrapping:

+

3.6 If/Else Statements

+

If functions are similar to grouping:

if('statement'){
 	/commands 	=> /execute if statement run command
 }
 
-

Mit einigen extra Features:

+

With some additional features:

  • -

    Vor dem Argument kann ein “!” eingefügt werden um dies umzukehren:

    +

    In front of every argument a “!” can be inserted to reverse the meaning:

    if(!'statement'){
     	/commands 	=> /execute unless statement run command
     }
     
  • -

    Nach dem Schluss kann ein “else” angehängt werden:

    +

    After the end an “else” can be attached:

    if('statement'){
@@ -249,14 +251,16 @@ 

3.7 If/Else Statements

/commands2 }
-

Hier darauf achten das Argument nicht zu verändern!

+
Important: Do not change the argument!
+
    if('entity @s[tag=test]'){
     	/tag @s remove test
-    	} else {
+    } else {
     	/tag @s remove test
     }
 
-

Hier werden beide ausgeführt!! Verbessert:

+
They are both executed!! Improved:
+
    if('entity @s[tag=test]'){
     	/tag @s add testIf
     }
@@ -267,7 +271,7 @@ 

3.7 If/Else Statements

}
    -
  • auch “else if” ist möglich:
  • +
  • even “else if” is possible:
    if('statement'){
     	/commands 				=> /execute if statement run command
@@ -276,27 +280,26 @@ 

3.7 If/Else Statements

}

-

3.8 Logische Operatoren

-

In Kombination mit Command Gruppen und If-Else-Statements können zusätzlich logische Operatoren benutzt werden:

+

3.8 Logical operators

+

In combination with grouping and if-else statements logical operators can be used:

    -
  • Der Oder-Operator kann bei den Gruppierungen auf zwei Arten benutzt werden:
  • +
  • The or operator can be used in two ways:
-
    as(@s||@p){
+
    as('@s'||'@p'){
     	/command
     }
     ==> execute as @s run command
         execute at @p run command
 
-    # oder als Liste
-    if(@s[tag=entity1],'entity @s[tag=entity2]'){
-    # hier gehen beide Varianten ^
+    # or as list
+    if('entity @s[tag=entity1]','entity @s[tag=entity2]'){
     	/command
     }
     ==> execute if entity @s[tag=entity1] run command
         execute if entity @s[tag=entity2] @p run command
 
    -
  • Der Und-Operator wird so definiert: (nur für if-statements sinnvoll)
  • +
  • The and operator is defined like so (makes only really sense with if)
    if('entity @s'&&'entity @p'){
     	/command
@@ -304,31 +307,31 @@ 

3.8 Logische Operatoren

==> execute if entity @s if entity @p run command
    -
  • Überprüfung von Variablen:
  • +
  • check variables:
var test = 5
 
-# genau gleich
+# equally
 if(test == 5){
     /commands
 }
 
-# größer/kleiner gleich
+# greater/smaller or equal
 if(test >= 5){
     /commands
 }
 
-# größer/kleiner
+# greater/smaller
 if(test > 5){
     /commands
 }
 
-# auch im Vergleich möglich
+# also avalible as comparison
 if(test > test2){
     /commands
 }
 
-# oder mit entity variablen
+# or with variables with entitys
 if(test @s > test2 @a){
     /commands
 }
@@ -344,120 +347,138 @@ 

3.9 Switch-Cases

} }
-

Switches erleichtern dem Benutzer die vielen If-Bedingungen. Es kann einfach und übersichtlich auf verschiedene Werte von Variablen getestet werden.
-bsp:

+

Switches makes the case distinction much easier. It´s able to test easily and clearly certain variables.
+e.g:

var test = 10
 switch(test){
     case > 10 {
-        /say var ist über 10
+        /say var is over 10
     },
     case < 10 {
-        /say var ist unter 10
+        /say var is under 10
     },
     default {
-        /say nichts traf zu.
+        /say no match
     }
 }
 
-

Hier wird also test geprüft auf über 10, wenn das nicht zutrifft auf unter 10 und als standart default ausgegeben.
-Auch abkürzbar:

+

Here test is checked for more than 10, if that does not apply to less than 10 and finally outputed as default.
+Also abbreviable:

var test = 10
 switch(test){
-    case > 10 run: say var ist über 10
-    , case < 10 run: say var ist unter 10
-    , default run: say nichts traf zu.
+    case > 10 run: say var is over 10
+    , case < 10 run: say var is under 10
+    , default run: say no match
 }
 

3.10 For-Loops

-
for([from],[to],[var_name](optional)){
-    [actions]
-}
-
-

Einer der hilfreichsten Features ist der For-Loop. Als Argumente werden ganze Zahlen angenommen.

-

Von erstes Argument bis zweites Argument wird optional ausgegeben als drittes Argument

-
for(1,5){
+

One of the most helpful features is the for loop. It takes in neutral numbers.

+

From first Argument to second Argument is optional outputed as third Argument

+
 for(1,5){
 	/commands
-	# es wird 5x command ausgegeben
+	# is outputed 5 times
 }
 
-
for(1,5){
+
 for(1,5){
 	/say $(i)
-	# es wird 5x say mit 1 - 5 ausgegeben
+	# say with 1 - 5 is outputed 5 times
 }
 
-

Mit $(var_name) kann auf den Loopwert zugegriffen werden.

-

var_name ist normalerweise als “i” definiert, kann aber im 3.Argument geändert werden:

+

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:

for(1,5,X){
 	/say $(X)
-	# es wird 5x say mit 1 - 5 ausgegeben
-}
+	# say with 1 - 5 is outputed 5 times}
 
-

Das ist bei 2 dimensionalen Loops sinnvoll:

+

That makes especially with two-dimensional loops sence:

for(1,5,i){
 	for(1,2,j){
 		/say $(i).$(j)
 	}
-	# es wird 10x say mit 1.1 - 5.2 ausgegeben
+	# say with 1.1 - 5,2 is outputed 10 times
 }
 

3.11 Raycasting

-
raycast([distance](optional), [block to travel through](optional)){
-    [actions on hitted block]
+
raycast([distance](optional), [block to travel through](optional),entity | block [target](optional) ){
+    [actions on hitted block or entity]
 },{
     [actions for every flight step]
 }
 default distance = 100 Blocks
 default block = air
+default target = any block
 
-

Raycasting ist eine große Sache in Minecraft 1.13 und bietet viele Möglichkeiten.
-Es ist allerdings bisschen schwierig, also warum nicht leichter machen?
-Mit Minecraft Script ist das nun sehr sehr einfach:

+

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:

raycast {
     /setblock ~ ~ ~ stone
 }
 
-

Das alleine setzt überall, wo man hinschaut einen Steinblock.
-Partikel und Blockbegrenzung auch noch sehr einfach:

+

This alone sets everywhere where you look a stone
+Particles and block limits are also pretty easy:

raycast(10) {
     /setblock ~ ~ ~ stone
 }, {
     /particle flame ~ ~ ~
 }
 
-

Jetzt haben wir schöne Effekte und eine maximale Range von 10 Blöcken.
+

Now there are beautiful effects and a max range of 10 blocks.
+The second argument sets the porous blocks.

+
raycast(10,"air") {
+    /setblock ~ ~ ~ stone
+}
+
+

So the ray only goes through air.
+You can also negate the porous blocks and set with a “!” the not porous blocks:

+
raycast(10,!"white_wool") {
+    /setblock ~ ~ ~ stone
+}
+
+

The ray goes through all blocks, but white wool.

+

As third optional argument a target can be set:

+
raycast(10,"air",block "white_wool") {
+    /setblock ~ ~ ~ stone
+}
+
+

Now Mcscript knows that the target is a block and executes the command only if the block is white wool.

+
raycast(10,"air",entity @e[type=armor_stand]) {
+    /say test
+}
+
+

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.

-

3.12 while-Loops

-

Der while-Loop ist so zu definieren:

+

3.12 while loops

+

The while loop is defined like so:

while([cond]){
     /commands
 }
 
-

Die gruppierten Commands werden solange ausgeführt, wie die Bedingung[cond] war ist.

+

The grouped commands are executed as long as the condition [cond] is true.

-

Wenn die Bedingung zum Start nicht wahr ist, wird die Gruppierung nicht ausgeführt!

+

If the condition to start is not true, the grouping will not be executed!

-

Als Bedingung können hier alle Operatoren und Argumente der If-Bedingungen verwendet werden. z.B.

+

As a condition, all operators and arguments of the If conditions can be used. e.g.

var test = 0
 while(test < 10){
-    /commands hier
+    /commands here
     test += 1
 }
-# ==> Die Commands werden innerhalb eines Ticks 10mal ausgeführt.
+# ==> The commands are executed 10x in one tick
 
-

Bei while-Loops kann auch mit stop und continue gearbeitet werden:

+

For while-loops you can also use stop and continue:

var test = 0
 while(test < 10){
     test += 1
     if(test == 5){
         continue
-        # Wenn test 5 ist werden die restlichen Commands übersprungen
+        # If test is equal to 5 the other commands are skipped
     }
     /commands hier
     if(test >= 9){
         stop
-        # Wenn test 9 oder über 9 ist wird die Schleife abgebrochen
+        # If test is equal to or over 5 the loop is stopped
     }
 }
 
@@ -467,23 +488,24 @@

3.13 do-while-Loops

/commands } while([cond])
-

Der do-while-Loop funktioniert ähnlich, wie der while-Loop mit dem kleinen Unterschied, dass der Codeblock ausgeführt wird und danach erst die Bedingung geprüft wird.
-Der Loop wird also mindestens einmal durchlaufen.
+

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.

3.14 forEach-Loop

-
forEach(var [var_name] = [startwert]; [var_name] ==|>|<|<=|>=|!= [other_var]|[number]; [varname]++){
+
forEach(var [var_name] = [start value]; [var_name] ==|>|<|<=|>=|!= [other_var]|[number]; [varname]++){
     /commands
 }
 
-

Der forEach-Loop ist ein Loop, wie man ihn in fast jeder Programmiersprache vorfindet.
-Er ähnelt sich zu dem for-Loop von Minecraft Script, funktioniert aber dynamisch(d.h wird nicht beim generieren ausgeführt, sondern von Minecraft)

-

Bsp:

+

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:

forEach(var i = 0; i < 10; i++){
     /say hey
 }
 
-

Der Command wird also 10mal ausgeführt und der aktuelle Wert jeweils in dem scoreboard i gespeichert.
-So kann man auch auf den Wert zugreifen. Bsp. Fakultät:

+

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:

var result = 1
 forEach(var i = 2; i <= 10; i++){
     result *= i
@@ -492,17 +514,13 @@ 

3.14 forEach-Loop

3.15 Modals

-
modal [name]([arguments]){
-    [actions]
-}
-
-

Modals kann man wie functions oder Methoden verstehen, dass heißt man kann sie definieren:

+

Modals are like functions or methods. That means you can define them:

modal newModal(argument){
 	/say $(argument)
 }
 
-

Ein Modal wird immer mit dem Keyword eingeleitet, gefolgt von dem Namen und in Klammern alle benötigten Argumente.

-

Auf diese Argumente kann dann innerhalb mit $(argument_name) Referenz genommen werden.

+

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).

modal newModal(argument){
 	/say $(argument)
 }
@@ -511,7 +529,7 @@ 

3.15 Modals

# => say test
-

Wenn man das Modal so benutzt, dann werden die Werte eingesetzt und alles ausgegeben.

+

If you use the modal like that, the values are used and it outputs everything.

modal createCommand(command,argument1,argument2){
 	/$(command) $(argument1) $(argument2)
 }
@@ -520,8 +538,8 @@ 

3.15 Modals

# => say hallo du
-

Es können so auch mehrere Argumente benutzt werden.

-

Auch sind optionale und vordefinierte Argumente verfügbar:

+

You are also able to use multiple arguments.

+

There are optional and predefined arguments, too:

modal say(argument = "hallo"){
 	/say $(argument)
 }
@@ -533,13 +551,17 @@ 

3.15 Modals

# => say test

-

3.16 System Modals

-

Es gibt schon einige vordefinierte Modals, die hilfreich sein könnten. Bitte schaue dir dafür die spezifischen Dokumentationen hier an.

-

Du hast Ideen, welche Modals unbedingt als Standart-Modal aufgegriffen werden müssen? Sende mir einfach die Konfigurationsdatei zur Überprüfung.

-

IDEs und Syntax Highlighting

+

3.11 System Modals

+

There are already some helpful predefined modals. Please read the specific documentation here.

+

You have ideas which modals should be a standart? Send me your configuration file to check.
+

+

IDEs and Syntax Highlighting

+
+

Not available yet

+
-

Jetzt bleibt nichts mehr übrig als: Happy Developing

-

Vielen Dank an alle die Minecraft Script benutzen und diese Dokumentation gelesen haben. Bei Vorschlägen, Problemen oder Fehlern bitte mich kontaktieren.

+

Now there´s nothing left than: Happy Developing

+

Thanks to all who use Minecraft Script and read this documentation. Contact me if you have a proposal, problem or error.

diff --git a/package.json b/package.json index 45bc153..242ee36 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,12 @@ { "name": "mcscript", - "version": "0.1.3", + "version": "0.1.3.1", "description": "Minecraft Script to mcfunction compiler cli", "homepage":"http://stevertus.ga/mcscript", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Stevertus", - "person": "Barney Rubble (http://barnyrubble.tumblr.com/)", "repository" : { "type" : "git" , "url" : "https://github.com/Stevertus/mcscript.git"