Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- NAME: SDIG
- -- usage SDIG <B> <Z> <S>
- -- digs a 1x3 tunnel of Z length in an S-shaped pattern, with B number of branches, with S spaces between each branch
- -- digs its way down main trunk to point of origin
- local tArgs = {...}
- local BTarget = tonumber(tArgs[1])
- local ZTarget = tonumber(tArgs[2])
- local STarget = tonumber(tArgs[3])
- local BPass = 0
- -- Dig a 1x3 chunk
- function ZDig()
- while (turtle.detect()) do
- turtle.dig()
- end
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- end
- -- Dig the branch of z length
- function Branch()
- for i=1, ZTarget do
- ZDig()
- if i % 8 == 0 then -- places torches every 8 spaces
- turtle.select(16)
- turtle.placeDown()
- end
- end
- BPass = BPass + 1 -- when the branch has been completed, increment the BPass
- end
- -- Turn the correct direction at end of branch
- function Orient()
- if BPass % 2 == 0 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- -- Dig to start of next branch (STarget spaces away)
- function GotoBranchStart()
- for i=1, (STarget+1) do
- ZDig()
- end
- Orient() -- point turtle in right direction
- end
- -- Return from location on main branch back to Origin
- function GotoOrigin()
- if BPass > 1 then
- for i=1, (BPass-1)*(1+STarget) do
- while (turtle.detect()) do
- turtle.dig()
- end
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- end
- end
- end
- -- PROGRAM
- Branch()
- while BPass < BTarget do
- Orient()
- GotoBranchStart()
- Branch()
- end
- if BPass % 2 ~= 0 then
- turtle.turnRight()
- turtle.turnRight()
- for i=1, ZTarget do
- turtle.forward()
- end -- now back at main branch
- end
- turtle.turnRight()
- GotoOrigin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement