SHOW:
|
|
- or go back to the newest paste.
1 | -- Print a line of dashes for aesthetics | |
2 | - | term.clear() |
2 | + | local function lineBreak() |
3 | - | term.setCursorPos(1, 1) |
3 | + | local width, height = term.getSize() |
4 | for i = 1, width do | |
5 | io.write("-") | |
6 | - | local modem = peripheral.find("modem") or error("No modem attached", 0) |
6 | + | end |
7 | - | modem.open(43) -- Open channel 43 to receive messages |
7 | + | io.write("\n") |
8 | end | |
9 | -- Function to clear the screen | |
10 | local function clearScreen() | |
11 | - | modem.transmit(15, 43, "Remote Connected") |
11 | + | term.clear() |
12 | term.setCursorPos(1, 1) | |
13 | - | local event, side, channel, replyChannel, message, distance |
13 | + | |
14 | - | repeat |
14 | + | |
15 | - | event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message") |
15 | + | |
16 | - | until channel == 43 |
16 | + | -- Print the welcome message |
17 | print("Artillery Controller") | |
18 | - | print(tostring(message)) |
18 | + | lineBreak() |
19 | print("Select a weapon:") | |
20 | - | -- Define the allowed options |
20 | + | print("1. TNT") |
21 | - | local allowedOptions = {"Bridge", "Courtyard", "Archive", "Stables", "Filters", "status"} |
21 | + | print("2. Nuke") |
22 | print("3. Arrow Spray") | |
23 | - | -- Prompt the user to choose from the options |
23 | + | lineBreak() |
24 | - | print("Choose one of the following options:") |
24 | + | |
25 | - | for i, option in ipairs(allowedOptions) do |
25 | + | local choice = read() |
26 | - | print(i .. ". " .. option) |
26 | + | |
27 | if choice == "1" then | |
28 | projectileType = "TNT" | |
29 | - | -- Validate user input |
29 | + | elseif choice == "2" then |
30 | - | local userInput |
30 | + | print("Authorization Code:") |
31 | - | repeat |
31 | + | local choice = read() |
32 | - | print("Enter the number corresponding to your choice:") |
32 | + | if choice == "1234" then |
33 | - | userInput = tonumber(read()) |
33 | + | print("Codes Accepted") |
34 | - | until userInput and allowedOptions[userInput] |
34 | + | projectileType = "Nuke" |
35 | end | |
36 | - | -- Send the chosen option |
36 | + | elseif choice == "3" then |
37 | - | local chosenOption = allowedOptions[userInput] |
37 | + | projectileType = "Arrows" |
38 | - | modem.transmit(15, 43, chosenOption) |
38 | + | |
39 | ||
40 | clearScreen() | |
41 | ||
42 | - | -- Wait for a reply |
42 | + | |
43 | - | repeat |
43 | + | -- Ask for shot size-- Ask for shot size |
44 | - | event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message") |
44 | + | print("Artillery Controller") |
45 | - | until channel == 43 |
45 | + | lineBreak() |
46 | print("Weapon:"..projectileType) | |
47 | - | print(tostring(message)) |
47 | + | lineBreak() |
48 | - | |
48 | + | print("Size of Shot:") |
49 | print("1. 1x1") | |
50 | print("2. 2x2") | |
51 | if projectileType == "TNT" then | |
52 | print("3. 3x3") | |
53 | print("4. 4x4") | |
54 | print("5. 5x5") | |
55 | print("6. Stab Charge") | |
56 | ||
57 | local choice = read() | |
58 | if choice == "2" then | |
59 | projectilePattern = "2x2" | |
60 | elseif choice == "3" then | |
61 | projectilePattern = "3x3" | |
62 | elseif choice == "4" then | |
63 | projectilePattern = "4x4" | |
64 | elseif choice == "5" then | |
65 | projectilePattern = "5x5" | |
66 | elseif choice == "6" then | |
67 | projectilePattern = "StabCharge" | |
68 | else | |
69 | projectilePattern = "Single" | |
70 | end | |
71 | ||
72 | elseif projectileType == "Nuke" then | |
73 | -- Nuke keeps only Single or 2x2 | |
74 | local choice = read() | |
75 | if choice == "2" then | |
76 | projectilePattern = "2x2" | |
77 | else | |
78 | projectilePattern = "Single" | |
79 | end | |
80 | ||
81 | elseif projectileType == "Arrows" then | |
82 | projectilePattern = "Spray" -- only spray pattern for arrow volley 🔫 | |
83 | end | |
84 | clearScreen() | |
85 | ||
86 | ||
87 | print("Artillery Controller") | |
88 | lineBreak() | |
89 | print("Weapon:"..projectileType) | |
90 | print("Pattern:"..projectilePattern) | |
91 | lineBreak() | |
92 | print("Number of Itterations") | |
93 | lineBreak() | |
94 | local iterations = tonumber(read()) | |
95 | clearScreen() | |
96 | ||
97 | print("Artillery Controller") | |
98 | lineBreak() | |
99 | print("Weapon:"..projectileType) | |
100 | print("Pattern:"..projectilePattern) | |
101 | lineBreak() | |
102 | print("Select a targeting method") | |
103 | print("1. Current Position") | |
104 | print("2. Custom Current") | |
105 | print("3. Offset Position") | |
106 | lineBreak() | |
107 | ||
108 | local choice = read() | |
109 | ||
110 | if choice == "2" then | |
111 | print("X: ") | |
112 | targetX = read() | |
113 | print("Y: ") | |
114 | targetY = read() | |
115 | print("Z: ") | |
116 | targetZ = read() | |
117 | elseif choice == "3" then | |
118 | X, Y, Z = gps.locate() | |
119 | print("X: ") | |
120 | targetX = X + read() | |
121 | print("Y: ") | |
122 | targetY = Y + read() | |
123 | print("Z: ") | |
124 | targetZ = Z + read() | |
125 | else | |
126 | targetX, targetY, targetZ = gps.locate() | |
127 | end | |
128 | ||
129 | clearScreen() | |
130 | print("Artillery Controller") | |
131 | lineBreak() | |
132 | print("Weapon:"..projectileType) | |
133 | print("Pattern:"..projectilePattern) | |
134 | print("X:"..targetX) | |
135 | print("Y:"..targetY) | |
136 | print("Z:"..targetZ) | |
137 | lineBreak() | |
138 | print("Please Confirm") | |
139 | print("1. Confirm Input") | |
140 | print("2. Cancel") | |
141 | lineBreak() | |
142 | ||
143 | ||
144 | local choice = read() | |
145 | ||
146 | if choice == "1" then | |
147 | local modem = peripheral.find("modem") or error("No modem attached", 0) | |
148 | modem.open(43) -- Open 43 so we can receive replies | |
149 | ||
150 | clearScreen() | |
151 | print("Artillery Controller") | |
152 | lineBreak() | |
153 | modem.transmit(15, 43, "Artillery") | |
154 | os.sleep(0.1) | |
155 | print("Artillery Connected") | |
156 | print("Starting Programing") | |
157 | lineBreak() | |
158 | ||
159 | modem.transmit(15, 43, projectileType) | |
160 | print("Weapon:"..projectileType) | |
161 | os.sleep(0.1) | |
162 | modem.transmit(15, 43, projectilePattern) | |
163 | print("Pattern:"..projectilePattern) | |
164 | os.sleep(0.1) | |
165 | modem.transmit(15, 43, iterations) | |
166 | print("Iterations:"..iterations) | |
167 | os.sleep(0.1) | |
168 | modem.transmit(15, 43, targetX) | |
169 | print("X:"..targetX) | |
170 | os.sleep(0.1) | |
171 | modem.transmit(15, 43, targetY) | |
172 | print("Y:"..targetY) | |
173 | os.sleep(0.1) | |
174 | modem.transmit(15, 43, targetZ) | |
175 | print("Z:"..targetZ) | |
176 | ||
177 | os.sleep(0.5) | |
178 | clearScreen() | |
179 | print("Artillery Controller") | |
180 | lineBreak() | |
181 | print("Programing Complete") | |
182 | lineBreak() | |
183 | print("Firing Now") | |
184 | ||
185 | clearScreen() | |
186 | print("Artillery Controller") | |
187 | lineBreak() | |
188 | print("Programing Complete") | |
189 | for i = 1, iterations+2 do | |
190 | local event, side, channel, replyChannel, message, distance | |
191 | repeat | |
192 | event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message") | |
193 | until channel == 43 | |
194 | print(tostring(message)) | |
195 | end | |
196 | else | |
197 | print("Cancelled") | |
198 | end | |
199 | ||
200 | os.sleep(1) | |
201 | shell.run("Greeting") |