Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- collect
- -- Collects specified blocks from chests left by 'branch' and 'bwb' programs
- -- Written by HarvDad, March 2014
- args = {...}
- nArgs = #args
- usage = "Usage: collect"
- print("collect: Rev 0.1")
- loop = 0;
- x = 0
- y = 0
- z = 0
- face = 0
- patchSlot = 2
- minimumFuel = 100
- missionMessage = "Mission complete."
- abort = false
- local currentFuelLevel = turtle.getFuelLevel()
- if (nArgs == 1 and args[1]== "help") then
- print("Collects specified blocks from in-ground chests")
- print(" as left by the 'branch' and 'bwb' programs.")
- print("Place fuel in slot 1")
- print("Place at least 1 block of target material in slot 2.")
- print("Turtle proceeds in straight line until it hits something")
- print(usage)
- return
- end
- if nArgs ~= 0 then
- print(usage)
- return
- end
- function suckChest()
- local i
- turtle.select(3)
- for i=3,16 do
- turtle.suckDown()
- end
- end
- targetSlot = 2
- function gatherTargetMaterial()
- local i
- for i=3,16 do
- turtle.select(i)
- if turtle.compareTo(targetSlot) then
- turtle.transferTo(targetSlot)
- end
- end
- end
- function dumpRejects()
- local i
- turtle.select(3)
- for i=3,16 do
- turtle.select(i)
- if not turtle.compareTo(targetSlot) then
- turtle.dropDown()
- end
- end
- end
- function home()
- while z > 0 do
- turtle.back()
- end
- end
- -- Main Program
- for i=1,100 do
- turtle.select(3)
- if turtle.suckDown() then
- turtle.dropDown()
- suckChest()
- dumpRejects()
- gatherTargetMaterial()
- end
- if not turtle.forward() then
- break
- end
- z = z+1
- end
- home()
- print(missionMessage, " Current fuel level is ", turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement