Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("theinsektAPIs/poz3")
- os.loadAPI("theinsektAPIs/poz3a")
- --return code: 0=blocked, -1=no_fuel, -2=reached_limit, 1< = found something
- function searchDigLoop(slots,limit)
- if(limit==nil) then limit=10000 end
- if(slots<1 or slots>16) then
- error("Error: slots have to be a number between 1 and 16 (inclusive).")
- end
- for slotNum = 1, slots do
- if(turtle.getItemCount(slotNum)==0) then
- error("Error: One of the given slots are empty")
- end
- end
- for i=0, limit do
- local slotNum=getSlotNumFUD(slots)
- if slotNum~=0 then return slotNum end
- poz3a.detectDig("u")
- poz3a.detectDig("d")
- if(not poz3a.detectDigGo2("f",true)) then
- if turtle.getFuelLevel()==0 then
- return -1--no fuel
- end
- return 0--blocked
- end
- end
- return -2
- end
- function getSlotNumFUD(slots)
- local slotNum=getSlotNum("f", slots)
- --print("FUD: ",slotNum)
- if(slotNum~=0) then return slotNum end
- local slotNum=getSlotNum("u", slots)
- --print("FUD: ",slotNum)
- if(slotNum~=0) then return slotNum end
- local slotNum=getSlotNum("d", slots)
- --print("FUD: ",slotNum)
- if(slotNum~=0) then return slotNum end
- --print("FUD r: ",0)
- return 0
- end
- function getSlotNum(direction, slots)
- --print(direction)
- if(poz3.detect(direction)) then
- --print("detected")
- for slotNum = 1, slots do
- --print("compare with: ",slotNum)
- turtle.select(slotNum)
- if poz3.compare(direction) then
- --print("match: ",slotNum)
- return slotNum
- end
- end
- end
- return 0
- end
- args={...}
- if(#args<1) then
- print("Usage: orefinder <slotNum> <optional_limit>")
- print("Will dig 3 high tunnel forward until finds one of the blocks in slots 1 to slotNum.")
- return
- end
- local slots=tonumber(args[1])
- local limit=10000
- if args[2]~=nil then
- limit=tonumber(args[2])
- end
- local res=searchDigLoop(slots,limit)
- --local res=getSlotNumFUD(slots)
- --local res=getSlotNum("d",slots)
- print(res)
- if res>0 then print("Found a match with slotNum ",res) end
- if res==0 then print("Blocked!") end
- if res==-1 then print("Out of fuel!") end
- if res==-2 then print("At limit!") end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement