Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CCT Turbine Rotor Auto Repair by Teki
- local freeSlot = 0
- local blockDetected, blockDetails = turtle.inspect()
- local details = turtle.getItemDetail()
- local bladesReady = false
- local bladesSlot = 0
- -- Processing Functions
- local function clearInventory()
- for i =1,16 do
- turtle.dropDown(i)
- end
- end
- local function getFirstFreeSlot()
- for i =1,16 do
- if turtle.getItemCount(i) == 0 then
- return i
- end
- end
- return 0
- end
- local function getRotorSlot()
- for i =1,16 do
- details = turtle.getItemDetail(i)
- if details ~= nil and details.name == "Railcraft:part.turbine.rotor" then
- print("Rotor Found in slot " .. i)
- return i
- end
- end
- print("No Rotor Found")
- return 0
- end
- local function getBladesSlot()
- for i =1,16 do
- details = turtle.getItemDetail(i)
- if details ~= nil and details.name == "Railcraft:part.turbine.blade" then
- print("Blades Found in slot " .. i)
- return i
- end
- end
- print("No Blades Found")
- return 0
- end
- -- Main Functions
- local function craftBlades()
- clearInventory()
- turtle.select(1)
- turtle.suckDown(8)
- turtle.select(5)
- turtle.suckDown(8)
- turtle.select(9)
- turtle.suckDown(8)
- turtle.craft()
- end
- local function prepareBlades()
- bladesSlot = getBladesSlot()
- if bladesSlot ~= 0 then
- turtle.select(bladesSlot)
- turtle.transferTo(1,1)
- turtle.transferTo(2,1)
- turtle.transferTo(3,1)
- turtle.transferTo(5,1)
- turtle.transferTo(7,1)
- turtle.transferTo(9,1)
- turtle.transferTo(10,1)
- turtle.transferTo(11,1)
- bladesReady = true
- return true
- else
- craftBlades()
- end
- end
- local function checkTurbine()
- blockDetected, blockDetails = turtle.inspect()
- if blockDetected and blockDetails.name == "Railcraft:machine.alpha" and blockDetails.metadata == 1 then
- turtle.select(6)
- if turtle.suck(1) then
- details = turtle.getItemDetail(6)
- if details.count == 1 and details.metadata >= 28000 then
- print("Turbine Rotor needs to be repaired !")
- print("Repairing ...")
- turtle.craft()
- print("Done !")
- else
- print("Turbine Rotor is in good enough state")
- end
- turtle.drop(getRotorSlot())
- return true
- else
- print("Can't catch Turbine Rotor")
- end
- else
- print("Not in front of a Steam Turbine Housing ! " .. blockDetails.name .. " " .. blockDetails.metadata)
- return false
- end
- end
- while true do
- if bladesReady then
- checkTurbine()
- else
- if prepareBlades() then
- checkTurbine()
- else
- print("Can't prepare Blades !")
- end
- end
- sleep(10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement