Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function DROP(dropslot, top_bottom)
- turtle.select(dropslot)
- if top_bottom == 1 then
- turtle.dropUp(1)
- else
- turtle.dropDown(1)
- end
- end
- function SUCK(top_bottom)
- for slot=1,4 do
- turtle.select(slot)
- if top_bottom == 1 then
- turtle.suckUp()
- else
- turtle.suckDown()
- end
- end
- end
- function GET_RID_OF()
- turtle.select(4)
- turtle.drop()
- end
- function GET_NEW()
- turtle.select(4)
- turtle.suck(6)
- end
- function INSERT(top_bottom)
- for line=1,2 do
- for pattern=1,3 do
- for slot=1,3 do
- DROP(slot, top_bottom)
- end
- end
- for pattern=1,3 do
- DROP(2, top_bottom)
- DROP(4, top_bottom)
- DROP(2, top_bottom)
- end
- for pattern=1,3 do
- for slot=1,3 do
- DROP(4-slot, top_bottom)
- end
- end
- end
- end
- function GET_TO(reactornum)
- turtle.up()
- local temp = math.ceil(reactornum/6)-1
- if temp ~= 0 then
- for i=0,temp do
- for j=1,5 do
- turtle.up()
- end
- end
- end
- for i=1,3 do
- turtle.forward()
- end
- if ( reactornum%6 == 1 ) or ( reactornum%6 == 4 ) then
- turtle.turnRight()
- for xtoreac=1,4 do
- turtle.forward()
- end
- turtle.turnLeft()
- else
- if ( reactornum%6 == 3 ) or ( reactornum%6 == 0 ) then
- turtle.turnLeft()
- for xtoreactor=1,4 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- end
- end
- function GET_REACTOR(reactornum)
- if ( reactornum%6 <= 3 ) and ( reactornum%6 ~= 0 ) then
- turtle.down()
- SUCK(0)
- turtle.up()
- else
- turtle.up()
- SUCK(1)
- turtle.down()
- end
- end
- function PUT_REACTOR(reactornum)
- if ( reactornum%6 <= 3 ) and ( reactornum%6 ~= 0 ) then
- turtle.down()
- INSERT(0)
- turtle.up()
- else
- turtle.up()
- INSERT(1)
- turtle.down()
- end
- end
- function GET_BACK(reactornum)
- if ( reactornum%6 == 1 ) or ( reactornum%6 == 4 ) then
- turtle.turnLeft()
- for i=1,4 do
- turtle.forward()
- end
- turtle.turnLeft()
- else
- if ( reactornum%6 == 3 ) or ( reactornum%6 == 0 ) then
- turtle.turnRight()
- for i=1,4 do
- turtle.forward()
- end
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- for i=1,3 do
- turtle.forward()
- end
- local temp = math.ceil(reactornum/6)-1
- if temp ~= 0 then
- for i=0,temp do
- for j=1,5 do
- turtle.down()
- end
- end
- end
- turtle.down()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function REACTOR_RENEW(reactornum)
- local ReacFuel=0
- local Fuel = true
- GET_TO(reactornum)
- GET_REACTOR(reactornum)
- GET_BACK(reactornum)
- turtle.turnLeft()
- GET_RID_OF()
- turtle.turnLeft()
- GET_NEW()
- if turtle.getItemDetail(4).name == "ic2:quad_mox_fuel_rod" then
- ReacFuel=1
- else
- if turtle.getItemDetail(4).name == "ic2:quad_uranium_fuel_rod" then
- ReacFuel=2
- end
- end
- turtle.turnLeft()
- while Fuel do
- if turtle.getFuelLevel() < 1000 then
- turtle.select(16)
- turtle.suck(1)
- turtle.drop()
- else
- Fuel = false
- end
- end
- turtle.turnLeft()
- GET_TO(reactornum)
- PUT_REACTOR(reactornum)
- GET_BACK(reactornum)
- return ReacFuel
- end
- while true do
- local ReacFuel=0
- local Table = {0}
- print(Table[1])
- if fs.exists("disk/turt_ask") then
- TurtAsk = fs.open("disk/turt_ask", "r")
- Table[1] = tonumber(TurtAsk.readLine())
- TurtAsk.close()
- if Table[1] ~= 0 then
- TurtAsk = fs.open("disk/turt_ask", "r")
- Table[1] = tonumber(TurtAsk.readLine())
- for i=1,Table[1] do
- table.insert(Table, tonumber(TurtAsk.readLine()))
- end
- TurtAsk.close()
- TurtState = fs.open("disk/turt_state", "w")
- TurtState.writeLine(1)
- TurtState.close()
- end
- else
- sleep(10)
- end
- if Table[1] ~= 0 then
- for i=1,Table[1] do
- reactor=i+1
- ReacFuel=REACTOR_RENEW(Table[reactor])
- end
- else
- sleep(10)
- end
- TurtAns = fs.open("disk/turt_answer", "w")
- TurtAns.writeLine(Table[1])
- if Table[1] ~= 0 then
- for i=1,Table[1] do
- reactor=i+1
- TurtAns.writeLine(Table[reactor])
- TurtAns.writeLine(0)
- TurtAns.writeLine(ReacFuel)
- end
- end
- TurtAns.close()
- if Table[1] ~= 0 then
- sleep(11)
- TurtAsk = fs.open("disk/turt_ask", "w")
- TurtAsk.writeLine(0)
- TurtAsk.close()
- TurtState = fs.open("disk/turt_state", "w")
- TurtState.writeLine(0)
- TurtState.close()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement