Advertisement
Jkerr

Minecraft Turtle Program - Battle Tower Grabber

Jul 3rd, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. term.clear()
  2. print("Start where the first chest was facing the second half of the chest")
  3.  
  4. startingfuel = turtle.getFuelLevel()
  5.  
  6. print("-----------")
  7. print("Turtle fuel:")
  8. print(startingfuel)
  9.  
  10. if (startingfuel<300) then
  11.    print("--------------------------------------")
  12.    print("Low on fuel! (should have at least 300)")
  13.    return
  14. end
  15.  
  16. height = 0
  17. ceiling = false
  18. turtle.select(1)
  19.  
  20. function nextFloor()
  21.  
  22.   if turtle.detectUp() then
  23.     ceiling = true
  24.   else
  25.     ceiling = false
  26.   end
  27.   while ceiling ~= true do
  28.     turtle.up()
  29.     height=height+1
  30.     if turtle.detectUp() then
  31.       ceiling = true
  32.     else
  33.       ceiling = false
  34.     end
  35.   end
  36.  
  37. end
  38.  
  39. function reset()
  40.  
  41.      if height>0 then
  42.          for i=0,height,1 do
  43.           turtle.down()
  44.           height=height-1
  45.          end
  46.      end
  47.   turtle.select(1)
  48. end
  49.  
  50. function getChestContents()
  51.  
  52.    -- We're at the floor, break that first...
  53.    turtle.digUp()
  54.    turtle.up()
  55.    height=height+1
  56.    
  57.    -- Now the doubleslab the chest is on...
  58.    turtle.digUp()
  59.    turtle.up()
  60.    height=height+1
  61.    
  62.    -- now that half of the chest...
  63.    turtle.digUp()
  64.    turtle.suckUp()
  65.    turtle.up()
  66.    height=height+1
  67.    
  68.    -- Vacuum all around
  69.    turtle.turnRight()
  70.    turtle.suck()
  71.    turtle.turnRight()
  72.    turtle.suck()
  73.    turtle.turnRight()
  74.    turtle.suck()
  75.    turtle.turnRight()
  76.    
  77.    -- Break second half of chest
  78.    turtle.dig()
  79.    turtle.suck()
  80.    turtle.forward()
  81.    
  82.    -- Vacuum
  83.    turtle.suck()
  84.    turtle.turnRight()
  85.    turtle.suck()
  86.    turtle.turnRight()
  87.    turtle.suck()
  88.    turtle.turnRight()
  89.    turtle.suck()
  90.    turtle.turnRight()
  91.    
  92.    turtle.back()
  93.    
  94.    --Now back to the spot the chest was on, blocking the hole
  95.    turtle.down()
  96.    height=height-1
  97.    
  98. end
  99.  
  100. -- 9 floors above:
  101. nextFloor()
  102. getChestContents()
  103.  
  104. nextFloor()
  105. getChestContents()
  106.  
  107. nextFloor()
  108. getChestContents()
  109.  
  110. nextFloor()
  111. getChestContents()
  112.  
  113. nextFloor()
  114. getChestContents()
  115.  
  116. nextFloor()
  117. getChestContents()
  118.  
  119. nextFloor()
  120. getChestContents()
  121.  
  122. nextFloor()
  123. getChestContents()
  124.  
  125. nextFloor()
  126. getChestContents()
  127.  
  128. reset()
  129.  
  130. print("---------------------")
  131. print("Ending turtle fuel:")
  132. print(turtle.getFuelLevel())
  133. print("Fuel used:")
  134. print(startingfuel-turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement