From ee9b50264ed4a39b5b466d09f6e3968e199f67e7 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 30 Jan 2011 22:04:36 -0800 Subject: [PATCH] Improved draw.js. --- craftscripts/draw.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/craftscripts/draw.js b/craftscripts/draw.js index e7067ed32..9e73a8037 100644 --- a/craftscripts/draw.js +++ b/craftscripts/draw.js @@ -74,13 +74,16 @@ function findClosestWoolColor(col) { return closestId; } -var sess = context.remember(); context.checkArgs(1, 2, " "); var f = context.getSafeFile("drawings", argv[1]); +var sess = context.remember(); +var upright = argv[2] == "v"; -if (f != null) { +if (!f.exists()) { + player.error("Specified file doesn't exist."); +} else { var img = ImageIO.read(f); var width = img.getWidth(); @@ -92,12 +95,12 @@ if (f != null) { for (var y = 0; y < height; y++) { var c = new Color(img.getRGB(x, y)); var data = findClosestWoolColor(c); - //added this to enable the user to create images stood up rather than flat on the ground - if(argv[2]=="h"){ - sess.setBlock(origin.add(x, 0, y), new BaseBlock(35, data)); - } - if(argv[2]=="v"){ - sess.setBlock(origin.add(x, height-y, 0), new BaseBlock(35, data)); + // Added this to enable the user to create images upright + // rather than flat on the ground + if (!upright) { + sess.setBlock(origin.add(x, 0, y), new BaseBlock(35, data)); + } else { + sess.setBlock(origin.add(x, height - y, 0), new BaseBlock(35, data)); } } }