Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- is_ender_chest = false
- torch_slot = 1
- torch_distance = 12
- chest_slot = 2
- turn_distance = 32
- -- 1 is left, 2 is right
- turn_dir = 1
- local function forward()
- while turtle.dig() do end
- turtle.forward()
- while turtle.digUp() do end
- end
- local function scan()
- local bool, data = turtle.inspect()
- if bool then
- if string.find(data.name,"diamond") then
- print("FOUND "..data.name.." WAITING FOR INPUT")
- read()
- end
- end
- end
- local function turn(movecount)
- if movecount % turn_distance == 0 then
- if 1 % turn_dir == 0 then
- turn_dir = 2
- turtle.turnLeft()
- forward()
- forward()
- forward()
- turtle.turnLeft()
- else
- turn_dir = 1
- turtle.turnRight()
- forward()
- forward()
- forward()
- turtle.turnRight()
- end
- end
- end
- local function torch(movecount)
- if movecount % torch_distance == 0 then
- turtle.turnLeft()
- turtle.turnLeft()
- while turtle.dig() do end
- turtle.select(torch_slot)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- local function checkSlots()
- hasItemsFlag = true
- repeat
- if turtle.getItemCount(torch_slot) == 0 then
- hasItemsFlag = false
- print("missing torches in slot "..torch_slot)
- elseif turtle.getItemCount(chest_slot) == 0 then
- hasItemsFlag = false
- print("missing chests in slot "..chest_slot)
- elseif turtle.getFuelLevel() < 1000 then
- hasItemsFlag = false
- print("turtle fuel is below acceptable levels ("..turtle.getFuelLevel()..")")
- else
- hasItemsFlag = true
- end
- sleep(1)
- until hasItemsFlag
- end
- local function dumpItems()
- turtle.digDown()
- turtle.select(chest_slot)
- if turtle.placeDown() then
- for i = 3, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- if is_ender_chest then
- turtle.select(chest_slot)
- turtle.digDown()
- end
- end
- local function isFull()
- fullFlag = true
- for i = 3, 16 do
- if turtle.getItemCount(i) == 0 then
- fullFlag = false
- end
- end
- if fullFlag then
- dumpItems()
- end
- end
- local function main()
- checkSlots()
- moves = 0
- while true do
- isFull()
- scan()
- torch(moves)
- forward()
- moves = moves + 1
- turn(moves)
- end
- end
- main()
Add Comment
Please, Sign In to add comment