Advertisement
psychedelixx

Minecraft Turtle: Diagonal Hallway

May 24th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.     2013 (c) psychedelixx
  3.     Minecraft Turtle: Diagonal Hallway
  4.     2013-05-24
  5.  
  6.     Digs a diagonal hallway and places missing ground blocks and torches.
  7.  
  8.     Usage:
  9.     - use turtle and type "label set <name>"
  10.       (to give your turtle an unique name so it remembers its programs)
  11.     - type "pastebin get d9CBNDCz diagonal"
  12.     - place solid blocks in slot 16 (lower right corner)
  13.     - place torches in slot 15 (left of slot 16)
  14.     - type either "diagonal left ###" or "diagonal right ###" (replace ### with a number)
  15. --]]
  16.  
  17. function move()
  18.     print(turtle.getFuelLevel())
  19.         if turtle.getFuelLevel() < 5 then
  20.                 turtle.refuel()
  21.         end
  22.         if not turtle.detectDown() then
  23.                 turtle.select(16)
  24.                 turtle.placeDown()
  25.         end
  26.  
  27.         while not turtle.forward() do
  28.                 turtle.dig()
  29.         end
  30. end
  31.  
  32. local args = { ... }
  33. if #args < 2 then
  34.   print( "Usage: diagonal <direction> (right / left) <limit>" )
  35.   error()
  36. end
  37. dir = args[1]
  38. limit = tonumber(args[2])
  39.  
  40. if turtle.getFuelLevel() == 0 then
  41.     turtle.refuel()
  42. end
  43.  
  44. if turtle.getFuelLevel() == 0 then
  45.     print("I need fuel!")
  46. else
  47.     print("======== 2013 (c) psychedelixx ========")
  48.     print("Let's go!")
  49.  
  50.     move()
  51.     turtle.digUp()
  52.     if dir == "left" then
  53.         turtle.turnLeft()
  54.     else
  55.         turtle.turnRight()
  56.     end
  57.     move()
  58.     turtle.digUp()
  59.     if dir == "left" then
  60.         turtle.turnRight()
  61.     else
  62.         turtle.turnLeft()
  63.     end
  64.     while turtle.detect() do turtle.dig() end
  65.     turtle.up()
  66.     while turtle.detect() do turtle.dig() end
  67.     if dir == "left" then
  68.         turtle.turnLeft()
  69.     else
  70.         turtle.turnRight()
  71.     end
  72.     while turtle.detect() do turtle.dig() end
  73.     turtle.down()
  74.     move()
  75.     if dir == "left" then
  76.         turtle.turnRight()
  77.     else
  78.         turtle.turnLeft()
  79.     end
  80.    
  81.     torchCount = 0
  82.     while turtle.getFuelLevel() > 0 and limit > 0 do
  83.         print("")
  84.         print("Remaining: " .. limit)
  85.         print("Fuel: " .. turtle.getFuelLevel())
  86.    
  87.         move()
  88.         turtle.digUp()
  89.         while turtle.detect() do turtle.dig() end
  90.         turtle.up()
  91.         while turtle.detect() do turtle.dig() end
  92.  
  93.         if torchCount%4 == 0 then
  94.             turtle.select(15)
  95.             turtle.place()
  96.         end
  97.        
  98.         if dir == "left" then
  99.             turtle.turnLeft()
  100.         else
  101.             turtle.turnRight()
  102.         end
  103.         while turtle.detect() do turtle.dig() end
  104.         turtle.down()
  105.         move()
  106.        
  107.         if dir == "left" then
  108.             turtle.turnRight()
  109.         else
  110.             turtle.turnLeft()
  111.         end
  112.        
  113.         limit = limit-1
  114.         torchCount = torchCount + 1
  115.     end
  116.     move()
  117.     turtle.digUp()
  118. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement