Advertisement
Shaka01

lava refuel

Nov 6th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. function clearscreen()
  2.     term.clear()
  3.     term.setCursorPos(1, 1)
  4. end
  5.  
  6. maxFuel = turtle.getFuelLimit()
  7. curFuel = turtle.getFuelLevel()
  8. missingFuel = maxFuel - curFuel
  9. bucketsNeeded = math.ceil(missingFuel / 1000)
  10. automaticLength = math.floor(bucketsNeeded / 2)
  11.  
  12. clearscreen()
  13. print("Currently at " ..curFuel.. "/" ..maxFuel.. " fuel.")
  14. print("\nAccording to my calculations I'll need to move [" ..automaticLength.. "] blocks to refuel completely.\n\nWanna do that? y/n")
  15. auto = read()
  16.  
  17. if auto == "y" then
  18.     laenge = automaticLength
  19. else
  20.     clearscreen()
  21.     print("How long?")
  22.     laenge = tonumber(read())
  23. end
  24.  
  25. print("To the left or right? l/r")
  26. dir = read()
  27.  
  28. print("Try to move into safe position? y/n ")
  29. safe = read()
  30.  
  31. lcount = 0
  32.  
  33. function finditem(item)
  34.     for i = 1, 16 do
  35.         if turtle.getItemCount(i) > 0 then
  36.             data = turtle.getItemDetail(i)
  37.             if data.name == item then
  38.                 turtle.select(i)
  39.                 return true
  40.             end
  41.         end
  42.     end
  43.     return false
  44. end
  45.  
  46. function safemove()
  47.     finditem("minecraft:bucket")
  48.     turtle.placeDown()
  49.     turtle.refuel()
  50.     if turtle.forward() == false then
  51.         turtle.dig()
  52.     else
  53.         lcount = lcount + 1
  54.     end
  55. end
  56.  
  57. function oneline()
  58.     repeat
  59.         safemove()
  60.     until lcount == laenge
  61.     lcount = 0
  62. end
  63.  
  64. function turn()
  65.     if dir == "l" then
  66.         turtle.turnLeft()
  67.     elseif dir == "r" then
  68.         turtle.turnRight()
  69.     end
  70. end
  71.  
  72. function fullturn()
  73.     finditem("minecraft:bucket")
  74.     turtle.placeDown()
  75.     turtle.refuel()
  76.     turn()
  77.     repeat turtle.dig() until turtle.forward()
  78.     turn()
  79. end
  80.  
  81. function movetosafety()
  82.     for i =1, 2 do
  83.         repeat turtle.digUp() until turtle.up()
  84.     end
  85.     for i=1, 2 do
  86.         repeat turtle.dig() until turtle.forward()
  87.     end
  88. end
  89.  
  90. function manualstart()
  91.     if finditem("minecraft:bucket") == false then
  92.  
  93.     repeat
  94.         clearscreen()
  95.         textutils.slowPrint("Need bucket or this won't work.")
  96.         sleep(1)
  97.     until finditem("minecraft:bucket")
  98.     end
  99.  
  100.     oneline()
  101.     fullturn()
  102.     oneline()
  103.     if safe == "y" then
  104.         movetosafety()
  105.     end
  106. end
  107.  
  108. manualstart()
  109. clearscreen()
  110. print("I'm now at " ..turtle.getFuelLevel() .." fuel.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement