SHARE
TWEET

Untitled

Mxx123456 Feb 27th, 2020 (edited) 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.   local temp = math.ceil(reactornum/6)-1
  49.   if temp ~= 0 then
  50.     for i=0,temp do
  51.       for j=1,5 do
  52.         turtle.up()
  53.       end
  54.     end
  55.   end
  56.   for i=1,3 do
  57.     turtle.forward()
  58.   end
  59.   if ( reactornum%6 == 1 ) or ( reactornum%6 == 4 ) then
  60.     turtle.turnRight()
  61.     for xtoreac=1,4 do
  62.       turtle.forward()
  63.     end
  64.     turtle.turnLeft()
  65.   else
  66.     if ( reactornum%6 == 3 ) or ( reactornum%6 == 0 ) then
  67.       turtle.turnLeft()
  68.       for xtoreactor=1,4 do
  69.         turtle.forward()
  70.       end
  71.       turtle.turnRight()
  72.     end
  73.   end
  74. end
  75. function GET_REACTOR(reactornum)
  76.   if ( reactornum%6 <= 3 ) and ( reactornum%6 ~= 0 ) then
  77.     turtle.down()
  78.     SUCK(0)
  79.     turtle.up()
  80.   else
  81.     turtle.up()
  82.     SUCK(1)
  83.     turtle.down()
  84.   end
  85. end
  86. function PUT_REACTOR(reactornum)
  87.   if ( reactornum%6 <= 3 ) and ( reactornum%6 ~= 0 ) then
  88.     turtle.down()
  89.     INSERT(0)
  90.     turtle.up()
  91.   else
  92.     turtle.up()
  93.     INSERT(1)
  94.     turtle.down()
  95.   end
  96. end
  97. function GET_BACK(reactornum)
  98.   if ( reactornum%6 == 1 ) or ( reactornum%6 == 4 ) then
  99.     turtle.turnLeft()
  100.     for i=1,4 do
  101.       turtle.forward()
  102.     end
  103.     turtle.turnLeft()
  104.   else
  105.     if ( reactornum%6 == 3 ) or ( reactornum%6 == 0 ) then
  106.       turtle.turnRight()
  107.       for i=1,4 do
  108.         turtle.forward()
  109.       end
  110.       turtle.turnRight()
  111.     else
  112.       turtle.turnLeft()
  113.       turtle.turnLeft()
  114.     end
  115.   end
  116.   for i=1,3 do
  117.     turtle.forward()
  118.   end
  119.   local temp = math.ceil(reactornum/6)-1
  120.   if temp ~= 0 then
  121.     for i=0,temp do
  122.       for j=1,5 do
  123.         turtle.down()
  124.       end
  125.     end
  126.   end
  127.   turtle.down()
  128.   turtle.turnLeft()
  129.   turtle.turnLeft()
  130. end
  131. function REACTOR_RENEW(reactornum)
  132.   local ReacFuel=0
  133.   local Fuel = true
  134.   GET_TO(reactornum)
  135.   GET_REACTOR(reactornum)
  136.   GET_BACK(reactornum)
  137.   turtle.turnLeft()
  138.   GET_RID_OF()
  139.   turtle.turnLeft()
  140.   GET_NEW()
  141.   if turtle.getItemDetail(4).name == "ic2:quad_mox_fuel_rod" then
  142.     ReacFuel=1
  143.   else
  144.     if turtle.getItemDetail(4).name == "ic2:quad_uranium_fuel_rod" then
  145.       ReacFuel=2
  146.     end
  147.   end
  148.   turtle.turnLeft()
  149.   while Fuel do
  150.     if turtle.getFuelLevel() < 1000 then
  151.       turtle.select(16)
  152.       turtle.suck(1)
  153.       turtle.drop()
  154.     else
  155.       Fuel = false
  156.     end
  157.   end
  158.   turtle.turnLeft()
  159.   GET_TO(reactornum)
  160.   PUT_REACTOR(reactornum)
  161.   GET_BACK(reactornum)
  162.   return ReacFuel
  163. end
  164. while true do
  165.   local ReacFuel=0
  166.   local Table = {0}
  167.   print(Table[1])
  168.   if fs.exists("disk/turt_ask") then
  169.     TurtAsk = fs.open("disk/turt_ask", "r")
  170.     Table[1] = tonumber(TurtAsk.readLine())
  171.     TurtAsk.close()
  172.     if Table[1] ~= 0 then
  173.       TurtAsk = fs.open("disk/turt_ask", "r")
  174.       Table[1] = tonumber(TurtAsk.readLine())
  175.       for i=1,Table[1] do
  176.         table.insert(Table, tonumber(TurtAsk.readLine()))
  177.       end
  178.       TurtAsk.close()
  179.       TurtState = fs.open("disk/turt_state", "w")
  180.       TurtState.writeLine(1)
  181.       TurtState.close()
  182.     end
  183.   else
  184.     sleep(10)
  185.   end
  186.   if Table[1] ~= 0 then
  187.     for i=1,Table[1] do
  188.       reactor=i+1
  189.       ReacFuel=REACTOR_RENEW(Table[reactor])
  190.     end
  191.   else
  192.     sleep(10)
  193.   end
  194.   TurtAns = fs.open("disk/turt_answer", "w")
  195.   TurtAns.writeLine(Table[1])
  196.   if Table[1] ~= 0 then
  197.     for i=1,Table[1] do
  198.       reactor=i+1
  199.       TurtAns.writeLine(Table[reactor])
  200.       TurtAns.writeLine(0)
  201.       TurtAns.writeLine(ReacFuel)
  202.     end
  203.   end
  204.   TurtAns.close()
  205.   if Table[1] ~= 0 then
  206.     sleep(11)
  207.     TurtAsk = fs.open("disk/turt_ask", "w")
  208.     TurtAsk.writeLine(0)
  209.     TurtAsk.close()
  210.     TurtState = fs.open("disk/turt_state", "w")
  211.     TurtState.writeLine(0)
  212.     TurtState.close()
  213.   end
  214. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top