-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallRules.lua
More file actions
100 lines (95 loc) · 2.71 KB
/
installRules.lua
File metadata and controls
100 lines (95 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
repositoryURL = "https://raw.github.com/Jabulba/SpawnCC/master/"
os.pullEvent = os.pullEventRaw;
function downloadFile(url, file)
fileData = http.get(url);
newFile = fs.open(file, "w");
newFile.write( fileData.readAll() );
newFile.close();
fileData.close();
end
function purgeSystem()
print("Purging the system, please wait...");
programs = shell.programs();
for i = 1,#programs do
write("Purging " .. programs[i] .. "... ");
if fs.exists(programs[i]) then
write(" Erasing...");
fs.delete(programs[i]);
write(" Complete. ");
end
end
programs = nil;
print("Restricting access to shell, please wait...");
programs = shell.programs();
for i = 1,#programs do
write("Parsing " .. programs[i] .. "... ");
write("Restricting access.");
tempFile = fs.open(programs[i], "w");
write(".");
tempFile.write('print("Kono puroguramu wa, shisutemu kara paji sa reta.")');
write(".");
tempFile.close();
print(" Complete.");
tempFile = nil;
end
end
purgeSystem();
print("Downloading latest parser version...");
downloadFile(repositoryURL .. "colourTextParser.lua", "colourTextParser.lua");
print("parser installed.");
print("Downloading latest rules files...")
local i = 0;
local rulesFileList = http.get(repositoryURL .. "rulesFiles.List");
while true do
local file = rulesFileList.readLine();
if file == nil then break end
downloadFile(repositoryURL .. "" .. file, file);
i = i + 1;
end
print(i .. " files downloaded.");
print("")
print("Avalible files:");
local fileList = fs.list("");
for num, file in ipairs(fileList) do
if string.find(file, ".ctxt") then
print(num .. ". " .. file);
end
end
print("");
local sides = { "right", "left", "top", "bottom", "front", "back" };
local peripheralType;
local numDetected = 0;
print("Detecting monitors... ");
configFile = fs.open("colourTextParser.config", "w");
for _,aux in pairs(sides) do
peripheralType = peripheral.getType(aux);
if peripheralType == "monitor" then
if peripheral.call(aux, "isColour") then
numDetected = numDetected + 1;
write(aux .. " monitor file: ");
while true do
local input = tonumber( (read() or nil) );
if input and string.find(fileList[input], ".ctxt") then
configFile.writeLine( fileList[input] );
break;
else
print("Wrong file number!");
end
end
end
end
end
configFile.close();
if numDetected == 0 then error("No colour monitor detected.", 0) end
print("Writing startup files.");
local startupFile = fs.open("startup", "w");
startupFile.write( 'shell.run("colourTextParser.lua")' );
startupFile.close();
write(".");
local startupFile = fs.open("autorun", "w");
startupFile.write( 'shell.run("colourTextParser.lua")' );
startupFile.close();
write(".");
print("Done.");
print("Rebooting");
os.reboot();