Advertisement
Guest User

startup

a guest
May 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. turtle.select(1)
  2. turtle.refuel()
  3. for i=2,16,1 do
  4.   turtle.select(i)
  5.   turtle.refuel()
  6.   turtle.drop()
  7. end
  8.  
  9. function test()
  10. end
  11.  
  12. turtle.select(1)
  13. turtle.turnLeft()
  14. while true do
  15.   waitForNoRedstone("left",10)
  16.   moveOrRefuel(true)
  17.   if(peripheral.wrap("right").getEnergyStored==0)
  18.   then
  19.     moveOrRefuel(false)
  20.     repeat
  21.     until(redstone.getInput("left"))
  22.   else
  23.     shiftIt()
  24.     moverOrRefuel(false)
  25.   end
  26. end
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. function shiftIt()
  56. print("shifted")
  57. end
  58.  
  59.  
  60.  
  61. function waitForNoRedstone(side,time)
  62.   t=0
  63.   repeat
  64.     sleep(.1)
  65.     if(redstone.getInput(side))
  66.     then
  67.       t = 0
  68.     else
  69.       t = t+.1
  70.     end
  71.   until(t>time)
  72. end
  73.  
  74.  
  75. function moveOrRefuel(isForward)
  76.   success = false
  77.   if(isForward)
  78.   then
  79.     success = turtle.forward()
  80.   else
  81.     success = turtle.back()
  82.   end
  83.   if(not success)
  84.   then
  85.     if(turtle.getFuelLevel()==0)
  86.     then
  87.       refuel()
  88.     end
  89.     if(isForward)
  90.     then
  91.       success = turtle.forward()
  92.     else
  93.       success = turtle.back()
  94.     end
  95.     if(not success) then
  96.       if(isForward)
  97.       then
  98.         print("Error while trying to go forward")
  99.       else
  100.         print("Error while trying to go backward")
  101.       end
  102.       exit()
  103.     end
  104.   end
  105. end
  106.  
  107.  
  108.  
  109. function refuel()
  110.   turtle.select(1)
  111.   turtle.place()
  112.   turtle.suckUp("front")
  113.   for i=1,16,1 do
  114.     turtle.select(i)
  115.     turtle.refuel()
  116.     turtle.drop()
  117.   end
  118.   turtle.dig()
  119.   turtle.select(1)
  120. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement