Merge pull request #444 from orthoplex64/master

Update maze.js
Dieser Commit ist enthalten in:
Matthew Miller 2019-01-01 11:38:55 +10:00 committet von GitHub
Commit ba8bde0b35
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -19,6 +19,7 @@
importPackage(Packages.com.sk89q.worldedit);
importPackage(Packages.com.sk89q.worldedit.blocks);
importPackage(Packages.com.sk89q.worldedit.math);
usage = "<block> [width] [length] [height] [size] [thickness] flags\n";
usage += "\n";
@ -40,10 +41,15 @@ usage += "• b places blue wool if unvisited";
context.checkArgs(1, -1, usage);
sess = context.remember();
origin = player.getBlockIn();
origin = player.getBlockIn().toVector().toBlockPoint();
// This may throw an exception that is caught by the script processor
block = context.getBlock(argv[1]);
airBlock = context.getBlock("air");
glassBlock = context.getBlock("glass");
limeWoolBlock = context.getBlock("lime_wool");
redWoolBlock = context.getBlock("red_wool");
blueWoolBlock = context.getBlock("blue_wool");
if (argv.length > 7) flags = String(argv[7]);
else flags = false;
@ -74,20 +80,20 @@ if (argv.length > 2) {
} else w = 5;
if (flags) {
ee = flags.search("i") != -1 ? true : false;
r = flags.search("y") != -1 ? true : false;
ee = flags.search("i") != -1;
r = flags.search("y") != -1;
if (r) ee = true;
f = flags.search("f") != -1 ? true : false;
c = flags.search("c") != -1 ? true : false;
e = flags.search("e") != -1 ? true : false;
ao = flags.search("a") != -1 ? true : false;
f = flags.search("f") != -1;
c = flags.search("c") != -1;
e = flags.search("e") != -1;
ao = flags.search("a") != -1;
if (ao) f = c = false, e = true;
v = flags.search("v") != -1 ? true : false;
so = flags.search("s") != -1 ? true : false;
v = flags.search("v") != -1;
so = flags.search("s") != -1;
if (so) ee = true;
g = flags.search("g") != -1 ? true : false;
re = flags.search("r") != -1 ? true : false;
bl = flags.search("b") != -1 ? true : false;
g = flags.search("g") != -1;
re = flags.search("r") != -1;
bl = flags.search("b") != -1;
if (g || re || bl) so = ee = true;
} else ee = r = f = c = e = ao = v = so = g = re = bl = false;
@ -208,8 +214,8 @@ for (y = 0; y <= l; y++) for (x = 0; x <= w; x++) {
}
} else if (e && cell != id(x, l)) {
for (z = 0; z < h; z++) for (yi = 0; yi < s; yi++) for (xi = 1; xi <= wa; xi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), BaseBlock(0));
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), BaseBlock(0));
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), airBlock);
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), airBlock);
}
}
@ -222,8 +228,8 @@ for (y = 0; y <= l; y++) for (x = 0; x <= w; x++) {
}
} else if (e && cell != id(w, y)) {
for (z = 0; z < h; z++) for (yi = 1; yi <= wa; yi++) for (xi = 0; xi < s; xi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), BaseBlock(0));
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), BaseBlock(0));
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), airBlock);
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), airBlock);
}
}
@ -236,8 +242,8 @@ for (y = 0; y <= l; y++) for (x = 0; x <= w; x++) {
if (e && cell != id(x, l) && cell != id(w, y)) {
for (z = 0; z < h; z++) for (yi = 0; yi < s; yi++) for (xi = 0; xi < s; xi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) + yi), BaseBlock(0));
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, -z), BaseBlock(0));
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) + yi), airBlock);
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, -z), airBlock);
}
}
}
@ -281,51 +287,51 @@ if (so) {
if (visited[cell] && !wrong[cell]) {
for (yi = 0; yi < s; yi++) for (xi = 0; xi < s; xi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), BaseBlock(35, 5));
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), BaseBlock(35, 5));
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), limeWoolBlock);
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), limeWoolBlock);
}
}
if ((visited[cell] && !wrong[cell] && visited[id(x - 1, y)] && !wrong[id(x - 1, y)] && noWallLeft[cell]) || cell == start || id(x - 1, y) == end) {
for (xi = 1; xi <= wa; xi++) for (yi = 0; yi < s; yi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), BaseBlock(35, 5));
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), BaseBlock(35, 5));
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), limeWoolBlock);
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), limeWoolBlock);
}
}
if (visited[cell] && !wrong[cell] && visited[id(x, y - 1)] && !wrong[id(x, y - 1)] && noWallAbove[cell]) {
for (xi = 0; xi < s; xi++) for (yi = 1; yi <= wa; yi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), BaseBlock(35, 5));
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), BaseBlock(35, 5));
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), limeWoolBlock);
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), limeWoolBlock);
}
}
if (g) {
if (visited[cell] && !wrong[cell] && (!visited[id(x - 1, y)] || wrong[id(x - 1, y)]) && noWallLeft[cell] && cell != start) {
for (z = 0; z < h; z++) for (xi = 1; xi <= wa; xi++) for (yi = 0; yi < s; yi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), BaseBlock(20));
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), BaseBlock(20));
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), glassBlock);
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), glassBlock);
}
}
if ((!visited[cell] || wrong[cell]) && visited[id(x - 1, y)] && !wrong[id(x - 1, y)] && noWallLeft[cell] && id(x - 1, y) != end) {
for (z = 0; z < h; z++) for (xi = 1; xi <= wa; xi++) for (yi = 0; yi < s; yi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), BaseBlock(20));
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), BaseBlock(20));
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), glassBlock);
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), glassBlock);
}
}
if (visited[cell] && !wrong[cell] && (!visited[id(x, y - 1)] || wrong[id(x, y - 1)]) && noWallAbove[cell]) {
for (z = 0; z < h; z++) for (xi = 0; xi < s; xi++) for (yi = 1; yi <= wa; yi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), BaseBlock(20));
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), BaseBlock(20));
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), glassBlock);
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), glassBlock);
}
}
if ((!visited[cell] || wrong[cell]) && visited[id(x, y - 1)] && !wrong[id(x, y - 1)] && noWallAbove[cell]) {
for (z = 0; z < h; z++) for (xi = 0; xi < s; xi++) for (yi = 1; yi <= wa; yi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), BaseBlock(20));
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), BaseBlock(20));
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), glassBlock);
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), glassBlock);
}
}
}
@ -333,22 +339,22 @@ if (so) {
if (re) {
if (wrong[cell]) {
for (yi = 0; yi < s; yi++) for (xi = 0; xi < s; xi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), BaseBlock(35, 14));
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), BaseBlock(35, 14));
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), redWoolBlock);
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), redWoolBlock);
}
}
if ((wrong[cell] || wrong[id(x - 1, y)]) && noWallLeft[cell]) {
for (xi = 1; xi <= wa; xi++) for (yi = 0; yi < s; yi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), BaseBlock(35, 14));
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), BaseBlock(35, 14));
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), redWoolBlock);
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), redWoolBlock);
}
}
if ((wrong[cell] || wrong[id(x, y - 1)]) && noWallAbove[cell]) {
for (xi = 0; xi < s; xi++) for (yi = 1; yi <= wa; yi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), BaseBlock(35, 14));
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), BaseBlock(35, 14));
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), redWoolBlock);
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), redWoolBlock);
}
}
}
@ -356,22 +362,22 @@ if (so) {
if (bl) {
if (!visited[cell] && y < l && x < w) {
for (yi = 0; yi < s; yi++) for (xi = 0; xi < s; xi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), BaseBlock(35, 11));
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), BaseBlock(35, 11));
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), blueWoolBlock);
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), blueWoolBlock);
}
}
if ((!visited[cell] || !visited[id(x - 1, y)]) && noWallLeft[cell] && x > 0 && x < w) {
for (xi = 1; xi <= wa; xi++) for (yi = 0; yi < s; yi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), BaseBlock(35, 11));
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), BaseBlock(35, 11));
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), blueWoolBlock);
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), blueWoolBlock);
}
}
if ((!visited[cell] || !visited[id(x, y - 1)]) && noWallAbove[cell]) {
for (xi = 0; xi < s; xi++) for (yi = 1; yi <= wa; yi++) {
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), BaseBlock(35, 11));
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), BaseBlock(35, 11));
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), blueWoolBlock);
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), blueWoolBlock);
}
}
}