Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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(self)
- if shutterState then
- shutterState = false
- if colors.test(rs.getBundledOutput("bottom"), colors.brown) then
- rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") - colors.brown)
- rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") + colors.green)
- else
- rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") + colors.green)
- end
- else
- shutterState = true
- if colors.test(rs.getBundledOutput("bottom"), colors.green) then
- rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") - colors.green)
- rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") + colors.brown)
- else
- rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") + colors.brown)
- end
- end
- self.BGcolor = shutterState and colors.red or colors.lime
- self.Color = shutterState and colors.black or colors.white
- end,
- x1 = 5,
- x2 = 20,
- y1 = 2,
- y2 = 2},
- entrance = {
- light = {"\\====/"},
- color = entranceState and colors.black or colors.white,
- BGcolor = entranceState and colors.red or colors.lime,
- action = function(self)
- if entranceState then
- entranceState = false
- rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") - colors.purple)
- else
- entranceState = true
- rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") + colors.purple)
- end
- self.BGcolor = entranceState and colors.red or colors.lime
- self.Color = entranceState and colors.black or colors.white
- 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(self)
- if processingState then
- processingState = false
- rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") - colors.cyan)
- else
- processingState = true
- rs.setBundledOutput("bottom", rs.getBundledOutput("bottom") + colors.cyan)
- end
- self.BGcolor = processingState and colors.red or colors.lime
- self.Color = processingState and colors.black or colors.white
- 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(self)
- if alarmState then
- alarmState = false
- rs.setBundledOutput("bottom", rs.getBundledInput("bottom") - colors.red)
- else
- alarmState = true
- processingState = false
- entranceState = false
- shutterState = false
- rs.setBundledOutput("bottom", colors.red)
- end
- self.BGcolor = alarmState and colors.red or colors.lime
- self.Color = alarmState and colors.black or colors.white
- 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
- 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.BGcolor = v.BGcolor == colors.lime and colors.red or colors.lime
- v:action()
- drawGUI()
- end
- end
- end
- end
- term.setCursorPos(1, y)
Advertisement
Add Comment
Please, Sign In to add comment