Advertisement
Guest User

1.lua

a guest
Feb 27th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.10 KB | None | 0 0
  1. function DROP(dropslot, top_bottom)
  2.     turtle.select(dropslot)
  3.     if top_bottom == 1 then
  4.         turtle.dropUp(1)
  5.     else
  6.         turtle.dropDown(1)
  7.     end
  8. end
  9. function SUCK(top_bottom)
  10.     for slot=1,4 do
  11.         turtle.select(slot)
  12.         if top_bottom == 1 then
  13.             turtle.suckUp()
  14.         else    
  15.             turtle.suckDown()
  16.         end
  17.     end
  18. end
  19. function GET_RID_OF()
  20.     turtle.select(4)
  21.     turtle.drop()
  22. end
  23. function GET_NEW()
  24.     turtle.select(4)
  25.     turtle.suck(6)
  26. end
  27. function INSERT(top_bottom)
  28.     for line=1,2 do
  29.         for pattern=1,3 do
  30.             for slot=1,3 do
  31.                 DROP(slot, top_bottom)
  32.             end
  33.         end
  34.         for pattern=1,3 do
  35.             DROP(2, top_bottom)
  36.             DROP(4, top_bottom)
  37.             DROP(2, top_bottom)
  38.         end
  39.         for pattern=1,3 do
  40.             for slot=1,3 do
  41.                 DROP(4-slot, top_bottom)
  42.             end
  43.         end
  44.     end
  45. end
  46. function GET_TO(reactornum)
  47.     turtle.up()
  48.     turtle.forward()
  49.     turtle.forward()
  50.     turtle.forward()
  51.     if ( reactornum == 1 ) or ( reactornum == 4 ) then
  52.         turtle.turnRight()
  53.         for xtoreac=1,4 do
  54.             turtle.forward()
  55.         end
  56.         turtle.turnLeft()
  57.     else
  58.         if ( reactornum == 3 ) or ( reactornum == 6 ) then
  59.             turtle.turnLeft()
  60.             for xtoreactor=1,4 do
  61.                 turtle.forward()
  62.             end
  63.             turtle.turnRight()
  64.         end
  65.     end
  66. end
  67. function GET_REACTOR(reactornum)
  68.     if reactornum <= 3 then
  69.         turtle.down()
  70.         SUCK(0)
  71.         turtle.up()
  72.     else
  73.         turtle.up()
  74.         SUCK(1)
  75.         turtle.down()
  76.     end
  77. end
  78. function PUT_REACTOR(reactornum)
  79.     if reactornum <=3 then
  80.         turtle.down()
  81.         INSERT(0)
  82.         turtle.up()
  83.     else
  84.         turtle.up()
  85.         INSERT(1)
  86.         turtle.down()
  87.     end
  88. end
  89. function GET_BACK(reactornum)
  90.     if ( reactornum == 1 ) or ( reactornum == 4 ) then
  91.         turtle.turnLeft()
  92.         for i=1,4 do
  93.             turtle.forward()
  94.         end
  95.         turtle.turnLeft()
  96.     else
  97.         if ( reactornum == 3 ) or ( reactornum == 6 ) then
  98.             turtle.turnRight()
  99.             for i=1,4 do
  100.                 turtle.forward()
  101.             end
  102.             turtle.turnRight()
  103.         else
  104.             turtle.turnLeft()
  105.             turtle.turnLeft()
  106.         end
  107.     end
  108.     turtle.forward()
  109.     turtle.forward()
  110.     turtle.forward()
  111.     turtle.down()
  112.     turtle.turnLeft()
  113.     turtle.turnLeft()
  114. end
  115. function REACTOR_RENEW(reactornum)
  116.     local Fuel = true
  117.     GET_TO(reactornum)
  118.     GET_REACTOR(reactornum)
  119.     GET_BACK(reactornum)
  120.     turtle.turnLeft()
  121.     GET_RID_OF()
  122.     turtle.turnLeft()
  123.     GET_NEW()
  124.     turtle.turnLeft()
  125.     while Fuel do
  126.         if turtle.getFuelLevel() < 1000 then
  127.             turtle.select(16)
  128.             turtle.suck(1)
  129.             turtle.drop()
  130.         else
  131.             Fuel = false
  132.         end
  133.     end
  134.     turtle.turnLeft()
  135.     GET_TO(reactornum)
  136.     PUT_REACTOR(reactornum)
  137.     GET_BACK(reactornum)
  138. end
  139. REACTOR_RENEW(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement