Advertisement
psychedelixx

Minecraft Turtle: Hallway

May 20th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.     2013 (c) psychedelixx
  3.     Minecraft Turtle: Hallway
  4.     2013-05-21
  5.  
  6.     Digs a simple hallway and places missing ground blocks and torches (every 11th horizontal block).
  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 VnRd9e6C hallway"
  12.     - place solid blocks in slot 16 (lower right corner)
  13.     - place torches in slot 15 (left of slot 16)
  14.     - type "hallway <length>"
  15.         • where <length> represents the maximum length of the hallway
  16. --]]
  17.  
  18. local args = { ... }
  19. if #args < 1 then
  20.   print( "Usage: hallway <length>" )
  21.   error()
  22. end
  23. limit = tonumber(args[1])
  24.  
  25. if turtle.getFuelLevel() == 0 then
  26.     turtle.refuel()
  27. end
  28.  
  29. if turtle.getFuelLevel() == 0 then
  30.     print("I need fuel!")
  31. else
  32.     print("======== 2013 (c) psychedelixx ========")
  33.     print("Let's go!")
  34.  
  35.     torchCount = 0
  36.    
  37.     while turtle.getFuelLevel() > 0 and limit > 0 do
  38.         print("")
  39.         print("Remaining: " .. limit)
  40.         print("Fuel: " .. turtle.getFuelLevel())
  41.         print("Next torch in: " .. 11-torchCount%11 .. "m")
  42.  
  43.         turtle.dig()
  44.         turtle.forward()
  45.         turtle.digUp()
  46.  
  47.         if not turtle.detectDown() then
  48.             turtle.select(16)
  49.             turtle.placeDown()
  50.         end
  51.    
  52.         if torchCount%11 == 0 then
  53.             turtle.turnRight()
  54.             turtle.dig()
  55.             turtle.select(15)
  56.             turtle.place()
  57.             turtle.turnLeft()
  58.         end
  59.         limit = limit-1
  60.         torchCount = torchCount + 1
  61.         if limit > 0 and turtle.getFuelLevel() < 2 then
  62.             turtle.refuel()
  63.         end
  64.     end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement