can someone tell my why it's broken?
local shutterState = false
local entranceState = false
local processingState = false
local alarmState = false
local x,y = term.getSize()
local statusLights = {
shutter = {
light = {"[--------------]"},
color = shutterState and colors.black or colors.white,
BGcolor = shutterState and colors.red or colors.lime,
action = function()
if shutterState then
shutterState = false
rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") - colors.white)
else
shutterState = true
rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") + colors.white)
end
end,
x1 = 5,
x2 = 20,
y1 = 2,
y2 = 2},
entrance = {
light = {"[url="file://\\====/"]\\====/[/url]"},
color = entranceState and colors.black or colors.white,
BGcolor = entranceState and colors.red or colors.lime,
action = function()
if entranceState then
entranceState = false
rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") - colors.white)
else
entranceState = true
rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") + colors.white)
end
end,
x1 = 10,
x2 = 15,
y1 = 3,
y2 = 3},
processing = {
light = {"|====|"},
color = processingState and colors.black or colors.white,
BGcolor = processingState and colors.red or colors.lime,
action = function()
if processingState then
processingState = false
rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") - colors.white)
else
processingState = true
rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") + colors.white)
end
end,
x1 = 10,
x2 = 15,
y1 = 18,
y2 = 18},
alarm = {
light = {"+--------+",
"| |",
"| ALARM! |",
"| |",
"+--------+"},
color = alarmState and colors.black or colors.white,
BGcolor = alarmState and colors.red or colors.lime,
action = function()
if rs.getBundledInput("bottom", colors.red) then
alarmState = false
rs.setBundledOutput("bottom", rs.getBundledInput("bottom") - colors.red)
else
alarmState = true
rs.setBundledOutput("bottom", rs.getBundledInput("bottom") + colors.red)
end
end,
x1 = 35,
x2 = 43,
y1 = 14,
y2 = 18}
}
local function drawBG()
term.clear()
for i = 1, 19 do
paintutils.drawLine(1, i, 24, i, colors.white)
paintutils.drawLine(28, i, 51, i, colors.white)
term.setBackgroundColor(colors.red)
term.setCursorPos(25, i)
write("[")
term.setBackgroundColor(colors.blue)
term.setCursorPos(26, i)
write("X")
term.setBackgroundColor(colors.red)
term.setCursorPos(27, i)
write("]")
end
for i = 2, 18 do
paintutils.drawLine(2, i, 23, i, colors.lightGray)
term.setBackgroundColor(colors.gray)
term.setCursorPos(23, i)
write("|")
term.setCursorPos(2, i)
write(i == 2 and ".--------------------." or
i == 18 and "'--------------------'" or
"|")
end
end
local function drawGUI()
for _,v in pairs(statusLights) do
for i = 1, #v.light do
term.setBackgroundColor(v.BGcolor)
term.setTextColor(v.color)
term.setCursorPos(v.x1, v.y1 + (i - 1))
write(v.light[i])
end
end
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
term.setCursorPos(29, 3)
write("Shutter: ")
term.setTextColor(shutterState and colors.red or colors.lime)
write(shutterState and "OPEN " or "CLOSED")
term.setTextColor(colors.black)
term.setCursorPos(29, 4)
write("Entrance: ")
term.setTextColor(entranceState and colors.red or colors.lime)
write(entranceState and "OPEN " or "CLOSED")
term.setTextColor(colors.black)
term.setCursorPos(29, 5)
write("Processing: ")
term.setTextColor(processingState and colors.red or colors.lime)
write(processingState and "OPEN " or "CLOSED")
end
if rs.getBundledInput("bottom", colors.red) then
alarmState = true
end
drawBG()
drawGUI()
while true do
local events = {os.pullEvent()}
if events[1] == "mouse_click" and events[2] == 1 then
for _,v in pairs(statusLights) do
if events[3] >= v.x1 and events[3] <= v.x2 and events[4] >= v.y1 and events[4] <= v.y2 then
v.action()
drawGUI()
end
end
elseif events[1] == "redstone" then
if rs.getBundledInput("bottom", colors.red) then
alarmState = true
end
end
end












