SHOW:
|
|
- or go back to the newest paste.
1 | - | local tArgs = { ... } |
1 | + | |
2 | - | if #tArgs ~= 1 then |
2 | + | |
3 | - | print( "Usage: quarry size <length>" ) |
3 | + | function startProgram() |
4 | - | print( "Place blocks in slots 1 - 14, place landmarks in 16" ) |
4 | + | print("Place Blocks in 1 - 14") |
5 | - | return |
5 | + | print("Place Landmark in 16") |
6 | print("Press Enter to start...") | |
7 | ||
8 | - | -- Set length with user input |
8 | + | -- Wait for the player to press Enter |
9 | - | local length = tonumber( tArgs[1] ) |
9 | + | read() |
10 | - | if length < 1 then |
10 | + | |
11 | - | print( "Side length must be positive" ) |
11 | + | print("Let's get started!") |
12 | - | return |
12 | + | |
13 | ||
14 | function putblockdown() | |
15 | if not (turtle.detectDown()) then | |
16 | while turtle.getItemCount(curSlot) == 0 and curSlot < 15 do | |
17 | - | while turtle.getItemCount(curSlot) == 0 and curSlot < 16 do |
17 | + | |
18 | end | |
19 | turtle.select(curSlot) | |
20 | turtle.placeDown() | |
21 | end | |
22 | end | |
23 | ||
24 | -- Place Landmark in front | |
25 | function placelmf() | |
26 | if not (turtle.detect()) then | |
27 | putblockdown() | |
28 | turtle.back() | |
29 | turtle.select(16) | |
30 | turtle.place() | |
31 | end | |
32 | end | |
33 | ||
34 | -- Place Landmark right | |
35 | - | -- Place Landmark left and right |
35 | + | function placelmr() |
36 | - | function placelmb() |
36 | + | turtle.turnRight() |
37 | safeMoveForward() | |
38 | - | turtle.turnRight() |
38 | + | safeMoveForward() |
39 | - | turtle.forward() |
39 | + | turtle.back() |
40 | - | putblockdown() |
40 | + | |
41 | putblockdown() | |
42 | turtle.back() | |
43 | turtle.select(16) | |
44 | turtle.place() | |
45 | turtle.turnLeft() | |
46 | - | turtle.forward() |
46 | + | |
47 | - | putblockdown() |
47 | + | |
48 | ||
49 | function safeMoveForward() | |
50 | -- Check if there's a block in front | |
51 | - | turtle.turnRight() |
51 | + | if turtle.detect() then |
52 | -- Break the block in front | |
53 | turtle.dig() | |
54 | ||
55 | - | function backhome() |
55 | + | -- Handle sand or gravel falling |
56 | - | x = length |
56 | + | while turtle.detect() do |
57 | turtle.dig() | |
58 | - | -- putblockdown() |
58 | + | end |
59 | end | |
60 | ||
61 | -- Move forward | |
62 | if not turtle.forward() then | |
63 | - | -- Move forward <length> times |
63 | + | print("Failed to move forward.") |
64 | end | |
65 | - | while i < length do |
65 | + | |
66 | - | turtle.forward() |
66 | + | |
67 | function backhome(x) | |
68 | while x > 0 do | |
69 | turtle.back() | |
70 | x = x - 1 | |
71 | - | backhome() |
71 | + | |
72 | end | |
73 | ||
74 | startProgram() | |
75 | - | while i < length do |
75 | + | |
76 | -- Get in postistion | |
77 | - | turtle.forward() |
77 | + | |
78 | safeMoveForward() | |
79 | safeMoveForward() | |
80 | safeMoveForward() | |
81 | - | placelmb() |
81 | + | turtle.turnRight() |
82 | - | backhome() |
82 | + | |
83 | -- Move length to place first Landmark and return home | |
84 | - | turtle.forward() |
84 | + | |
85 | while i < 64 do | |
86 | safeMoveForward() | |
87 | - | while i < length do |
87 | + | |
88 | - | turtle.forward() |
88 | + | |
89 | ||
90 | placelmf() | |
91 | backhome(63) | |
92 | -- Build platform | |
93 | - | backhome() |
93 | + | turtle.turnRight() |
94 | local i = 0 | |
95 | - | -- That's all, folks! |
95 | + | while i < 3 do |
96 | putblockdown() | |
97 | safeMoveForward() | |
98 | i = i + 1 | |
99 | end | |
100 | ||
101 | turtle.turnRight() | |
102 | safeMoveForward() | |
103 | turtle.turnRight() | |
104 | ||
105 | local i = 0 | |
106 | while i < 11 do | |
107 | putblockdown() | |
108 | safeMoveForward() | |
109 | i = i + 1 | |
110 | end | |
111 | ||
112 | turtle.turnRight() | |
113 | safeMoveForward() | |
114 | safeMoveForward() | |
115 | turtle.turnRight() | |
116 | safeMoveForward() | |
117 | ||
118 | local i = 0 | |
119 | while i < 11 do | |
120 | putblockdown() | |
121 | safeMoveForward() | |
122 | i = i + 1 | |
123 | end | |
124 | ||
125 | putblockdown() | |
126 | turtle.turnRight() | |
127 | safeMoveForward() | |
128 | turtle.turnRight() | |
129 | ||
130 | local i = 0 | |
131 | while i < 64 do | |
132 | putblockdown() | |
133 | safeMoveForward() | |
134 | i = i + 1 | |
135 | end | |
136 | ||
137 | placelmr() | |
138 | backhome(64) | |
139 | ||
140 | -- Fin | |
141 | print("Quarry setup") | |
142 | return |