Skip to content

Commit

Permalink
0.1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevertus committed Apr 28, 2018
1 parent e2d228d commit 4fee57e
Show file tree
Hide file tree
Showing 9 changed files with 314 additions and 206 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions Core Modals.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Minecraft Script Core Modals
`- parameter -`

` [optional] `

` <allowed types>`

` this | or that`
### console
> `log( - text <string | number> - , [entity] )`
Expand Down
7 changes: 7 additions & 0 deletions README-DE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<a id="cli-add"></a>
### 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`

<a id="cli-modals"></a>
### 2.4 Dev: mcscript modals

Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

![](https://i.imgur.com/YedWe7W.png)

Minecraft Script Documentation
Expand All @@ -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)
Expand Down Expand Up @@ -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.
<a id="cli-watch"></a>
### 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.
<a id="cli-add"></a>
### 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`

<a id="cli-modals"></a>
### 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.
Expand Down
4 changes: 4 additions & 0 deletions _changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 54 additions & 0 deletions bin/add.js
Original file line number Diff line number Diff line change
@@ -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");
});
}
4 changes: 4 additions & 0 deletions bin/test-module.js
Original file line number Diff line number Diff line change
@@ -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]){
Expand All @@ -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")
}
Loading

0 comments on commit 4fee57e

Please sign in to comment.