Update draw.js and roof.js

Dieser Commit ist enthalten in:
Matthew Miller 2018-12-20 13:43:01 +10:00
Ursprung 5eb9b779d7
Commit b300c21185
6 geänderte Dateien mit 47 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -2,7 +2,7 @@ CraftScripts are script files for WorldEdit that let you write world
editing scripts with JavaScript easily. editing scripts with JavaScript easily.
Example usage: Example usage:
/cs maze.js lightstone 10 10 /cs maze.js glowstone 10 10
You may or may not install these scripts -- it is optional. If you are, however, You may or may not install these scripts -- it is optional. If you are, however,
place the entire craftscripts/ folder into the respective directory for the platform place the entire craftscripts/ folder into the respective directory for the platform

Datei anzeigen

@ -7,4 +7,4 @@ Note: Legally you should not release things to the public domain as not
all countries have the concept of public domain in their copyright law. all countries have the concept of public domain in their copyright law.
You can also post your scripts here: You can also post your scripts here:
http://forum.sk89q.com/forums/craftscripts.6/ https://discord.gg/YKbmj7V or http://forum.sk89q.com/forums/craftscripts.6/

Datei anzeigen

@ -43,8 +43,26 @@ var clothColors = [
makeColor(100, 60, 0), // Brown makeColor(100, 60, 0), // Brown
makeColor(48, 80, 0), // Cactus green makeColor(48, 80, 0), // Cactus green
makeColor(255, 0, 0), // Red makeColor(255, 0, 0), // Red
makeColor(0, 0, 0), // Black makeColor(0, 0, 0) // Black
] ];
var clothBlocks = [
context.getBlock("white_wool"),
context.getBlock("orange_wool"),
context.getBlock("magenta_wool"),
context.getBlock("light_blue_wool"),
context.getBlock("yellow_wool"),
context.getBlock("lime_wool"),
context.getBlock("pink_wool"),
context.getBlock("gray_wool"),
context.getBlock("light_gray_wool"),
context.getBlock("cyan_wool"),
context.getBlock("purple_wool"),
context.getBlock("blue_wool"),
context.getBlock("brown_wool"),
context.getBlock("green_wool"),
context.getBlock("red_wool"),
context.getBlock("black_wool")
];
var clothColorsOpt = [ var clothColorsOpt = [
makeColor(178, 178, 178), // White makeColor(178, 178, 178), // White
makeColor(187, 102, 44), // Orange makeColor(187, 102, 44), // Orange
@ -61,8 +79,8 @@ var clothColorsOpt = [
makeColor(68, 41, 22), // Brown makeColor(68, 41, 22), // Brown
makeColor(44, 61, 19), // Cactus green makeColor(44, 61, 19), // Cactus green
makeColor(131, 36, 32), // Red makeColor(131, 36, 32), // Red
makeColor(21, 18, 18), // Black makeColor(21, 18, 18) // Black
] ];
var clothColorsOptHD = [ var clothColorsOptHD = [
makeColor(168, 168, 168), // White makeColor(168, 168, 168), // White
makeColor(143, 59, 0), // Orange makeColor(143, 59, 0), // Orange
@ -79,8 +97,8 @@ var clothColorsOptHD = [
makeColor(52, 25, 0), // Brown makeColor(52, 25, 0), // Brown
makeColor(10, 76, 10), // Cactus green makeColor(10, 76, 10), // Cactus green
makeColor(127, 9, 9), // Red makeColor(127, 9, 9), // Red
makeColor(17, 17, 17), // Black makeColor(17, 17, 17) // Black
] ];
// http://stackoverflow.com/questions/2103368/color-logic-algorithm/2103608#2103608 // http://stackoverflow.com/questions/2103368/color-logic-algorithm/2103608#2103608
function colorDistance(c1, c2) { function colorDistance(c1, c2) {
@ -90,7 +108,7 @@ function colorDistance(c1, c2) {
var b = c1.getBlue() - c2.getBlue(); var b = c1.getBlue() - c2.getBlue();
var weightR = 2 + rmean/256; var weightR = 2 + rmean/256;
var weightG = 4.0; var weightG = 4.0;
var weightB = 2 + (255-rmean)/256 var weightB = 2 + (255-rmean)/256;
return Math.sqrt(weightR*r*r + weightG*g*g + weightB*b*b); return Math.sqrt(weightR*r*r + weightG*g*g + weightB*b*b);
} }
@ -113,14 +131,14 @@ function findClosestWoolColor(col, clothColors) {
context.checkArgs(1, 3, "<image> <orientation> <palette>"); context.checkArgs(1, 3, "<image> <orientation> <palette>");
var f = context.getSafeFile("drawings", argv[1]); var f = context.getSafeOpenFile("drawings", argv[1], "png", ["png", "jpg", "jpeg", "bmp"]);
var sess = context.remember(); var sess = context.remember();
var upright = argv[2] == "v"; var upright = argv[2] === "v";
var colors = clothColors; var colors = clothColors;
if(argv[3] == "opt") { if(argv[3] === "opt") {
colors = clothColorsOpt; colors = clothColorsOpt;
player.print("Using optimized palette"); player.print("Using optimized palette");
} else if(argv[3] == "optHD") { } else if(argv[3] === "optHD") {
colors = clothColorsOptHD; colors = clothColorsOptHD;
player.print("Using optimized HD palette"); player.print("Using optimized HD palette");
} }
@ -132,7 +150,7 @@ if (!f.exists()) {
var width = img.getWidth(); var width = img.getWidth();
var height = img.getHeight(); var height = img.getHeight();
var origin = player.getBlockIn(); var origin = player.getBlockIn().toVector().toBlockPoint();
for (var x = 0; x < width; x++) { for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) { for (var y = 0; y < height; y++) {
@ -141,9 +159,9 @@ if (!f.exists()) {
// Added this to enable the user to create images upright // Added this to enable the user to create images upright
// rather than flat on the ground // rather than flat on the ground
if (!upright) { if (!upright) {
sess.setBlock(origin.add(x, 0, y), new BaseBlock(35, data)); sess.setBlock(origin.add(x, 0, y), clothBlocks[data]);
} else { } else {
sess.setBlock(origin.add(x, height - y, 0), new BaseBlock(35, data)); sess.setBlock(origin.add(x, height - y, 0), clothBlocks[data]);
} }
} }
} }

Datei anzeigen

@ -20,11 +20,11 @@
importPackage(Packages.com.sk89q.worldedit); importPackage(Packages.com.sk89q.worldedit);
importPackage(Packages.com.sk89q.worldedit.blocks); importPackage(Packages.com.sk89q.worldedit.blocks);
var torchDirs = {} var torchDirs = {};
torchDirs[PlayerDirection.NORTH] = [2, 4]; torchDirs[Direction.NORTH] = [2, 4];
torchDirs[PlayerDirection.SOUTH] = [1, 3]; torchDirs[Direction.SOUTH] = [1, 3];
torchDirs[PlayerDirection.WEST] = [3, 2]; torchDirs[Direction.WEST] = [3, 2];
torchDirs[PlayerDirection.EAST] = [4, 1]; torchDirs[Direction.EAST] = [4, 1];
var pitches = { var pitches = {
"f#": 0, "f#": 0,

Datei anzeigen

@ -16,20 +16,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
importPackage(Packages.java.io);
importPackage(Packages.java.awt);
importPackage(Packages.com.sk89q.worldedit); importPackage(Packages.com.sk89q.worldedit);
importPackage(Packages.com.sk89q.worldedit.math);
importPackage(Packages.com.sk89q.worldedit.blocks); importPackage(Packages.com.sk89q.worldedit.blocks);
var blocks = context.remember(); var blocks = context.remember();
var session = context.getSession(); var session = context.getSession();
var region = session.getRegion(); var player = context.getPlayer();
var region = session.getRegionSelector(player.getWorld()).getRegion();
context.checkArgs(1, 1, "<type>"); context.checkArgs(1, 1, "<type>");
var blocktype = context.getBlock(argv[1]); var blocktype = context.getBlock(argv[1]);
var cycles = region.getLength() var cycles = region.getLength();
if (region.getWidth() > cycles){ if (region.getWidth() > cycles){
cycles = region.getWidth(); cycles = region.getWidth();
@ -40,8 +40,8 @@ cycles = cycles / 2;
for (var c = 0; c < cycles; c++) { for (var c = 0; c < cycles; c++) {
for (var w = 0; w < region.getWidth() - (c * 2); w++) { for (var w = 0; w < region.getWidth() - (c * 2); w++) {
for (var l = 0; l < region.getLength() - (c * 2); l++) { for (var l = 0; l < region.getLength() - (c * 2); l++) {
if (w == 0 || w == (region.getWidth() - (c * 2)) - 1 || l == 0 || l == (region.getLength() - (c * 2)) - 1) { if (w === 0 || w === (region.getWidth() - (c * 2)) - 1 || l === 0 || l === (region.getLength() - (c * 2)) - 1) {
var vec = new Vector( var vec = BlockVector3.at(
region.getMinimumPoint().getX() + (w + c), region.getMinimumPoint().getX() + (w + c),
region.getMaximumPoint().getY() + c, region.getMaximumPoint().getY() + c,
region.getMinimumPoint().getZ() + (l + c)); region.getMinimumPoint().getZ() + (l + c));

Datei anzeigen

@ -127,7 +127,7 @@ public class ColorCodeBuilder {
} else if (!resetFrom.hasEqualFormatting(resetTo) || } else if (!resetFrom.hasEqualFormatting(resetTo) ||
(resetFrom.getColor() != null && resetTo.getColor() == null)) { (resetFrom.getColor() != null && resetTo.getColor() == null)) {
// Have to set reset code and add back all the formatting codes // Have to set reset code and add back all the formatting codes
return String.valueOf(Style.RESET) + getCode(resetTo); return Style.RESET + getCode(resetTo);
} else { } else {
if (resetFrom.getColor() != resetTo.getColor()) { if (resetFrom.getColor() != resetTo.getColor()) {
return String.valueOf(resetTo.getColor()); return String.valueOf(resetTo.getColor());