Advertisement
McBaron

barts code

Jan 11th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. -- find out how long
  2. write("Put torches in slot 16. That's the bottom row , right corner. \n")
  3. write("Put as much fuel as you think you'll need in the other slots starting with #1. \n")
  4. write("How long should I make it? \n ")
  5. local length = tonumber( read() )
  6.  
  7. -- find out how many branches to make
  8. write("How many halls? ")
  9. local halls = tonumber(read())
  10. local fuel=1
  11. local x,y,z=0,0,0
  12.  
  13. function turnaround()
  14.         turtle.turnRight()
  15.         turtle.turnRight()
  16. end
  17.  
  18. function placemarker()
  19.         turtle.select(16)
  20.         turtle.placeDown()
  21. end
  22.  
  23. function refuel()
  24. --print("My fuel level is "..turtle.getItemCount(fuel))
  25.         if turtle.getItemCount(fuel) == 0 then
  26.                 fuel=fuel+1
  27.            else
  28.     end
  29.        
  30.         if turtle.getFuelLevel() < 21 then
  31.                 print("my fuel is  "..turtle.getFuelLevel())
  32.                 turtle.select(fuel)
  33.                 turtle.refuel(1)
  34.         end
  35. end
  36.  
  37. function run()
  38.         if not turtle.forward() then
  39.                 repeat
  40.                         refuel()
  41.                         turtle.dig()
  42.                         sleep(0.25)    
  43.                 until turtle.forward()
  44.         end
  45. end
  46.  
  47. function moveover()
  48.         turtle.turnLeft()
  49.                 for m=1,3 do
  50.                         run()
  51.                         z=z+1
  52.                          print("Z while moving = "..z)
  53.                         turtle.digDown()
  54.                 end
  55.         turtle.down()
  56.         turtle.turnLeft()
  57. end
  58.  
  59. function aBranch()
  60.         for d=1,length do
  61.                 run()
  62.         end
  63.         turtle.digUp()
  64.         turtle.up()
  65.         turnaround()
  66.         placemarker()
  67.         for d=1,length do
  68.                 run()
  69.         end
  70.         placemarker()
  71. end
  72.  
  73. --[[
  74. program starts here
  75. if the program turns too soon or too late,
  76. change i=< halls to i=halls or i<halls
  77. ]]
  78.        
  79. refuel()
  80. for i=1, halls do
  81. print("i start of loop = "..i)
  82. print("Z start of loop = "..z)
  83.         aBranch()
  84.                 if z<=((halls*3)-6) then -- z counts spaces to the left of starting.
  85.                 moveover()
  86.                 else
  87.                 end
  88. end
  89.  
  90. turtle.turnRight()
  91.  
  92. for rt=1,z do
  93.         run()
  94. end
  95. turtle.turnLeft()
  96.  
  97. print("I am finished")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement