shell.run("clear");
-- Creates 3 arrays, s to store the constant of each color, o to store the toggles and sn to store the names of the toggles
s = {colors.white, colors.red, colors.lightBlue, colors.yellow, colors.blue, colors.black};
o = {"off", "off", "off", "off", "off", "off"};
sn = {"Service 1", "Service 2", "Service 3", "Service 4", "Service 5", "Service 6"};
-- some placeholders for later
cs = 1;
co = "off";
-- master color variable, the sum of all the color constants of services that are on will be stored here
master = 0;
while true do
shell.run("clear");
-- reset master
master = 0;
print("/// Fort Systems Controller ///\n");
-- for loop to check if a toggle is on and if it is then it adds the color value to the master variable
for i=1, 6 do
-- the status variable will store "on" or "off", i use it to convert "on" to "on " so the text doesnt move
status = o[i];
if(o[i] == "on") then
status = status.." ";
master = master + s[i];
end
-- this is what turns each cable on, based on the value of the master variable it decides which cables to turn on
rs.setBundledOutput("bottom", master);
-- this prints each of the services and their states
print(i.." - "..status.." - "..sn[i]);
end
-- here it asks for what service to toggle, if the number is not in the list it asks again
sValid = true;
while sValid do
write("\nSelect a service to toggle: ");
cs = read();
-- this took me some painful moments of troubleshooting, if you dont convert what you read() and then try to use it to point inside an array it will point to different data, example: not calling tonumber(cs) and then doing i[cs] would do i["3"] instead of i[3]
cs = tonumber(cs);
if((cs == 1) or (cs == 2) or (cs == 3) or (cs == 4) or (cs == 5) or (cs == 6)) then
sValid = false;
else
print("Invalid Service");
end
end
--here it toggles the service, if its on it turns it off and vice versa
co = o[cs];
if(co == "on") then
o[cs] = "off";
else
o[cs] = "on";
end
end
This is the wiring that go below the computer
[attachment=26:1.jpg]
Another Angle
[attachment=27:2.jpg]
This is how it looks covered
[attachment=28:3.jpg]