SideOfBundled = "back"
Rooms = {"top", "back", "mines", "dungeon"}
Operate = {"blue", "red", "yellow", "green"}
function testBundle(sSide, sColour)
local nColour = colors[sColour] or colours[sColour]
if type(nColour) ~= "number" then
return
end
if rs.testBundledInput(SideOfBundled, nColour) then
return true
else
return false
end
end
function bundle(sSide, sColour, sValue)
local nColour = colors[sColour] or colours[sColour]
if type(nColour) ~= "number" then
error( "No such color" )
return false
end
if sValue then
rs.setBundledOutput( SideOfBundled, colors.combine( rs.getBundledOutput( sSide ), nColour ) )
elseif not sValue then
rs.setBundledOutput( SideOfBundled , colors.subtract( rs.getBundledOutput( sSide ), nColour ) )
end
end
function writeFile()
WriteFile = io.open("Bundles", "w")
for n=1,#Operate do
if testBundle(SideOfBundled, Operate[n]) then
WriteFile:write(Operate[n].."n")
end
end
WriteFile:close()
end
function Clear()
term.setCursorPos(1,1)
term.clear()
end
function Welcome()
Clear()
print("Welcome to USER's Light Control system")
write("These lights are turned on:")
for n=1, #Operate do
if testBundle(SideOfBundled, Operate[n]) then
write(" "..Rooms[n]..",")
end
end
x, y = term.getCursorPos()
term.setCursorPos(x-1, y)
term.write(" ")
print()
write("Rooms:")
for p,n in pairs(Rooms) do
write(" "..n..",")
end
x, y = term.getCursorPos()
term.setCursorPos(x-1, y)
term.write(" ")
print()
write("Toggle: ")
local Temp = read()
for p=1, #Rooms do
if Temp == Rooms[p] then
bundle(SideOfBundled, Operate[p], not testBundle(SideOfBundled, Operate[p]))
end
end
writeFile()
end
--Load the previous bundled
if fs.exists("Bundles") then
TalkToMe = io.open("Bundles", "r")
for line in TalkToMe:lines() do
bundle(SideOfBundled, line, true)
end
TalkToMe:close()
end
while true do
sleep(0.1)
Welcome()
end
Happy now?!
xD
Add a room and color at the same places.
It has formatting problems!
Something you can improve
It can also probably be improved without the sleep()
But I was suffering problems with the display not updating correctly.
I think its due to delaying updates to RP cables so we don't get low fps :)/>/>