Skip to content

Commit 4fee57e

Browse files
committed
0.1.3.1
1 parent e2d228d commit 4fee57e

File tree

9 files changed

+314
-206
lines changed

9 files changed

+314
-206
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
node_modules
22
package-lock.json
33
lib/modals/cam.mcscript
4+
# examples
5+
# Nodepad++ Highlighter.xml
6+
# _changelog.md
7+
# Core Modals.md
8+
# *.html
9+
# README-DE.md

Core Modals.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Minecraft Script Core Modals
22
`- parameter -`
3+
34
` [optional] `
5+
46
` <allowed types>`
7+
58
` this | or that`
69
### console
710
> `log( - text <string | number> - , [entity] )`

README-DE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ Alternativ kannst mit `mcscript compile *filepath*` einen speziellen Pfad oder s
8080
Hiermit wird dein Code automatisch compiled, wenn du irgendwelche Änderungen machst (speicherst). So musst du nicht bei jeder Änderung den obigen Command eingeben.
8181

8282
Auch hier kann ein Pfad angegeben werden.
83+
<a id="cli-add"></a>
84+
### 2.4 mcscript add [url or package]
85+
Dieser Conmmand kann ein datapack zu deiner Welt hinzufügen.
86+
Als Argument kann entweder eine Url direkt zur Datei oder der Name einer mcScript Extension genutzt werden.
87+
88+
Eine Liste aller McScript Extensions kann bekommen werden mit `mcscript add`
89+
8390
<a id="cli-modals"></a>
8491
### 2.4 Dev: mcscript modals
8592

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
![](https://i.imgur.com/YedWe7W.png)
23

34
Minecraft Script Documentation
@@ -17,6 +18,7 @@ German documentation [here](https://github.com/Stevertus/mcscript/blob/master/RE
1718
- [mcscript new](#cli-new)
1819
- [mcscript compile](#cli-compile)
1920
- [mcscript watch](#cli-watch)
21+
- [mcscript add](#cli-add)
2022
3) [Syntax](#syntax)
2123
- [file setup](#files)
2224
- [expand files](#extend)
@@ -74,15 +76,22 @@ Creates a new datapack for you with all basic files in a scripts folder. Takes a
7476
This command converts all .mcscript files into .mcfunction format. You can read [here](#syntax) what you can do in the mcscript files.
7577
The console displays all generated files or throws an error if something was not correct.
7678

77-
Alternatively you can use `mcscript-compile *filepath*` to set an custom directory or file.
79+
Alternatively you can use `mcscript compile *filepath*` to set an custom directory or file.
7880
<a id="cli-watch"></a>
7981
### 2.3 mcscript watch
8082

8183
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.
8284

8385
Again, a path can be specified.
86+
<a id="cli-add"></a>
87+
### 2.4 mcscript add [url or package]
88+
This command adds a custom datapack to your directory.
89+
As argument an url to the resource or a *mcScript Extension* name can be used.
90+
91+
Get a list of all supported packages by running just`mcscript add`
92+
8493
<a id="cli-modals"></a>
85-
### 2.4 Dev: mcscript modals
94+
### 2.5 Dev: mcscript modals
8695

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

_changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Minecraft Script Changes
1111
* changed: . are now allowed in variable names
1212
* changed: the mcscript folder will be automaticly deleted! save important files!!
1313
* fixed: the forWeb.js file
14+
15+
** v0.1.3.1**
16+
* added: a `mcscript add` package command
17+
* reduced file size
1418
### v0.1.2
1519
* changed: fixed asat to "at @s"
1620
* changed: raycasting is more accurate

bin/add.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
var http = require('https');
2+
var fs = require('fs');
3+
4+
exports.addPack = function(name){
5+
let patt = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/)
6+
if(patt.test(name)){
7+
download(name, "external")
8+
} else http.get("https://download1350.mediafire.com/q7aa9e774jug/oyrbdi6fbpqo1bl/mcscri%27%2B%27pt+packages.json", (res) => {
9+
res.setEncoding('utf8');
10+
res.on('data', function (chunk) {
11+
let packs = JSON.parse(chunk)
12+
let obj = packs.find(obj => obj.name === name.toLowerCase())
13+
if(obj && obj.url){
14+
console.log(obj.url.slice(0, 17))
15+
if(obj.url.slice(0, 17) == "https://github.com" || obj.url.slice(0, 16) == "http://github.com") downloadFromRedirectLink(obj.url, obj.name)
16+
else download(obj.url, obj.name)
17+
} else {
18+
let packStr = ""
19+
packs.forEach((e, i) => {
20+
packStr += e.name
21+
if(i != packs.length - 1) packStr += ", "
22+
})
23+
console.log("\x1b[31m","Your pack was not found! Please use one of these: ","\x1b[0m")
24+
console.log("\x1b[36m",packStr,"\x1b[0m")
25+
}
26+
});
27+
28+
}).on('error', function(e) {
29+
console.log("\x1b[31m","Got error: " + e.message,"\x1b[0m");
30+
});
31+
}
32+
var download = function (url, name){
33+
console.log("\x1b[36m","Downloading "+name+".zip ...","\x1b[0m")
34+
let file = fs.createWriteStream(name + '.zip');
35+
let request = http.get(url, function(response) {
36+
response.pipe(file)
37+
response.on('end', () => {
38+
console.log("\x1b[32m","Download of "+name+".zip finished!","\x1b[0m")
39+
});
40+
}).on('error', function(e) {
41+
console.log("\x1b[31m","Got error: " + e.message,"\x1b[0m");
42+
});
43+
}
44+
function downloadFromRedirectLink(url, file) {
45+
http.get(url, function(res) {
46+
if(res.statusCode != 302){
47+
console.log("error: no redirect found");
48+
return;
49+
}
50+
download(res.headers.location,file);
51+
}).on('error', function(e) {
52+
console.log("\x1b[31m", "Got error: " + e.message,"\x1b[0m");
53+
});
54+
}

bin/test-module.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22

33
var lib= require('../lib/index.js');
4+
var addPack = require('./add.js');
45
var gen_new = require('../lib/gen_new.js');
56
// lib.compile(process.argv[2] || './')
67
switch(process.argv[2]){
@@ -15,5 +16,8 @@ switch(process.argv[2]){
1516
if(process.argv[3]) gen_new.new(process.argv[3])
1617
else console.log("\x1b[31m","You have to enter a datapack id!","\x1b[0m")
1718
break
19+
case 'add':
20+
addPack.addPack(process.argv[3] || "")
21+
break
1822
default: console.log("\x1b[31m","Please select a sub command","\x1b[0m")
1923
}

0 commit comments

Comments
 (0)