Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Tunnel Simple Script v1
- --Turtle Program Computer Craft
- --by SemlerPDX(July2021)
- --pastebin get CJ5iY7G0 Tunnel
- --COMMENT SYNTAX EXPLAINATION
- --torches must be in slot 1 (one for every 8th block, 2nd row high)
- --Tunnel 20 (length in increments of 10)
- --example: Tunnel 20 (makes tunnel 20 deep with torches)
- -- Variables --
- local args = {...}
- local d = args[1] or 0
- local r = 0 + d
- local t = turtle
- -- F-ACK --
- if #args ~= 1 then
- print("<error420: syntax>")
- print("<ex: Tunnel 20 (starts digging tunnel 20 blocks deep)>")
- return
- end
- if d == 0 then
- print("<error421: missing length>")
- print("<ex: Tunnel 20 (starts digging tunnel 20 blocks deep)>")
- return
- end
- -- Functions --
- --force forward function by CCCode
- local function forceForward()
- while not t.forward() do
- t.dig()
- end
- end
- --dig down, decrement lit variable
- local function fDown()
- t.digDown()
- t.down()
- end
- --dig up, turn around
- local function fUp()
- t.digUp()
- t.up()
- end
- local function fRow()
- fUp()
- fUp()
- for v=1,3 do
- for s=1,10 do
- if v == 3 and s == 5 then
- t.placeUp()
- end
- forceForward()
- end
- if v ~= 3 then
- t.turnLeft()
- t.turnLeft()
- fDown()
- end
- end
- end
- --return home
- local function fHome()
- t.turnLeft()
- t.turnLeft()
- while r ~=0 do
- forceForward()
- r = r -1
- end
- end
- --clear display screen
- local function fset()
- term.clear()
- term.setCursorPos(1,1)
- end
- -- Pre-fire scripts --
- fset()
- print("Beginning Tunnel "..tostring(d).." blocks long...")
- --t.up()
- --t.down()
- sleep(2)
- ---- Main Loop ----
- while d ~= 0 do
- local function fcancel()
- local event, key = os.pullEvent("key")
- end
- local function fmain()
- fRow()
- d = d - 10
- end
- FunctionEnabled = parallel.waitForAny(fcancel,fmain)
- if FunctionEnabled == 1 then
- textutils.slowPrint("Cancelling Tunnel...", 15)
- sleep(1.65)
- break
- end
- end
- -- Evaluate Ending --
- if FunctionEnabled == 1 then --(1 = functions cancelled, 2 = standard function looped)
- fset()
- print("Tunnel Cancelled by user")
- else
- fset()
- print("Tunnel Completed")
- print("Returning home...")
- fHome()
- t.select(1)
- fset()
- print("...program complete")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement