Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- 2013 (c) psychedelixx
- Minecraft Turtle: Diagonal Hallway
- 2013-05-24
- Digs a diagonal hallway and places missing ground blocks and torches.
- Usage:
- - use turtle and type "label set <name>"
- (to give your turtle an unique name so it remembers its programs)
- - type "pastebin get d9CBNDCz diagonal"
- - place solid blocks in slot 16 (lower right corner)
- - place torches in slot 15 (left of slot 16)
- - type either "diagonal left ###" or "diagonal right ###" (replace ### with a number)
- --]]
- function move()
- print(turtle.getFuelLevel())
- if turtle.getFuelLevel() < 5 then
- turtle.refuel()
- end
- if not turtle.detectDown() then
- turtle.select(16)
- turtle.placeDown()
- end
- while not turtle.forward() do
- turtle.dig()
- end
- end
- local args = { ... }
- if #args < 2 then
- print( "Usage: diagonal <direction> (right / left) <limit>" )
- error()
- end
- dir = args[1]
- limit = tonumber(args[2])
- if turtle.getFuelLevel() == 0 then
- turtle.refuel()
- end
- if turtle.getFuelLevel() == 0 then
- print("I need fuel!")
- else
- print("======== 2013 (c) psychedelixx ========")
- print("Let's go!")
- move()
- turtle.digUp()
- if dir == "left" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- move()
- turtle.digUp()
- if dir == "left" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- while turtle.detect() do turtle.dig() end
- turtle.up()
- while turtle.detect() do turtle.dig() end
- if dir == "left" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- while turtle.detect() do turtle.dig() end
- turtle.down()
- move()
- if dir == "left" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- torchCount = 0
- while turtle.getFuelLevel() > 0 and limit > 0 do
- print("")
- print("Remaining: " .. limit)
- print("Fuel: " .. turtle.getFuelLevel())
- move()
- turtle.digUp()
- while turtle.detect() do turtle.dig() end
- turtle.up()
- while turtle.detect() do turtle.dig() end
- if torchCount%4 == 0 then
- turtle.select(15)
- turtle.place()
- end
- if dir == "left" then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- while turtle.detect() do turtle.dig() end
- turtle.down()
- move()
- if dir == "left" then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- limit = limit-1
- torchCount = torchCount + 1
- end
- move()
- turtle.digUp()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement