Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Clears a x by y by z area
- local turtleId
- local isWirelessTurtle
- local messageOutputFileName
- isWirelessTurtle = peripheral.isPresent("right")
- if (isWirelessTurtle == true) then
- turtleId = os.getComputerLabel()
- rednet.open("right")
- end
- function writeMessage(message)
- print(message)
- -- If this turtle has a modem, then write the message to red net
- if (isWirelessTurtle == true) then
- if (turtleId == nil) then
- rednet.broadcast(message)
- else
- -- Broadcast the message (prefixed with the turtle's id)
- rednet.broadcast("[".. turtleId.."] "..message)
- end
- end
- if (messageOutputFileName ~= nil) then
- -- Open file, write message and close file (flush doesn't seem to work!)
- local outputFile = io.open(messageOutputFileName, "a")
- outputFile:write(message)
- outputFile:write("\n")
- outputFile:close()
- end
- end
- function refuel()
- turtle.select(1)
- turtle.refuel(64)
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function clearLine()
- for i = 1, depth do
- turtle.dig()
- turtle.forward()
- end
- for i = 1, depth do
- turtle.back()
- end
- end
- function clearWall()
- for i = 1, height do
- turtle.digUp()
- clearLine()
- turtle.up()
- end
- for i = 1, height do
- turtle.down()
- end
- end
- function clearCube()
- for i = 1, width do
- clearWall()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- turtle.turnLeft()
- for i = 1, width+1 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- term.write("Insert depth: ")
- depth = tonumber(read())
- print(" ")
- term.write("Insert width: ")
- width = tonumber(read())
- print(" ")
- term.write("Insert height: ")
- height = tonumber(read())
- print(" ")
- writeMessage("beginning to clear")
- refuel()
- clearCube()
- writeMessage("Done Clearing")
Advertisement
Add Comment
Please, Sign In to add comment