Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- +--------------------------------------------------------+
- -- | |
- -- | mapArt |
- -- | |
- -- +--------------------------------------------------------+
- local version = "Version 1.1.1"
- -- By Jeffrey Alexander, aka Bomb Bloke.
- -- Command Computer script for building map images out of GIFs.
- -- http://www.computercraft.info/forums2/index.php?/topic/28883-mapart/
- ---------------------------------------------
- ------------ Load APIs ------------
- ---------------------------------------------
- local function loadAPI(API, paste)
- if not _G[API] then
- if not (fs.exists(API) or fs.exists(shell.resolve(API))) then
- shell.run("pastebin get " .. paste .. " " .. API)
- os.loadAPI(shell.resolve(API))
- else os.loadAPI(fs.exists(API) and API or shell.resolve(API)) end
- end
- end
- loadAPI("bbpack", "cUYTGbpb")
- loadAPI("GIF", "5uk9uRjC")
- ---------------------------------------------
- ------------Variable Declarations------------
- ---------------------------------------------
- local teleport = {commands.exec("tpn")}
- teleport = (teleport[2][1]:sub(1, 16) == "Unknown command.") and "teleport" or "tpn"
- local transparent = "minecraft:sandstone"
- local x, y, z = commands.getBlockPosition()
- local x1, z1 = math.floor((x - 64) / 128) * 128 + 64, math.floor((z - 64) / 128) * 128 + 64
- local xSize, ySize, myEvent = term.getSize()
- local startDir = shell.resolve(".")
- ---------------------------------------------
- ------------ Functions ------------
- ---------------------------------------------
- local function clear(textCol, backCol)
- if textCol then term.setTextColour(textCol) end
- if backCol then term.setBackgroundColour(backCol) end
- for i = 4, ySize - 3 do
- term.setCursorPos(1, i)
- term.clearLine()
- end
- end
- local function snooze()
- local myEvent = tostring({})
- os.queueEvent(myEvent)
- os.pullEvent(myEvent)
- end
- -- Returns whether a click was performed at a given location.
- -- If one parameter is passed, it checks to see if y is [1].
- -- If two parameters are passed, it checks to see if x is [1] and y is [2].
- -- If three parameters are passed, it checks to see if x is between [1]/[2] (non-inclusive) and y is [3].
- -- If four paramaters are passed, it checks to see if x is between [1]/[2] and y is between [3]/[4] (non-inclusive).
- local function clickedAt(...)
- if myEvent[1] ~= "mouse_click" then return false end
- if #arg == 1 then return (arg[1] == myEvent[4])
- elseif #arg == 2 then return (myEvent[3] == arg[1] and myEvent[4] == arg[2])
- elseif #arg == 3 then return (myEvent[3] > arg[1] and myEvent[3] < arg[2] and myEvent[4] == arg[3])
- else return (myEvent[3] > arg[1] and myEvent[3] < arg[2] and myEvent[4] > arg[3] and myEvent[4] < arg[4]) end
- end
- -- Returns whether one of a given set of keys was pressed.
- local function pressedKey(...)
- if myEvent[1] ~= "key" then return false end
- for i=1,#arg do if arg[i] == myEvent[2] then return true end end
- return false
- end
- -- Prompts user to select a file.
- local function fileBrowser()
- local bump = math.floor((xSize - 49) / 2) + 1
- local cursor = {{">> "," <<"},{"> > "," < <"},{" >> "," << "},{"> > "," < <"}}
- local blackText = (_CC_VERSION or _HOST) and colours.grey or colours.black
- while true do
- local displayList, position, lastPosition, animationTimer, curCount, gapTimer, lastProgress = {}, 1, 0, os.startTimer(0), 1
- if #shell.resolve(".") > 0 then displayList[1] = ".." end
- do
- local fullList = fs.list(shell.resolve("."))
- table.sort(fullList, function (a, b) return string.lower(a) < string.lower(b) end)
- for i = 1, #fullList do if fs.isDir(shell.resolve(fullList[i])) then displayList[#displayList + 1] = fullList[i] end end
- for i = 1, #fullList do if fullList[i]:sub(#fullList[i] - 3):lower() == ".gif" then displayList[#displayList + 1] = fs.getName(fullList[i]) end end
- end
- while true do
- myEvent = {os.pullEvent()}
- -- Track animations (bouncing cursor + scrolling marquee).
- if myEvent[1] == "timer" and myEvent[2] == animationTimer then
- curCount = curCount == 4 and 1 or (curCount + 1)
- animationTimer = os.startTimer(0.5)
- myEvent[1] = "cabbage"
- -- Bail.
- elseif pressedKey(keys.backspace) or (myEvent[1] == "mouse_click" and myEvent[2] == 2) then
- return nil
- -- Move down the list.
- elseif pressedKey(keys.down, keys.s) or (myEvent[1] == "mouse_scroll" and myEvent[2] == 1) then
- position = position == #displayList and 1 or (position + 1)
- -- Move up the list.
- elseif pressedKey(keys.up, keys.w) or (myEvent[1] == "mouse_scroll" and myEvent[2] == -1) then
- position = position == 1 and #displayList or (position - 1)
- -- Select something.
- elseif pressedKey(keys.enter, keys.space) or clickedAt(math.floor(ySize / 2) + 1) then
- if fs.isDir(shell.resolve(displayList[position])) then
- shell.setDir(shell.resolve(displayList[position]))
- break
- else return shell.resolve(displayList[position]) end
- -- User clicked somewhere on the file list; move that entry to the currently-selected position.
- elseif clickedAt(0, xSize + 1, 3, ySize - 2) then
- position = position + myEvent[4] - math.floor(ySize / 2) - 1
- position = position > #displayList and #displayList or position
- position = position < 1 and 1 or position
- end
- -- Update other screen stuff.
- if myEvent[1] ~= "timer" then
- -- File list.
- term.setBackgroundColour(colours.black)
- for y = position == lastPosition and (math.floor(ySize / 2) + 1) or 4, position == lastPosition and (math.floor(ySize / 2) + 1) or (ySize - 3) do
- local thisLine = y + position - math.floor(ySize / 2) - 1
- if displayList[thisLine] then
- local thisString = displayList[thisLine]
- thisString = fs.isDir(shell.resolve(thisString)) and "["..thisString.."]" or thisString:sub(1, #thisString-4)
- if thisLine == position then
- term.setCursorPos(math.floor((xSize - #thisString - 8) / 2) + 1, y)
- term.clearLine()
- term.setTextColour(colours.red)
- term.write(cursor[curCount][1])
- term.setTextColour(colours.orange)
- term.write(thisString)
- term.setTextColour(colours.red)
- term.write(cursor[curCount][2])
- else
- term.setCursorPos(math.floor((xSize - #thisString) / 2) + 1, y)
- term.clearLine()
- if y == 4 or y == ySize - 3 then
- term.setTextColour(blackText)
- elseif y == 5 or y == ySize - 4 then
- term.setTextColour(term.isColour() and colours.grey or blackText)
- elseif y == 6 or y == ySize - 5 then
- term.setTextColour(term.isColour() and colours.lightGrey or colours.white)
- else term.setTextColour(colours.white) end
- term.write(thisString)
- end
- else
- term.setCursorPos(1, y)
- term.clearLine()
- end
- end
- lastPosition = position
- end
- end
- end
- end
- -- Constructs image within the world.
- local function doBuild(filename)
- local GIFImage, mapsX, mapsY, buildCount, myTimer = GIF.loadGIF(filename, "mapArt.pal"), 1, 1, 1
- local vert = GIFImage.height > GIFImage.width
- if vert then
- mapsX = math.ceil(GIFImage.width * mapsY / GIFImage.height)
- else
- mapsY = math.ceil(GIFImage.height * mapsX / GIFImage.width)
- end
- -- Bug the user about the output size:
- while true do
- clear(colours.black, colours.lightGrey)
- term.setCursorPos(21, 5)
- term.write("Resolution")
- term.setTextColour(colours.grey)
- term.setCursorPos(5, 7)
- term.write("Image resolution: " .. GIFImage.width .. " x " .. GIFImage.height .. ", ratio: " .. (GIFImage.width / GIFImage.height))
- term.setCursorPos(5, 9)
- term.write("Map resolution: " .. (mapsX * 128) .. " x " .. (mapsY * 128) .. ", ratio: " .. (mapsX / mapsY))
- term.setCursorPos(5, 11)
- term.write("Columns:")
- term.setCursorPos(5, 13)
- term.write("Rows:")
- term.setCursorPos(16, 11)
- term.write(mapsX)
- term.setCursorPos(16, 13)
- term.write(mapsY)
- term.setCursorPos(41, 11)
- term.write("Start")
- term.setCursorPos(39, 12)
- term.write("from map:")
- term.setCursorPos(42, 13)
- term.write(buildCount)
- term.setTextColour(colours.lightGrey)
- term.setBackgroundColour(colours.blue)
- term.setCursorPos(14, vert and 13 or 11)
- term.write("<")
- term.setCursorPos(19, vert and 13 or 11)
- term.write(">")
- term.setCursorPos(40, 13)
- term.write("<")
- term.setCursorPos(46, 13)
- term.write(">")
- term.setCursorPos(5, 15)
- term.write(" Back ")
- term.setCursorPos(40, 15)
- term.write(" Begin ")
- myEvent = {os.pullEvent()}
- if clickedAt(14, vert and 13 or 11) then
- if vert and mapsY > 1 then
- mapsY = mapsY - 1
- mapsX = math.ceil(GIFImage.width * mapsY / GIFImage.height)
- elseif not vert and mapsX > 1 then
- mapsX = mapsX - 1
- mapsY = math.ceil(GIFImage.height * mapsX / GIFImage.width)
- end
- if buildCount > mapsX * mapsY then buildCount = mapsX * mapsY end
- elseif clickedAt(19, vert and 13 or 11) then
- if vert and mapsY < 100 then
- mapsY = mapsY + 1
- mapsX = math.ceil(GIFImage.width * mapsY / GIFImage.height)
- elseif not vert and mapsX < 100 then
- mapsX = mapsX + 1
- mapsY = math.ceil(GIFImage.height * mapsX / GIFImage.width)
- end
- elseif clickedAt(40, 13) and buildCount > 1 then
- buildCount = buildCount - 1
- elseif clickedAt(46, 13) and buildCount < mapsX * mapsY then
- buildCount = buildCount + 1
- elseif clickedAt(4, 11, 15) then
- return
- elseif clickedAt(39, 47, 15) then
- break
- end
- end
- clear(colours.black, colours.lightGrey)
- term.setCursorPos(21, 5)
- term.write("Resizing...")
- for i = 2, #GIFImage do GIFImage[i] = nil end
- if GIFImage.width ~= mapsX * 128 and GIFImage.height ~= mapsY * 128 then
- if GIFImage.height > GIFImage.width then
- GIFImage = GIF.resizeGIF(GIFImage, nil, mapsY * 128)
- else
- GIFImage = GIF.resizeGIF(GIFImage, mapsX * 128)
- end
- end
- local image = {}
- for y = 1, GIFImage.height do
- image[y] = {}
- for x = 1, GIFImage.width do image[y][x] = 0 end
- end
- local pal, width, height = GIFImage.pal, GIFImage.width, GIFImage.height
- local len = #pal / 3
- GIFImage = GIFImage[1]
- for y = 1, GIFImage.yend do
- local x, GIFImageY, imageY = GIFImage.xstart + 1, GIFImage[y], image[y + GIFImage.ystart]
- for i = 1, #GIFImageY do
- local GIFImageYI = GIFImageY[i]
- if type(GIFImageYI) == "number" then
- x = x + GIFImageYI
- else
- for pixel = 1, #GIFImageYI do imageY[x + pixel - 1] = GIFImageYI[pixel] end
- x = x + #GIFImageYI
- end
- end
- end
- GIFImage = nil
- term.setCursorPos(21, 7)
- term.write("Padding...")
- if width < mapsX * 128 then
- local diff = mapsX * 128 - width
- for y = 1, height do
- local row = image[y]
- for i = 1, math.floor(diff / 2) do table.insert(row, 1, 0) end
- for i = #row + 1, #row + math.ceil(diff / 2) do row[i] = 0 end
- snooze()
- end
- width = mapsX * 128
- end
- if height < mapsY * 128 then
- local row = {}
- for i = 1, mapsX * 128 do row[i] = 0 end
- local diff = mapsY * 128 - height
- for i = 1, math.floor(diff / 2) do table.insert(image, 1, row) end
- for i = #image + 1, #image + math.ceil(diff / 2) do image[i] = row end
- height = mapsY * 128
- snooze()
- end
- -- Build stuff!
- for builds = buildCount, mapsX * mapsY do
- local xxxx, zzzz, curCommands, maxCommands, counter = (builds - 1) % mapsX, math.floor((builds - 1) / mapsX), 0, 250, 0
- clear(colours.black, colours.lightGrey)
- term.setCursorPos(22, 5)
- term.write("Building")
- term.setBackgroundColour(colours.grey)
- term.setCursorPos(4, 11)
- term.write(string.rep(" ", 45))
- term.setTextColour(colours.grey)
- term.setBackgroundColour(colours.lightGrey)
- sleep(0)
- parallel.waitForAny(
- -- Track completed commands.
- function()
- while true do
- os.pullEvent("task_complete")
- curCommands = curCommands - 1
- end
- end,
- -- Display build progress.
- -- Mostly pointless because server time pretty much stands still while this is running.
- function()
- local countmax, lastcount = 16640, 0
- repeat
- myTimer = os.startTimer(60)
- repeat local event, id = os.pullEvent("timer") until id == myTimer
- term.setBackgroundColour(colours.brown)
- term.setCursorPos(4, 11)
- term.write(string.rep(" ", math.floor(counter / countmax * 45)))
- term.setBackgroundColour(colours.grey)
- term.write(string.rep(" ", 45 - math.floor(counter / countmax * 45)))
- term.setBackgroundColour(colours.lightGrey)
- term.setCursorPos(4, 7)
- term.clearLine()
- term.write(tostring(counter) .. " / " .. tostring(countmax) .. " blocks" .. (counter < countmax and ", ~" .. tostring(counter - lastcount) .. " per minute." or "."))
- term.setCursorPos(4, 9)
- term.clearLine()
- term.write(counter < countmax and tostring(math.floor(counter / countmax * 100)) .. "%, about " .. tostring(math.ceil((countmax - counter) / (counter - lastcount))) .. " minutes remaining." or "100%")
- lastcount = counter
- until counter == countmax
- end,
- -- Actual construction is done here.
- function()
- -- Prevent too many commands executing at once.
- local function doCommand(doThis)
- while curCommands >= maxCommands do os.pullEvent("task_complete") end
- commands.execAsync(doThis)
- curCommands = curCommands + 1
- counter = counter + 1
- end
- -- Clear old builds.
- doCommand("fill " .. x1 .. " 127 " .. (z1 - 1) .. " " .. (x1 + 127) .. " 128 " .. z1 .. " minecraft:air")
- for i = 1, 127 do doCommand("fill " .. x1 .. " " .. (127 - i) .. " " .. (z1 + i) .. " " .. (x1 + 127) .. " " .. (128 + i) .. " " .. (z1 + i) .. " minecraft:air") end
- -- Calibrate wave heights.
- local ys = {}
- for i = 1, 128 do
- local y = (math.floor((image[1 + zzzz * 128][i + xxxx * 128] - 1) / len) == 0) and 127 or 128
- doCommand("setblock " .. (x1 + i - 1) .. " " .. y .. " " .. (z1 - 1) .. " minecraft:cobblestone")
- ys[i] = y
- end
- -- Main image area.
- for xxx = 0, 7 do for zzz = 0, 7 do for xx = 1, 16 do
- local y = ys[xxx * 16 + xx]
- for zz = 1, 16 do
- local curCol = image[zz + zzz * 16 + zzzz * 128][xx + xxx * 16 + xxxx * 128]
- local block = pal[curCol]
- local shade = math.floor((curCol - 1) / len)
- if shade == 0 then
- y = y + 1
- elseif shade == 2 then
- y = y - 1
- end
- doCommand("setblock " .. (x1 + xx - 1 + xxx * 16) .. " " .. y .. " " .. (z1 + zz - 1 + zzz * 16) .. " " .. block[4] .. " " .. block[5])
- end
- ys[xxx * 16 + xx] = y
- end end end
- os.queueEvent("timer", myTimer)
- while true do os.pullEvent("stopResumingMe") end
- end
- )
- commands.give("@p minecraft:map")
- term.setCursorPos(4, 13)
- term.write("Completed build " .. builds.. " of " .. (mapsX * mapsY) .. ".")
- term.setTextColour(colours.lightGrey)
- term.setBackgroundColour(colours.blue)
- term.setCursorPos(5, 15)
- term.write(" Cancel ")
- term.setCursorPos(37, 15)
- term.write(" Continue ")
- while true do
- myEvent = {os.pullEvent("mouse_click")}
- if clickedAt(4, 13, 15) then
- return
- elseif clickedAt(36, 47, 15) then
- break
- end
- end
- end
- end
- ---------------------------------------------
- ------------ Init ------------
- ---------------------------------------------
- if not os.getComputerLabel() then os.setComputerLabel("mapArt") end
- term.setTextColour(colours.black)
- term.setBackgroundColour(colours.brown)
- for j = 0, 1 do for i = 1, 3 do
- term.setCursorPos(1, i + (j * (ySize - 3)))
- term.clearLine()
- end end
- term.setCursorPos(5, 2)
- term.write("mapArt")
- term.setCursorPos(2, ySize - 1)
- term.write("This system is facing "..({"unknown", "north", "south", "west", "east"})[commands.getBlockInfo(commands.getBlockPosition()).metadata]..".")
- paintutils.drawPixel(1, 1, colours.blue)
- paintutils.drawPixel(2, 1, colours.green)
- paintutils.drawPixel(3, 1, colours.yellow)
- paintutils.drawPixel(1, 2, colours.grey)
- paintutils.drawPixel(2, 2, colours.white)
- paintutils.drawPixel(3, 2, colours.lightBlue)
- paintutils.drawPixel(1, 3, colours.orange)
- paintutils.drawPixel(2, 3, colours.lime)
- paintutils.drawPixel(3, 3, colours.red)
- -- Build a palette file suitable for the current MC install:
- if not fs.exists("mapArt.pal") then
- -- All colours as of MC1.12,
- -- except the first, which is prone to change,
- -- and water, which doesn't work well with staircasing:
- local basePal = {
- {127, 178, 56, "minecraft:grass"},
- {247, 233, 163, "minecraft:sandstone"},
- {199, 199, 199, "minecraft:web"},
- {255, 0, 0, "minecraft:redstone_block"},
- {160, 160, 255, "minecraft:packed_ice"},
- {167, 167, 167, "minecraft:iron_block"},
- { 0, 124, 0, "minecraft:leaves"},
- {255, 255, 255, "minecraft:wool"},
- {164, 168, 184, "minecraft:clay"},
- {151, 109, 77, "minecraft:planks", 3},
- {112, 112, 112, "minecraft:cobblestone"},
- {143, 119, 72, "minecraft:planks"},
- {255, 252, 245, "minecraft:stone", 3},
- {216, 127, 51, "minecraft:planks", 4},
- {178, 76, 216, "minecraft:wool", 2},
- {102, 153, 216, "minecraft:wool", 3},
- {229, 229, 51, "minecraft:wool", 4},
- {127, 204, 25, "minecraft:wool", 5},
- {242, 127, 165, "minecraft:wool", 6},
- { 76, 76, 76, "minecraft:wool", 7},
- {153, 153, 153, "minecraft:wool", 8},
- { 76, 127, 153, "minecraft:wool", 9},
- {127, 63, 178, "minecraft:wool", 10},
- { 51, 76, 178, "minecraft:wool", 11},
- {102, 76, 51, "minecraft:planks", 5},
- {102, 127, 51, "minecraft:wool", 13},
- {153, 51, 51, "minecraft:wool", 14},
- { 25, 25, 25, "minecraft:wool", 15},
- {250, 238, 77, "minecraft:gold_block"},
- { 92, 219, 213, "minecraft:diamond_block"},
- { 74, 128, 255, "minecraft:lapis_block"},
- { 0, 217, 58, "minecraft:emerald_block"},
- {129, 86, 49, "minecraft:planks", 1},
- {112, 2, 0, "minecraft:netherrack"},
- {209, 177, 161, "minecraft:stained_hardened_clay"},
- {159, 82, 36, "minecraft:stained_hardened_clay", 1},
- {149, 87, 108, "minecraft:stained_hardened_clay", 2},
- {112, 108, 138, "minecraft:stained_hardened_clay", 3},
- {186, 133, 36, "minecraft:stained_hardened_clay", 4},
- {103, 117, 53, "minecraft:stained_hardened_clay", 5},
- {160, 77, 78, "minecraft:stained_hardened_clay", 6},
- { 57, 41, 35, "minecraft:stained_hardened_clay", 7},
- {135, 107, 98, "minecraft:stained_hardened_clay", 8},
- { 87, 92, 92, "minecraft:stained_hardened_clay", 9},
- {122, 73, 88, "minecraft:stained_hardened_clay", 10},
- { 76, 62, 92, "minecraft:stained_hardened_clay", 11},
- { 76, 50, 35, "minecraft:stained_hardened_clay", 12},
- { 76, 82, 42, "minecraft:stained_hardened_clay", 13},
- {142, 60, 46, "minecraft:stained_hardened_clay", 14},
- { 37, 22, 16, "minecraft:stained_hardened_clay", 15}
- }
- -- Remove anything we can't setblock:
- for i = #basePal, 1, -1 do
- local this = basePal[i]
- if not this[5] then this[5] = 0 end
- commands.setblock(x, y + 1, z, this[4],this[5])
- local data = commands.getBlockInfo(x, y + 1, z)
- if data.name ~= this[4] or data.metadata ~= this[5] then table.remove(basePal, i) end
- end
- -- If we can't setblock glazed terracotta, also remove regular terracotta (it has no special colour prior to MC1.12):
- commands.setblock(x, y + 1, z, "minecraft:white_glazed_terracotta")
- if basePal[#basePal][4] == "minecraft:stained_hardened_clay" and commands.getBlockInfo(x, y + 1, z).name ~= "minecraft:white_glazed_terracotta" then for i = #basePal - 15, #basePal do basePal[i] = nil end end
- commands.setblock(x, y + 1, z, "minecraft:air")
- -- Triplicate the entries to get the three different shades:
- local len = #basePal
- for i = 1, len do
- local old, new1, new2 = basePal[i], {}, {}
- new1[1], new1[2], new1[3] = math.floor(old[1] * 220 / 255), math.floor(old[2] * 220 / 255), math.floor(old[3] * 220 / 255)
- new2[1], new2[2], new2[3] = math.floor(old[1] * 180 / 255), math.floor(old[2] * 180 / 255), math.floor(old[3] * 180 / 255)
- new1[4], new1[5], new2[4], new2[5] = old[4], old[5], old[4], old[5]
- basePal[i + len], basePal[i + 2 * len] = new1, new2
- end
- basePal[0] = {1000, 1000, 1000, transparent, 0}
- -- Save for future reference:
- local output = fs.open("mapArt.pal", "w")
- output.write(textutils.serialise(basePal))
- output.close()
- end
- local myLoc = "My location: X: " .. x .. ", Y: " .. y .. ", Z: " .. z
- local buildArea = "Build area: X: " .. (x1 - 4) .. " - " .. (x1 + 131).. ", Z: " .. (z1 - 4) .. " - " .. (z1 + 131)
- local ready = (x == x1 + 64 and y == 1 and z == z1 + 63)
- ---------------------------------------------
- ------------ Main Program Loop ------------
- ---------------------------------------------
- while true do
- clear(colours.black, colours.lightGrey)
- term.setCursorPos(22, 5)
- term.write("What Do?")
- term.setCursorPos(math.floor((xSize - #myLoc) / 2) + 1, 14)
- term.write(myLoc)
- term.setCursorPos(math.floor((xSize - #buildArea) / 2) + 1, 15)
- term.write(buildArea)
- term.setTextColour(colours.lightGrey)
- term.setBackgroundColour(colours.grey)
- term.setCursorPos(21, 8)
- if ready then
- term.write(" Build ")
- term.setCursorPos(21, 10)
- term.write(" Fill ")
- else
- term.write(" Prepare ")
- end
- term.setCursorPos(21, 12)
- term.write(" Quit ")
- myEvent = {os.pullEvent()}
- if clickedAt(20, 31, 8) then
- if ready then
- -- Build something.
- local filename = fileBrowser()
- if filename then doBuild(filename) end
- else
- -- Prepare build area.
- -- Safe room:
- commands.execAsync("fill " .. (x1 + 59) .. " 0 " .. (z1 + 59) .. " " .. (x1 + 68) .. " 5 " .. (z1 + 68) .. " minecraft:bedrock")
- commands.execAsync("fill " .. (x1 + 60) .. " 1 " .. (z1 + 60) .. " " .. (x1 + 67) .. " 4 " .. (z1 + 67) .. " minecraft:air")
- commands.execAsync("setblock " .. (x1 + 63) .. " 1 " .. (z1 + 63) .. " minecraft:ender_chest 3")
- commands.execAsync("setblock " .. (x1 + 64) .. " 1 " .. (z1 + 63) .. " minecraft:bedrock")
- commands.execAsync("setblock " .. (x1 + 64) .. " 2 " .. (z1 + 63) .. " minecraft:torch 5")
- commands.execAsync(teleport .. " @p " .. (x1 + 64) .. " 2 " .. (z1 + 65))
- -- Empty out the surrounding chunks:
- for yy = 255, 3, -1 do if yy ~= y then commands.execAsync("fill " .. (x1 - 4) .. " " .. yy .. " " .. (z1 - 4) .. " " .. (x1 + 131) .. " " .. yy .. " " .. (z1 + 131) .. " minecraft:air") end end
- commands.execAsync("fill " .. (x1 - 4) .. " 0 " .. (z1 - 4) .. " " .. (x1 + 67) .. " 2 " .. (z1 + 59) .. " minecraft:air")
- commands.execAsync("fill " .. (x1 + 68) .. " 0 " .. (z1 - 4) .. " " .. (x1 + 131) .. " 2 " .. (z1 + 67) .. " minecraft:air")
- commands.execAsync("fill " .. (x1 + 60) .. " 0 " .. (z1 + 68) .. " " .. (x1 + 131) .. " 2 " .. (z1 + 131) .. " minecraft:air")
- commands.execAsync("fill " .. (x1 - 4) .. " 0 " .. (z1 + 60) .. " " .. (x1 + 59) .. " 2 " .. (z1 + 131) .. " minecraft:air")
- -- Teleport pads:
- commands.execAsync("fill " .. (x1 + 60) .. " 1 " .. (z1 + 60) .. " " ..(x1 + 61) .. " 1 " .. (z1 + 61) .. " minecraft:bedrock")
- commands.execAsync("fill " .. (x1 + 66) .. " 1 " .. (z1 + 60) .. " " ..(x1 + 67) .. " 1 " .. (z1 + 61) .. " minecraft:bedrock")
- commands.execAsync("fill " .. (x1 + 60) .. " 1 " .. (z1 + 66) .. " " ..(x1 + 61) .. " 1 " .. (z1 + 67) .. " minecraft:bedrock")
- commands.execAsync("fill " .. (x1 + 66) .. " 1 " .. (z1 + 66) .. " " ..(x1 + 67) .. " 1 " .. (z1 + 67) .. " minecraft:bedrock")
- commands.execAsync("setblock " .. (x1 + 61) .. " 2 " .. (z1 + 61) .. " minecraft:wooden_pressure_plate")
- commands.execAsync("setblock " .. (x1 + 66) .. " 2 " .. (z1 + 61) .. " minecraft:wooden_pressure_plate")
- commands.execAsync("setblock " .. (x1 + 61) .. " 2 " .. (z1 + 66) .. " minecraft:wooden_pressure_plate")
- commands.execAsync("setblock " .. (x1 + 66) .. " 2 " .. (z1 + 66) .. " minecraft:wooden_pressure_plate")
- commands.execAsync("setblock " .. (x1 + 61) .. " 0 " .. (z1 + 61) .. " minecraft:command_block 1 replace {Command:\"" .. teleport .. " @p " .. (x1 - 5) .. " 150 " .. (z1 - 5) .. "\"}")
- commands.execAsync("setblock " .. (x1 + 66) .. " 0 " .. (z1 + 61) .. " minecraft:command_block 1 replace {Command:\"" .. teleport .. " @p " .. (x1 + 132) .. " 150 " .. (z1 - 5) .. "\"}")
- commands.execAsync("setblock " .. (x1 + 61) .. " 0 " .. (z1 + 66) .. " minecraft:command_block 1 replace {Command:\"" .. teleport .. " @p " .. (x1 - 5) .. " 150 " .. (z1 + 132) .. "\"}")
- commands.execAsync("setblock " .. (x1 + 66) .. " 0 " .. (z1 + 66) .. " minecraft:command_block 1 replace {Command:\"" .. teleport .. " @p " .. (x1 + 132) .. " 150 " .. (z1 + 132) .. "\"}")
- commands.execAsync("setblock " .. (x1 + 60) .. " 2 " .. (z1 + 60) .. " minecraft:standing_sign 14 replace {Text2:\"{\\\"text\\\":\\\"North\\\"}\",Text3:\"{\\\"text\\\":\\\"West\\\"}\"}")
- commands.execAsync("setblock " .. (x1 + 67) .. " 2 " .. (z1 + 60) .. " minecraft:standing_sign 2 replace {Text2:\"{\\\"text\\\":\\\"North\\\"}\",Text3:\"{\\\"text\\\":\\\"East\\\"}\"}")
- commands.execAsync("setblock " .. (x1 + 60) .. " 2 " .. (z1 + 67) .. " minecraft:standing_sign 10 replace {Text2:\"{\\\"text\\\":\\\"South\\\"}\",Text3:\"{\\\"text\\\":\\\"West\\\"}\"}")
- commands.execAsync("setblock " .. (x1 + 67) .. " 2 " .. (z1 + 67) .. " minecraft:standing_sign 6 replace {Text2:\"{\\\"text\\\":\\\"South\\\"}\",Text3:\"{\\\"text\\\":\\\"East\\\"}\"}")
- -- Swap computers (this will fail horribly if the original computer was already near bedrock):
- commands.execAsync("setblock " .. (x1 + 64) .. " 1 " .. (z1 + 63) .. " computercraft:command_computer 3 replace {computerID:" .. os.getComputerID() .. ",x:" .. (x1 + 64) .. ",y:1,z:" .. (z1 + 63) .. ",id:\"computercraft : command_computer\",label:\"" .. os.getComputerLabel() .. "\",on:0b}")
- commands.execAsync("fill " .. (x1 - 4) .. " " .. y .. " " .. (z1 - 4) .. " " .. (x1 + 131) .. " " .. y .. " " .. (z1 + 131) .. " minecraft:air")
- end
- elseif clickedAt(20, 31, 10) and ready then
- -- Fill build area back in with featureless terrain.
- clear(colours.black, colours.lightGrey)
- term.setCursorPos(math.floor((xSize - 10) / 2) + 1, 5)
- term.write("Filling...")
- sleep(0)
- for y = 63, 255 do commands.execAsync("fill " .. (x1 - 4) .. " " .. y .. " " .. (z1 - 4) .. " " .. (x1 + 131) .. " " .. y .. " " .. (z1 + 131) .. " minecraft:air") end
- commands.execAsync("fill " .. (x1 - 4) .. " 62 " .. (z1 - 4) .. " " .. (x1 + 131) .. " 62 " .. (z1 + 131) .. " minecraft:grass")
- commands.execAsync("fill " .. (x1 - 4) .. " 0 " .. (z1 - 4) .. " " .. (x1 + 131) .. " 0 " .. (z1 + 131) .. " minecraft:bedrock")
- for y = 56, 61 do commands.execAsync("fill " .. (x1 - 4) .. " " .. y .. " " .. (z1 - 4) .. " " .. (x1 + 131) .. " " .. y .. " " .. (z1 + 131) .. " minecraft:dirt") end
- for y = 55, 3, -1 do commands.execAsync("fill " .. (x1 - 4) .. " " .. y .. " " .. (z1 - 4) .. " " .. (x1 + 131) .. " " .. y .. " " .. (z1 + 131) .. " minecraft:stone") end
- commands.execAsync("setblock " .. (x1 + 64) .. " 63 " .. (z1 + 63) .. " computercraft:command_computer 3 replace {computerID:" .. os.getComputerID() .. ",x:" .. (x1 + 64) .. ",y:63,z:" .. (z1 + 63) .. ",id:\"computercraft : command_computer\",label:\"" .. os.getComputerLabel() .. "\",on:0b}")
- commands.execAsync(teleport .. " @p " .. (x1 + 64) .. " 64 " .. (z1 + 65))
- for y = 2, 1, -1 do commands.execAsync("fill " .. (x1 - 4) .. " " .. y .. " " .. (z1 - 4) .. " " .. (x1 + 131) .. " " .. y .. " " .. (z1 + 131) .. " minecraft:stone") end
- elseif clickedAt(20, 31, 12) or pressedKey(keys.q, keys.x) then
- -- Exit.
- if myEvent[1] == "key" then os.pullEvent("char") end
- break
- end
- end
- ---------------------------------------------
- ------------ Exit ------------
- ---------------------------------------------
- term.setTextColour(colours.white)
- term.setBackgroundColour(colours.black)
- term.clear()
- term.setCursorPos(1, 1)
- print("Thanks for using mapArt!\n")
- shell.setDir(startDir)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement