Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Min is 3 for H--
- lengthMax = 50
- widthMax = 3
- heightMax = 3
- orientation = 4
- --N=4, E=3, S=2, W=1--
- orientations = {"north", "east", "south", "west"}
- startDirection = orientation
- xCurrent = 0
- zCurrent = 0
- yCurrent = 0
- xHome = 0
- zHome = 0
- yHome = 0
- xBlackcurrant = 0
- zBlackcurrant = 0
- yBlackcurrant = 0
- orientationLast = orientation
- zDiff = {-1, 0, 1, 0}
- xDiff = {0, 1, 0 ,-1}
- turn = 1
- turnLast = turn
- lengthCurrent = lengthMax
- placeTorch = 10
- width = widthMax
- finishWalk = widthMax
- heightCheck = heightMax
- heightMax = heightMax - 3
- height = heightMax
- ending = false
- kill = false
- said = false
- selectedSlot = 16
- answer = "F"
- facingAnswer = 0
- torchesGoCheck = "Pickles"
- startUpComplete = false
- saidYes = "Rainbows"
- hasTorch = false
- lengthSet = 0
- widthSet = 0
- heightSet = 0
- function fillFacing()
- print("Fill in which way I'm facing: ")
- print("North=4, East=3, South=2, West=1")
- facingAnswer = tonumber(read())
- while not(facingAnswer == 1 or facingAnswer == 2 or facingAnswer == 3 or facingAnswer == 4) do
- print("ERROR! Please try again!")
- print("Fill in which way I'm facing: ")
- print("North=4, East=3, South=2, West=1")
- facingAnswer = tonumber(read())
- end
- orientation = facingAnswer
- startDirection = orientation
- orientationLast = orientation
- shell.run("clear")
- end
- function answerWrong()
- print("ERROR! Please try again!")
- print("Do you want to fill in the dimensions? Type: 'Y' or 'N'")
- print("If 'N' then I will use the Default")
- print("Default: (L: " .. lengthMax .. ", W: " .. widthMax .. ", H: " .. heightCheck .. ")")
- answer = read()
- shell.run("clear")
- end
- function runStartup()
- if startUpComplete == false then
- shell.run("clear")
- print("I'm going to build you a room, Master.")
- print(" ")
- print("Do you want to fill in the dimensions? Type: 'Y' or 'N'")
- print("If 'N' then I will use the Default")
- print("Default: (L: " .. lengthMax .. ", W: " .. widthMax .. ", H: " .. heightCheck .. ")")
- answer = read()
- while not(answer == "Y" or answer == "N") do
- print("ERROR! Please try again!")
- print("Do you want to fill in the dimensions? Type: 'Y' or 'N'")
- print("If 'N' then I will use the Default")
- print("Default: (L: " .. lengthMax .. ", W: " .. widthMax .. ", H: " .. heightCheck .. ")")
- answer = read()
- shell.run("clear")
- end
- if answer == "N" then
- fillFacing()
- heightMax = heightMax + 3
- heightCheck = heightMax
- heightMax = heightMax - 3
- height = heightMax
- startUpComplete = true
- elseif answer == "Y" then
- shell.run("clear")
- print("Please Fill the Dimensions!")
- print(" ")
- print("Fill in the Length:")
- lengthSet = tonumber(read())
- lengthMax = lengthSet
- lengthCurrent = lengthMax
- while lengthSet == nil do
- print("ERROR! Please try again!")
- print("Fill in the Length:")
- lengthSet = tonumber(read())
- lengthMax = lengthSet
- lengthCurrent = lengthMax
- shell.run("clear")
- end
- shell.run("clear")
- print("Please Fill the Dimensions!")
- print(" ")
- print("Fill in the Width:")
- widthSet = tonumber(read())
- widthMax = widthSet
- width = widthMax
- while widthSet == nil do
- print("ERROR! Please try again!")
- print("Fill in the Width:")
- widthSet = tonumber(read())
- widthMax = widthSet
- width = widthMax
- shell.run("clear")
- end
- shell.run("clear")
- print("Please Fill the Dimensions!")
- print(" ")
- print("Fill in the Height:")
- heightSet = tonumber(read())
- heightMax = heightSet
- heightCheck = heightMax
- heightMax = heightMax - 3
- height = heightMax
- while heightSet == nil or heightSet < 3 do
- print("ERROR! Please try again!")
- print("Fill in the Height:")
- heightSet = tonumber(read())
- heightMax = heightSet
- heightCheck = heightMax
- heightMax = heightMax - 3
- height = heightMax
- shell.run("clear")
- end
- shell.run("clear")
- fillFacing()
- shell.run("clear")
- print("I will now start, Master.")
- print(" ")
- startUpComplete = true
- end
- end
- end
- function torchGo()
- while not(torchesGoCheck == "Go") do
- print("ERROR! Please try Again")
- print("Once I have Torches Type: 'Go'")
- torchesGoCheck = read()
- shell.run("clear")
- end
- end
- function torchAdded()
- while not(saidYes == "Y") do
- shell.run("clear")
- print("ERROR! Please try Again")
- print("Once I have Torches, Type: 'Y'")
- saidYes = read()
- end
- end
- function saidCheck()
- shell.run("clear")
- print("I need Torches in Slot.1, Master.")
- print("Once I have Torches Type: 'Y'")
- saidYes = read()
- torchAdded()
- end
- function torchCheck()
- while not(turtle.getItemDetail("minecraft:torch")) do
- if said == false then
- saidCheck()
- hasTorch = true
- end
- end
- if hasTorch == true then
- shell.run("clear")
- print("I'm Ready, Master. Type: 'Go' to Start")
- torchesGoCheck = read()
- torchGo()
- end
- shell.run("clear")
- hasTorch = false
- said = false
- end
- function left()
- orientation = orientation - 1
- orientation = (orientation - 1) % 4
- orientation = orientation + 1
- turtle.turnLeft()
- end
- function right()
- orientation = orientation - 1
- orientation = (orientation + 1) % 4
- orientation = orientation + 1
- turtle.turnRight()
- end
- function look(direction)
- while direction ~= orientations[orientation] do
- right()
- end
- end
- function moveForward()
- while turtle.detect() do
- turtle.dig()
- end
- moved = false
- while not(moved) do
- moved = turtle.forward()
- end
- xCurrent = xCurrent + xDiff[orientation]
- zCurrent = zCurrent + zDiff[orientation]
- end
- function digForward()
- while turtle.detect() do
- turtle.dig()
- end
- end
- function digBelow()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- function digAbove()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- function moveUp()
- turtle.digUp()
- moved = false
- while not(moved) do
- digAbove()
- moved = turtle.up()
- end
- yCurrent = yCurrent + 1
- end
- function moveDown()
- turtle.digDown()
- moved = false
- while not(moved) do
- moved = turtle.down()
- end
- yCurrent = yCurrent - 1
- end
- function goDown()
- moved = false
- while not(moved) do
- turtle.digDown()
- moved = turtle.down()
- end
- yCurrent = yCurrent - 1
- end
- function goUp()
- moved = false
- while not(moved) do
- digAbove()
- moved = turtle.up()
- end
- yCurrent = yCurrent + 1
- end
- function upBreak()
- digAbove()
- goUp()
- digAbove()
- end
- function leftDig()
- left()
- moveForward()
- digAbove()
- digBelow()
- while height > 0 do
- upBreak()
- height = height - 1
- end
- height = heightMax
- while height > 0 do
- moveDown()
- height = height - 1
- end
- height = heightMax
- left()
- end
- function rightDig()
- right()
- moveForward()
- digAbove()
- digBelow()
- while height > 0 do
- upBreak()
- height = height - 1
- end
- height = heightMax
- while height > 0 do
- moveDown()
- height = height - 1
- end
- height = heightMax
- right()
- end
- function leftWalk()
- left()
- moveForward()
- digAbove()
- digBelow()
- while height > 0 do
- upBreak()
- height = height - 1
- end
- height = heightMax
- while height > 0 do
- moveDown()
- height = height - 1
- end
- height = heightMax
- end
- function rightWalk()
- right()
- moveForward()
- digAbove()
- digBelow()
- while height > 0 do
- upBreak()
- height = height - 1
- end
- height = heightMax
- while height > 0 do
- moveDown()
- height = height - 1
- end
- height = heightMax
- end
- function goto(xHome, zHome, yHome)
- while yHome < yCurrent do
- moveDown()
- end
- while yHome > yCurrent do
- moveUp()
- end
- if xHome < xCurrent then
- look("west")
- while xHome < xCurrent do
- moveForward()
- end
- end
- if xHome > xCurrent then
- look("east")
- while xHome > xCurrent do
- moveForward()
- end
- end
- if zHome < zCurrent then
- look("north")
- while zHome < zCurrent do
- moveForward()
- end
- end
- if zHome > zCurrent then
- look("south")
- while zHome > zCurrent do
- moveForward()
- end
- end
- while not(orientation == startDirection) do
- right()
- end
- end
- function dropItems()
- turtle.select(16)
- selectedSlot = 16
- while not(selectedSlot == 1) do
- turtle.drop()
- selectedSlot = selectedSlot - 1
- turtle.select(selectedSlot)
- end
- end
- function lookLast()
- while not(orientation == orientationLast) do
- right()
- end
- end
- function dropOff()
- xBlackcurrant = xCurrent
- zBlackcurrant = zCurrent
- yBlackcurrant = yCurrent
- orientationLast = orientation
- turtle.select(16)
- if turtle.getItemCount() > 0 then
- print("Going to Drop Off")
- goto(xHome, zHome, yHome)
- dropItems()
- goto(xBlackcurrant, zBlackcurrant, yBlackcurrant)
- lookLast()
- elseif turtle.getItemCount() == 0 then
- turtle.select(1)
- end
- end
- while true do
- if lengthCurrent > 0 and ending == false then
- runStartup()
- dropOff()
- torchCheck()
- moveForward()
- digAbove()
- digBelow()
- while height > 0 do
- upBreak()
- height = height - 1
- end
- height = heightMax
- while height > 0 do
- moveDown()
- height = height - 1
- end
- height = heightMax
- placeTorch = placeTorch - 1
- lengthCurrent = lengthCurrent - 1
- if placeTorch <= 0 then
- placeTorch = 10
- turtle.placeDown()
- end
- end
- if lengthCurrent <= 0 and turn == 1 and width > 0 then
- width = width - 1
- if width > 0 then
- rightDig()
- lengthCurrent = lengthMax
- turn = 2
- print("Turned Right")
- end
- end
- if lengthCurrent <= 0 and turn == 2 and width > 0 then
- width = width - 1
- if width > 0 then
- leftDig()
- lengthCurrent = lengthMax
- turn = 1
- print("Turned Left")
- end
- end
- if width <= 0 then
- turnLast = turn
- turn = 3
- ending = true
- end
- if width <= 0 and turn == 3 and ending == true then
- print("Final Walk Home")
- goto(xHome, zHome, yHome)
- kill = true
- turn = 4
- end
- if kill == true then
- print("Killing the Program")
- error()
- end
- end
Add Comment
Please, Sign In to add comment