· 7 years ago · Feb 23, 2019, 04:34 AM
1InstallDir = ...
2if InstallDir == nil then InstallDir = '/' end
3term.clear()
4term.setCursorPos(1,1)
5print('Do you wish to install Min? (Y/N)')
6local x = read()
7
8if x == 'y' or x == 'Y' then
9local NF = fs.open(InstallDir..'/Min','w')
10NF.write(''
11..'--- This renders a minimap showing nearby ores using the overlay glasses and block scanner.\n'
12..'\n'
13..'--- We start the program by specifying a series of configuration options. Feel free to ignore these, and use the values\n'
14..'--- inline. Whilst you don't strictly speaking need a delay between each iteration, it does reduce the impact on the\n'
15..'--- server.\n'
16..'local scanInterval = 0.2\n'
17..'local renderInterval = 0.05\n'
18..'local scannerRange = 8\n'
19..'local scannerWidth = scannerRange * 2 + 1\n'
20..'\n'
21..'--- These values aren't very exciting, they just control what the minimap looks like\n'
22..'local size = 0.5\n'
23..'local cellSize = 16\n'
24..'local offsetX = 75\n'
25..'local offsetY = 75\n'
26..'\n'
27..'--- We end our on figuration section by defining the ores we're interested in and what colour we'll draw them as. We\n'
28..'--- define some ores as having a higher priority, so large ore veins don't mask smaller veins of more precious ores.\n'
29..'local ores = {\n'
30..' ["minecraft:emerald_ore"] = 10,\n'
31..' ["bno:ore_netheremerald"] = 10\n'
32..'}\n'
33..'\n'
34..'local colours = {\n'
35..' ["minecraft:emerald_ore"] = { 0, 255, 0 },\n'
36..' ["bno:ore_netheremerald"] = { 0, 255, 0 }\n'
37..'}\n'
38..'\n'
39..'--- Now let's get into the interesting stuff! Let's look for a neural interface and check we've got all the required\n'
40..'--- modules.\n'
41..'local modules = peripheral.find("neuralInterface")\n'
42..'if not modules then error("Must have a neural interface", 0) end\n'
43..'if not modules.hasModule("plethora:scanner") then error("The block scanner is missing", 0) end\n'
44..'if not modules.hasModule("plethora:glasses") then error("The overlay glasses are missing", 0) end\n'
45..'\n'
46..'--- Now we've got our neural interface, let's extract the canvas and ensure nothing else is on it.\n'
47..'local canvas = modules.canvas()\n'
48..'canvas.clear()\n'
49..'\n'
50..'--- We now need to set up our minimap. We create a 2D array of text objects around the player, each starting off\n'
51..'--- displaying an empty string. If we find an ore, we'll update their colour and text.\n'
52..'local block_text = {}\n'
53..'local blocks = {}\n'
54..'for x = -scannerRange, scannerRange, 1 do\n'
55..' block_text[x] = {}\n'
56..' blocks[x] = {}\n'
57..'\n'
58..' for z = -scannerRange, scannerRange, 1 do\n'
59..' block_text[x][z] = canvas.addText({ 0, 0 }, " ", 0xFFFFFFFF, size)\n'
60..' blocks[x][z] = { y = nil, block = nil }\n'
61..' end\n'
62..'end\n'
63..'\n'
64..'--- We also create a marker showing the current player's location.\n'
65..'canvas.addText({ offsetX, offsetY }, "^", 0xFFFFFFFF, size * 2)\n'
66..'\n'
67..'--- Our first big function is the scanner: this searches for ores near the player, finds the most important ones, and\n'
68..'--- updates the block table.\n'
69..'local function scan()\n'
70..' while true do\n'
71..' local scanned_blocks = modules.scan()\n'
72..'\n'
73..' --- For each nearby position, we search the y axis for interesting ores. We look for the one which has\n'
74..' --- the highest priority and update the block information\n'
75..' for x = -scannerRange, scannerRange do\n'
76..' for z = -scannerRange, scannerRange do\n'
77..' local best_score, best_block, best_y = -1\n'
78..' for y = -scannerRange, scannerRange do\n'
79..' --- The block scanner returns blocks in a flat array, so we index into it with this rather scary formulae.\n'
80..' local scanned = scanned_blocks[scannerWidth ^ 2 * (x + scannerRange) + scannerWidth * (y + scannerRange) + (z + scannerRange) + 1]\n'
81..'\n'
82..' --- If there is a block here, and it's more interesting than our previous ores, then let's use that!\n'
83..' if scanned then\n'
84..' local new_score = ores[scanned.name]\n'
85..' if new_score and new_score > best_score then\n'
86..' best_block = scanned.name\n'
87..' best_score = new_score\n'
88..' best_y = y\n'
89..' end\n'
90..' end\n'
91..' end\n'
92..'\n'
93..' -- Update our block table with this information.\n'
94..' blocks[x][z].block = best_block\n'
95..' blocks[x][z].y = best_y\n'
96..' end\n'
97..' end\n'
98..'\n'
99..' --- We wait for some delay before starting again. This isn't _strictly_ needed, but helps reduce server load\n'
100..' sleep(scanInterval)\n'
101..' end\n'
102..'end\n'
103..'\n'
104..'--- The render function takes our block information generated in the previous function and updates the text elements.\n'
105..'local function render()\n'
106..' while true do\n'
107..' --- If possible, we rotate the map using the current player's look direction. If it's not available, we'll just\n'
108..' --- use north as up.\n'
109..' local meta = modules.getMetaOwner and modules.getMetaOwner()\n'
110..' local angle = meta and math.rad(-meta.yaw % 360) or 0\n'
111..'\n'
112..' --- Like before, loop over every nearby block and update something. Though this time we're updating objects on\n'
113..' --- the overlay canvas.\n'
114..' for x = -scannerRange, scannerRange do\n'
115..' for z = -scannerRange, scannerRange do\n'
116..' local text = block_text[x][z]\n'
117..' local block = blocks[x][z]\n'
118..'\n'
119..' if block.block then\n'
120..' --- If we've got a block here, we update the position of our text element to account for rotation,\n'
121..' local px = math.cos(angle) * -x - math.sin(angle) * -z\n'
122..' local py = math.sin(angle) * -x + math.cos(angle) * -z\n'
123..'\n'
124..' local sx = math.floor(px * size * cellSize)\n'
125..' local sy = math.floor(py * size * cellSize)\n'
126..' text.setPosition(offsetX + sx, offsetY + sy)\n'
127..'\n'
128..' --- Then change the text and colour to match the location of the ore\n'
129..' text.setText(tostring(block.y))\n'
130..' text.setColor(table.unpack(colours[block.block]))\n'
131..' else\n'
132..' --- Otherwise we just make sure the text is empty. We don't need to faff about with clearing the\n'
133..' --- colour or position, as we'll change it next iteration anyway.\n'
134..' text.setText(" ")\n'
135..' end\n'
136..' end\n'
137..' end\n'
138..'\n'
139..' sleep(renderInterval)\n'
140..' end\n'
141..'end\n'
142..'\n'
143..'--- We now run our render and scan loops in parallel, continually updating our block list and redisplaying it to the\n'
144..'--- wearer.\n'
145..'parallel.waitForAll(render, scan)\n'
146)
147NF.close()
148end
149
150
151
152
153
154InstallDir = ...
155if InstallDir == nil then InstallDir = '/' end
156term.clear()
157term.setCursorPos(1,1)
158print('Do you wish to install Packager? (Y/N)')
159local x = read()
160
161if x == 'y' or x == 'Y' then
162local NF = fs.open(InstallDir..'/Packager','w')
163NF.write(''
164..'Args = {...}\n'
165..'if type(Args[1]) ~= "string" or type(Args[2]) ~= "string" or type(Args[3]) ~= "string" then\n'
166..' error("Arguments: <DirToCombine> <DefaultInstallDir> <OutputFileName>")\n'
167..'end\n'
168..'if fs.exists(Args[1]) ~= true then error("Directory is non-existent.") end\n'
169..'if fs.exists(Args[3]) == true then error("File already exists") end\n'
170..'List = fs.list(Args[1])\n'
171..'z = fs.open(Args[3],"w")\n'
172..'for i = 1, #List do\n'
173..' z.writeLine("InstallDir = ...")\n'
174..' z.writeLine("if InstallDir == nil then InstallDir = '"..Args[2].."' end")\n'
175..' z.writeLine("term.clear()")\n'
176..' z.writeLine("term.setCursorPos(1,1)")\n'
177..' z.writeLine("print('Do you wish to install "..List[i].."? (Y/N)')")\n'
178..' z.writeLine("local x = read()")\n'
179..' z.writeLine("")\n'
180..' z.writeLine("if x == 'y' or x == 'Y' then")\n'
181..' z.writeLine("local NF = fs.open(InstallDir..'/"..List[i].."','w')")\n'
182..' F = fs.open(Args[1].."/"..List[i],"r")\n'
183..' z.writeLine("NF.write(''")\n'
184..' repeat\n'
185..' Lin = F.readLine()\n'
186..' if Lin ~= nil then\n'
187..' z.writeLine("..'"..Lin.."\\n'")\n'
188..' end\n'
189..' until Lin == nil\n'
190..' z.writeLine(")")\n'
191..' F.close()\n'
192..' z.writeLine("NF.close()")\n'
193..' z.writeLine("end")\n'
194..' for i = 1,5 do\n'
195..' z.writeLine("")\n'
196..' end\n'
197..'end\n'
198..'z.close()\n'
199)
200NF.close()
201end
202
203
204
205
206
207InstallDir = ...
208if InstallDir == nil then InstallDir = '/' end
209term.clear()
210term.setCursorPos(1,1)
211print('Do you wish to install cht.lua? (Y/N)')
212local x = read()
213
214if x == 'y' or x == 'Y' then
215local NF = fs.open(InstallDir..'/cht.lua','w')
216NF.write(''
217..'rednet.open("front")\n'
218..'CH = peripheral.wrap("back")\n'
219..'Token = "aa679-23b"\n'
220..'Info = {}\n'
221..'CH.capture("seedy bois")\n'
222..'CH.capture("bamzino")\n'
223..'while true do\n'
224..' _, Info[1], Info[3], Info[2], Info[4] = os.pullEvent("chat_capture")\n'
225..' if Info[3] == "seedy bois" or Info[3] == "bamzino" then\n'
226..' rednet.send(27,{Token,Info[4],Info[3]})\n'
227..' print("Sent")\n'
228..' end\n'
229..' ID, MSG = rednet.receive(10)\n'
230..' if MSG == "Yote" then\n'
231..' CH.tell("Hyeh")\n'
232..' end\n'
233..' sleep(1)\n'
234..' print(Info[3])\n'
235..'end\n'
236..' \n'
237)
238NF.close()
239end
240
241
242
243
244
245InstallDir = ...
246if InstallDir == nil then InstallDir = '/' end
247term.clear()
248term.setCursorPos(1,1)
249print('Do you wish to install pwr? (Y/N)')
250local x = read()
251
252if x == 'y' or x == 'Y' then
253local NF = fs.open(InstallDir..'/pwr','w')
254NF.write(''
255..'rednet.open("front")\n'
256..'local V = peripheral.wrap("back").canvas()\n'
257..'local T = {}\n'
258..'local CRF = 0\n'
259..'local MRF = 0\n'
260..'local RCRF = 0\n'
261..'local RMRF = 0\n'
262..'local ID = "NA"\n'
263..'V.clear()\n'
264..'local BOX = V.addRectangle(2+353,2+270,154,14,0x777777FF)\n'
265..'local BX2 = V.addRectangle(3+353,3+270,152,12,0x00ff0055)\n'
266..'local TXT = V.addText({5+353,5+270},"")\n'
267..'function hecc()\n'
268..' ID, T = rednet.receive(1)\n'
269..' CRF = T[1]\n'
270..' MRF = T[2]\n'
271..' RCRF = T[3]\n'
272..' RMRF = T[4]\n'
273..' BX2.setSize(152*(RCRF/RMRF),12)\n'
274..' PCT = (math.floor(RCRF/RMRF*10000)/100)\n'
275..' if math.floor(PCT*10)/10 == PCT and math.floor(PCT) ~= PCT then\n'
276..' PCT = PCT.."0"\n'
277..' elseif math.floor(PCT) == PCT then\n'
278..' PCT = PCT..".00"\n'
279..' end\n'
280..' TXT.setText(CRF.."/"..MRF.." "..PCT.."%")\n'
281..' TXT.setColor(0x77ff00ff)\n'
282..'end\n'
283..'while true do\n'
284..' pcall(hecc)\n'
285..'end\n'
286)
287NF.close()
288end
289
290
291
292
293
294InstallDir = ...
295if InstallDir == nil then InstallDir = '/' end
296term.clear()
297term.setCursorPos(1,1)
298print('Do you wish to install rom? (Y/N)')
299local x = read()
300
301if x == 'y' or x == 'Y' then
302local NF = fs.open(InstallDir..'/rom','w')
303NF.write(''