SHOW:
|
|
- or go back to the newest paste.
1 | - | --Stairs Down Simple Script v1 |
1 | + | --Tunnel Simple Script v1 |
2 | --Turtle Program Computer Craft | |
3 | - | --by SemlerPDX(July2016) |
3 | + | --by SemlerPDX(July2021) |
4 | ||
5 | --pastebin get CJ5iY7G0 Tunnel | |
6 | - | --torches must be in slot 1 (one for every 3rd layer dug) |
6 | + | |
7 | - | --stairs can be in slot 2 if desired, see below |
7 | + | |
8 | --torches must be in slot 1 (one for every 8th block, 2nd row high) | |
9 | - | --StairsDown 20 (number of stairs down) 1 (or blank -- 1 will add stairs from slot 2) |
9 | + | |
10 | - | --example: StairsDown 20 (makes stairs 20 deep with torches but no stair blocks) |
10 | + | --Tunnel 20 (length in increments of 10) |
11 | - | --example2: StairsDown 20 1 (makes stairs 20 deep w/ torches and stair blocks) |
11 | + | --example: Tunnel 20 (makes tunnel 20 deep with torches) |
12 | ||
13 | ||
14 | -- Variables -- | |
15 | local args = {...} | |
16 | local d = args[1] or 0 | |
17 | - | local s = args[2] or 0 |
17 | + | |
18 | local t = turtle | |
19 | ||
20 | - | local lit = 2 |
20 | + | |
21 | if #args ~= 1 then | |
22 | print("<error420: syntax>") | |
23 | - | if #args ~= 2 then |
23 | + | print("<ex: Tunnel 20 (starts digging tunnel 20 blocks deep)>") |
24 | return | |
25 | - | print("<ex: Stairs 20 1 (starts digging stairs 20 blocks deep with stair blocks in slot 2)>") |
25 | + | |
26 | ||
27 | if d == 0 then | |
28 | print("<error421: missing length>") | |
29 | print("<ex: Tunnel 20 (starts digging tunnel 20 blocks deep)>") | |
30 | return | |
31 | - | print("<ex: Stairs 20 (starts digging stairs 20 blocks deep)>") |
31 | + | |
32 | ||
33 | -- Functions -- | |
34 | --force forward function by CCCode | |
35 | local function forceForward() | |
36 | while not t.forward() do | |
37 | t.dig() | |
38 | end | |
39 | end | |
40 | ||
41 | --dig down, decrement lit variable | |
42 | local function fDown() | |
43 | t.digDown() | |
44 | t.down() | |
45 | end | |
46 | ||
47 | - | lit = lit - 1 |
47 | + | --dig up, turn around |
48 | local function fUp() | |
49 | t.digUp() | |
50 | - | --shave 4 blocks and place torch if needed |
50 | + | t.up() |
51 | - | local function fShave() |
51 | + | |
52 | - | for v=1,4 do |
52 | + | |
53 | - | if v == 3 then |
53 | + | local function fRow() |
54 | - | if lit == 0 then |
54 | + | fUp() |
55 | - | t.placeUp() |
55 | + | fUp() |
56 | - | lit = lit + 2 |
56 | + | |
57 | - | forceForward() |
57 | + | for s=1,10 do |
58 | - | else |
58 | + | if v == 3 and s == 5 then |
59 | - | forceForward() |
59 | + | t.placeUp() |
60 | - | end |
60 | + | end |
61 | - | else |
61 | + | forceForward() |
62 | - | forceForward() |
62 | + | end |
63 | - | end |
63 | + | if v ~= 3 then |
64 | t.turnLeft() | |
65 | t.turnLeft() | |
66 | fDown() | |
67 | - | --move to next shaving position |
67 | + | end |
68 | - | local function fReturn() |
68 | + | |
69 | end | |
70 | - | t.back() |
70 | + | |
71 | --return home | |
72 | local function fHome() | |
73 | t.turnLeft() | |
74 | - | --place stairs while returning home |
74 | + | |
75 | - | local function fHomeS() |
75 | + | |
76 | forceForward() | |
77 | r = r -1 | |
78 | - | t.select(2) |
78 | + | |
79 | end | |
80 | - | t.place() |
80 | + | |
81 | - | t.up() |
81 | + | |
82 | - | t.forward() |
82 | + | |
83 | - | r = r -1 |
83 | + | |
84 | term.setCursorPos(1,1) | |
85 | end | |
86 | ||
87 | -- Pre-fire scripts -- | |
88 | fset() | |
89 | print("Beginning Tunnel "..tostring(d).." blocks long...") | |
90 | - | t.up() |
90 | + | --t.up() |
91 | - | t.back() |
91 | + | --t.down() |
92 | - | r = r -1 |
92 | + | |
93 | ||
94 | ---- Main Loop ---- | |
95 | while d ~= 0 do | |
96 | ||
97 | local function fcancel() | |
98 | local event, key = os.pullEvent("key") | |
99 | end | |
100 | ||
101 | local function fmain() | |
102 | fRow() | |
103 | d = d - 10 | |
104 | - | print("Building staircase "..tostring(d).." blocks down...") |
104 | + | |
105 | - | t.digDown() |
105 | + | |
106 | - | t.down() |
106 | + | |
107 | ||
108 | if FunctionEnabled == 1 then | |
109 | textutils.slowPrint("Cancelling Tunnel...", 15) | |
110 | sleep(1.65) | |
111 | break | |
112 | end | |
113 | ||
114 | end | |
115 | ||
116 | -- Evaluate Ending -- | |
117 | - | fShave() |
117 | + | |
118 | - | fReturn() |
118 | + | |
119 | - | fDown() |
119 | + | print("Tunnel Cancelled by user") |
120 | - | d = d - 1 |
120 | + | |
121 | fset() | |
122 | print("Tunnel Completed") | |
123 | print("Returning home...") | |
124 | fHome() | |
125 | t.select(1) | |
126 | - | textutils.slowPrint("Cancelling Build...", 15) |
126 | + | |
127 | print("...program complete") | |
128 | end |