Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This program digs a mining stairs with a five levels down per filght of stairs
- -- Pastebin code = "TaFFELNp"; Pastebin name is "MDC_Stairs_Cut2"
- -- This program assumes that you place the turtle down on the forward end of the upper pad (a 2 stone x 2 stone)
- -- Place coal into Turtle slot #1 to assure adequate fueling
- -- Place stone into Turtle slot #2 and #3 to assure adequate placement resources
- -- This program begins by asking you to indicate whether you want to cut an upper hall (H response) or stairs (S response)
- if turtle.getFuelLevel() < 200 then
- print( "Your fuel level is less than 200; refueling with 240." )
- turtle.refuel(3)
- end
- local function fixHall() -- This function fixes one row of hallway
- if not turtle.detect() then turtle.select(2); turtle.place() end -- Check right and place
- if not turtle.detectUp() -- Move up
- then turtle.up()
- else turtle.digUp(); turtle.up() end
- if not turtle.detect() then turtle.select(2); turtle.place() end -- Check right and place
- if not turtle.detectUp() -- Move up
- then turtle.up()
- else turtle.digUp(); turtle.up() end
- if not turtle.detect() then turtle.select(2); turtle.place() end -- Check right and place
- if not turtle.detectUp() then turtle.select(2); turtle.placeUp() end -- Check up and place
- turtle.turnLeft(); turtle.down(); turtle.down()
- if not turtle.detect()
- then turtle.forward(); turtle.turnRight()
- else turtle.dig(); turtle.forward(); turtle.turnRight() end
- end
- print ( "Checking Entry." )
- local text_input = { ... } -- Obtain indicator of either H: Hallway cutting or S: Stairway cutting
- print( "1 text_input = ", text_input )
- if not (( text_input[1] == "S" ) or ( text_input[1] == "H" )) then
- print( "Error: You must respond with either a H for Hallway cutting or a S for Stairway cutting." )
- return
- end
- local desired_length = 5 + 2
- local desired_depth = 5
- while text_input == "H" do
- if not turtle.detect() -- Move forward and turn right
- then turtle.forward(); turtle.turnRight()
- else turtle.dig(); turtle.forward(); turtle.turnRight() end
- for iter1 = 1, desired_length do
- fixHall() -- Fix hallway for desired length
- end
- turtle.turnLeft(); turtle.turnLeft()
- if not turtle.detect() -- Reposition turtle for second cut
- then turtle.forward(); turtle.turnLeft()
- else turtle.dig(); turtle.forward(); turtle.turnLeft() end
- if not turtle.detect()
- then turtle.forward(); turtle.turnRight()
- else turtle.dig(); turtle.forward(); turtle.turnright() end
- for iter1 = 1, desired_length do
- fixHall() -- Fix hallway for desired length
- end
- turtle.turnLeft(); turtle.turnLeft(); turtle.forward(); turtle.turnLeft()
- text_input = "Done"
- end
- print( "2 text_input = ", text_input )
- while text_input == "S" do
- print( "3 text_input = ", text_input )
- for iter1 = 1, 1 do
- print( "Outer Loop")
- if not turtle.detect() then turtle.forward() -- Position turtle
- else turtle.dig(); turtle.forward(); end
- for iter2 = 0, ( desired_length - 1 ) do
- if not turtle.detectDown() then turtle.down(); turtle.turnRight()
- else turtle.digDown(); turtle.down(); turtle.turnRight(); end
- if not turtle.detect() then turtle.select(2); turtle.place(); end -- Check right and place
- turtle.up(); turtle.turnLeft()
- end
- end
- text_input = "Done"
- end
- print( "The program has ended successfully." )
Advertisement