Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- API for more complex mining functions
- os.loadAPI("theinsekt/turtle2")
- os.loadAPI("theinsekt/mine2")
- function tunnel3(length)
- local i=0
- while i<length do
- if mine2.digLoop("f",1)~=1 then
- return i
- end
- mine2.digLoop("u",0)
- mine2.digLoop("d",0)
- -- removes some extra gravel
- mine2.digLoop("u",0)
- i=i+1
- end
- return i
- end
- -- digs a 3 height tunnel, shaped
- -- like a horizontal U
- function horzU(length, width)
- local length2=tunnel3(length)
- if width>0 then
- mine2.turn("r",1)
- tunnel3(width)
- mine2.turn("r",1)
- else
- mine2.turn("l",1)
- tunnel3(-width)
- mine2.turn("l",1)
- end
- local length3=tunnel3(length2)
- -- returns the distance from start
- -- in the length direction
- return length2-length3
- end
- -- Digs an u, and then a reversed u,
- -- this creates a zigzag pattern.
- -- With width=3 and length>40
- -- a efficient strip mining pattern is
- -- created.
- function stripMine(length, width, iters)
- local i=0
- while i<iters do
- if horzU(length,width)~=0 then
- return i
- end
- horzU(0,-width)
- i=i+1
- end
- return i
- end
- -- direction can only be u or d
- function stairs(dir, length)
- if not (dir=="u" or dir=="d") then
- print("Error: direction must be u or d")
- return 0
- end
- local i=0
- while i<length do
- mine2.digLoop("u",0)
- mine2.digLoop("d",0)
- if mine2.digLoop("f",1)==0 then
- return i
- end --if
- mine2.digLoop("u",0)
- mine2.digLoop("d",0)
- if mine2.digLoop(dir,1)==0 then
- return i
- end --if
- i=i+1
- end
- end
- -- test
- --print(stairs("d",3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement