SHOW:
|
|
- or go back to the newest paste.
| 1 | - | --Tunnel Simple Script v1 |
| 1 | + | --Hollow Simple Script v1 |
| 2 | --Turtle Program Computer Craft | |
| 3 | --by SemlerPDX(July2021) | |
| 4 | ||
| 5 | - | --pastebin get CJ5iY7G0 Tunnel |
| 5 | + | --pastebin get BfnmYS5q Hollow |
| 6 | ||
| 7 | --COMMENT SYNTAX EXPLAINATION | |
| 8 | - | --torches must be in slot 1 (one for every 8th block, 2nd row high) |
| 8 | + | --torches must be in slot 1 (one for every 8th block, every 5th row) |
| 9 | ||
| 10 | - | --Tunnel 20 (length in increments of 10) |
| 10 | + | --example: Hollow 22 31 (makes empty room 22 blocks deep and 31 blocks wide, with full torch coverage) |
| 11 | - | --example: Tunnel 20 (makes tunnel 20 deep with torches) |
| 11 | + | |
| 12 | ||
| 13 | -- Variables -- | |
| 14 | local args = {...}
| |
| 15 | local d = args[1] or 0 | |
| 16 | local w = args[2] or 0 | |
| 17 | local r = 0 + d | |
| 18 | local dLit = 4 | |
| 19 | local wLit = 0 | |
| 20 | local t = turtle | |
| 21 | - | if #args ~= 1 then |
| 21 | + | |
| 22 | -- F-ACK -- | |
| 23 | - | print("<ex: Tunnel 20 (starts digging tunnel 20 blocks deep)>")
|
| 23 | + | if #args ~= 2 then |
| 24 | print("<error420: syntax>")
| |
| 25 | print("<ex: Hollow 20 10 (starts digging hollow 20 blocks deep and 10 blocks wide)>")
| |
| 26 | return | |
| 27 | end | |
| 28 | - | print("<error421: missing length>")
|
| 28 | + | |
| 29 | - | print("<ex: Tunnel 20 (starts digging tunnel 20 blocks deep)>")
|
| 29 | + | |
| 30 | print("<error421: missing depth>")
| |
| 31 | print("<ex: Hollow 20 10 (starts digging hollow 20 blocks deep and 10 blocks wide)>")
| |
| 32 | return | |
| 33 | end | |
| 34 | ||
| 35 | --if d <= 6 then | |
| 36 | -- print("<error421: depth too small>")
| |
| 37 | -- print("<ex: Hollow 10 10 (starts digging hollow 10 blocks deep and 10 blocks wide)>")
| |
| 38 | -- return | |
| 39 | --end | |
| 40 | ||
| 41 | -- Functions -- | |
| 42 | --force forward function by CCCode | |
| 43 | local function forceForward() | |
| 44 | while not t.forward() do | |
| 45 | t.dig() | |
| 46 | end | |
| 47 | end | |
| 48 | ||
| 49 | --dig down, decrement lit variable | |
| 50 | local function fDown() | |
| 51 | t.digDown() | |
| 52 | t.down() | |
| 53 | end | |
| 54 | ||
| 55 | --dig up, turn around | |
| 56 | local function fUp() | |
| 57 | - | for s=1,10 do |
| 57 | + | |
| 58 | - | if v == 3 and s == 5 then |
| 58 | + | |
| 59 | - | t.placeUp() |
| 59 | + | |
| 60 | ||
| 61 | local function fRow() | |
| 62 | fUp() | |
| 63 | fUp() | |
| 64 | for v=1,3 do | |
| 65 | for s=1,d do | |
| 66 | if v == 3 then | |
| 67 | - | end |
| 67 | + | if dLit == 0 and wLit == 0 then |
| 68 | dLit = 8 | |
| 69 | fUp() | |
| 70 | t.placeDown() | |
| 71 | forceForward() | |
| 72 | fDown() | |
| 73 | else | |
| 74 | forceForward() | |
| 75 | end | |
| 76 | if wLit == 0 then | |
| 77 | dLit = dLit - 1 | |
| 78 | end | |
| 79 | else | |
| 80 | forceForward() | |
| 81 | end | |
| 82 | end | |
| 83 | if v ~= 3 then | |
| 84 | t.turnLeft() | |
| 85 | t.turnLeft() | |
| 86 | fDown() | |
| 87 | end | |
| 88 | end | |
| 89 | - | print("Beginning Tunnel "..tostring(d).." blocks long...")
|
| 89 | + | |
| 90 | - | --t.up() |
| 90 | + | |
| 91 | - | --t.down() |
| 91 | + | local function fTurn() |
| 92 | t.turnLeft() | |
| 93 | forceForward() | |
| 94 | t.turnLeft() | |
| 95 | - | while d ~= 0 do |
| 95 | + | |
| 96 | ||
| 97 | ||
| 98 | --return home | |
| 99 | local function fHome() | |
| 100 | fUp() | |
| 101 | t.turnLeft() | |
| 102 | t.turnLeft() | |
| 103 | - | d = d - 10 |
| 103 | + | r = 0 + d |
| 104 | while r ~=0 do | |
| 105 | forceForward() | |
| 106 | r = r -1 | |
| 107 | end | |
| 108 | fDown() | |
| 109 | - | textutils.slowPrint("Cancelling Tunnel...", 15)
|
| 109 | + | |
| 110 | ||
| 111 | --clear display screen | |
| 112 | local function fset() | |
| 113 | term.clear() | |
| 114 | term.setCursorPos(1,1) | |
| 115 | end | |
| 116 | ||
| 117 | -- Pre-fire scripts -- | |
| 118 | fset() | |
| 119 | - | print("Tunnel Cancelled by user")
|
| 119 | + | print("Beginning Hollow "..tostring(d).." blocks deep and "..tostring(w).." blocks wide...")
|
| 120 | sleep(1) | |
| 121 | print(" -press any key to cancel-")
| |
| 122 | - | print("Tunnel Completed")
|
| 122 | + | |
| 123 | - | print("Returning home...")
|
| 123 | + | |
| 124 | ---- Main Loop ---- | |
| 125 | - | t.select(1) |
| 125 | + | while w ~= 0 do |
| 126 | ||
| 127 | local function fcancel() | |
| 128 | local event, key = os.pullEvent("key")
| |
| 129 | end | |
| 130 | ||
| 131 | local function fmain() | |
| 132 | fRow() | |
| 133 | fHome() | |
| 134 | fTurn() | |
| 135 | w = w - 1 | |
| 136 | if wLit == 0 then | |
| 137 | wLit = 5 | |
| 138 | end | |
| 139 | wLit = wLit - 1 | |
| 140 | dLit = 4 | |
| 141 | end | |
| 142 | ||
| 143 | FunctionEnabled = parallel.waitForAny(fcancel,fmain) | |
| 144 | ||
| 145 | if FunctionEnabled == 1 then | |
| 146 | textutils.slowPrint("Cancelling Hollow...", 15)
| |
| 147 | sleep(1.65) | |
| 148 | break | |
| 149 | end | |
| 150 | ||
| 151 | end | |
| 152 | ||
| 153 | -- Evaluate Ending -- | |
| 154 | if FunctionEnabled == 1 then --(1 = functions cancelled, 2 = standard function looped) | |
| 155 | fset() | |
| 156 | print("Hollow Cancelled by user")
| |
| 157 | else | |
| 158 | fset() | |
| 159 | print("Hollow "..tostring(args[1]).." "..tostring(args[2]).." Finished")
| |
| 160 | fset() | |
| 161 | print("...program complete")
| |
| 162 | end |