Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function takeFromInv(args)
- args.count = args.count or 1
- while true do
- local success, reason = turtle.suck(args.count)
- if success then
- break
- else
- print(reason)
- sleep(10)
- end
- end
- end
- local function selectSlot(args)
- args.slot = args.slot or 1
- while true do
- if turtle.select(args.slot) then
- break
- else
- print(reason)
- sleep(10)
- end
- end
- end
- local function dropItems(args)
- args.count = args.count or 1
- while true do
- if turtle.drop(args.count) then
- break
- end
- sleep(5)
- end
- end
- local function move(args)
- args.count = args.count or 1
- for i=1,args.count do
- while true do
- success = false
- if args.direction=="up" then
- success = turtle.up()
- elseif args.direction=="down" then
- success = turtle.down()
- elseif args.direction=="forward" then
- success = turtle.forward()
- end
- if success then
- break
- end
- sleep(5)
- end
- end
- end
- local function moveAndTake(args)
- args.itemcount = args.itemcount or 1
- args.movecount = args.movecount or 1
- for i=1,args.movecount do
- move({direction=args.direction})
- takeFromInv({count=args.itemcount})
- selectSlot({slot = turtle.getSelectedSlot()+1})
- end
- end
- local function takeItems()
- moveAndTake({itemcount=1, direction="up", movecount=4})
- turtle.turnRight()
- takeFromInv({count=1})
- selectSlot({slot = turtle.getSelectedSlot()+1})
- moveAndTake({itemcount=4, direction="down", movecount=3})
- move({direction="down"})
- end
- local function insertItems()
- turtle.turnRight()
- for i =1,5 do
- selectSlot({slot = i})
- dropItems({count=1})
- end
- turtle.turnRight()
- for i =6,8 do
- selectSlot({slot = i})
- dropItems({count=4})
- end
- turtle.turnRight()
- end
- local function fuelup()
- if turtle.getFuelLevel()<10 then
- local success, reason = turtle.suck(1)
- while true do
- if success then
- break
- else
- print(reason)
- sleep(10)
- end
- end
- turtle.refuel(1)
- end
- end
- while true do
- selectSlot({})
- fuelup()
- takeItems()
- insertItems()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement