Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("left")
- local mainID = 15
- local touchID = 16
- local charcoal = false
- local function turnAround()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- local function goUp(count)
- for k = 1,count do
- turtle.up()
- end
- end
- local function goDown(count)
- for k = 1,count do
- turtle.down()
- end
- end
- while true do --Main Loop
- while turtle.getItemCount() == 0 do --Get items
- if not turtle.suck() then
- goDown(2)
- turtle.suckDown()
- goUp(2)
- end
- if turtle.getItemCount() == 0 then
- rednet.send(mainID, "home")
- sleep(.5)
- rednet.send(mainID, "2")
- sleep(60)
- rednet.send(mainID, "1")
- sleep(60)
- end
- end
- rednet.send(mainID, "0")
- sleep(.5)
- rednet.send(mainID, "away")
- if turtle.getItemCount() ~= 0 then
- local data = turtle.getItemDetail()
- if data.name == "minecraft:log" then --Sort logs
- --[[
- rednet.send(touchID, "charcoal")
- while true do
- id, message = rednet.receive()
- if id == touchID then
- charcoal = message
- break
- end
- end
- ]]
- if charcoal then
- turtle.turnLeft()
- if not turtle.drop() then
- goUp(4)
- turtle.turnLeft()
- turtle.drop()
- turtle.turnRight()
- goDown(4)
- end
- turtle.turnRight()
- else
- goUp(4)
- turnAround()
- turtle.drop()
- turnAround()
- goDown(4)
- end
- elseif data.name == "minecraft:sapling" then --Sort saplings
- goUp(1)
- if not turtle.drop() then
- goUp(3)
- turnAround()
- turtle.drop()
- turnAround()
- goDown(3)
- end
- goDown(1)
- elseif data.name == "minecraft:apple" then --Sort apples
- turnAround()
- goUp(1)
- turtle.drop()
- goDown(1)
- turnAround()
- elseif data.name == "minecraft:coal" then --Sort Charcoal and refuel (if needed)
- if turtle.getFuelLevel() < (turtle.getFuelLimit() - 5120) then
- turtle.refuel()
- else
- goDown(2)
- turtle.turnLeft()
- if not turtle.drop() then
- goUp(6)
- turnRight()
- if not turtle.drop() then
- turnAround()
- turtle.drop()
- turnAround()
- end
- goDown(4)
- else
- goUp(2)
- turtle.turnRight()
- end
- end
- else --Sort everything else
- goDown(1)
- turtle.turnRight()
- turtle.drop()
- turtle.turnLeft()
- goUp(1)
- end
- end
- end
- rednet.close("left")
Advertisement
Add Comment
Please, Sign In to add comment