Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local blocksState = {
- [1] = false,
- [2] = false,
- [3] = false,
- [4] = false,
- [5] = false
- }
- local doorState = {
- [1] = false,
- [2] = false
- }
- local yardState = {
- [1] = false,
- [2] = false
- }
- local alarmState = false
- local alarm = {
- [1] = {color = colors.red,
- x1 = 36,
- x2 = 50,
- y1 = 16,
- y2 = 18}
- }
- local yard = {
- [1] = {color = colors.lightGray,
- x1 = 2,
- x2 = 16,
- y1 = 2,
- y2 = 9},
- [2] = {color = colors.gray,
- x1 = 18,
- x2 = 32,
- y1 = 2,
- y2 = 9}
- }
- local blocks = {
- [1] = {color = colors.white,
- x1 = 11,
- x2 = 13,
- y1 = 11,
- y2 = 14},
- [2] = {color = colors.orange,
- x1 = 15,
- x2 = 17,
- y1 = 11,
- y2 = 14},
- [3] = {color = colors.magenta,
- x1 = 19,
- x2 = 21,
- y1 = 11,
- y2 = 14},
- [4] = {color = colors.lightBlue,
- x1 = 23,
- x2 = 25,
- y1 = 11,
- y2 = 14},
- [5] = {color = colors.yellow,
- x1 = 27,
- x2 = 29,
- y1 = 11,
- y2 = 14}
- }
- local doors = {
- [1] = {color = colors.lime,
- x1 = 1,
- x2 = 10,
- y1 = 15,
- y2 = 17},
- [2] = {color = colors.pink,
- x1 = 30,
- x2 = 33,
- y1 = 15,
- y2 = 17}
- }
- local function openBlock(cell)
- rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom") + cell))
- end
- local function closeBlock(cell)
- rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom") - cell))
- end
- local function GUI()
- for i = 1, #blocks do
- term.setBackgroundColor(blocksState[i] and colors.red or colors.lime)
- term.setTextColor(blocksState[i] and colors.black or colors.white)
- term.setCursorPos(blocks[i].x1, blocks[i].y1)
- write("+-+")
- term.setCursorPos(blocks[i].x1, blocks[i].y1+1)
- write("|"..i.."|")
- term.setCursorPos(blocks[i].x1, blocks[i].y1+2)
- write("| |")
- term.setCursorPos(blocks[i].x1, blocks[i].y2)
- write("+-+")
- term.setCursorPos(36, i + 1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- write("Block "..i..": ")
- if blocksState[i] then
- term.setTextColor(colors.red)
- write("Open ")
- elseif not blocksState[i] then
- term.setTextColor(colors.lime)
- write("Closed")
- end
- end
- for i = 1, #doors do
- term.setBackgroundColor(doorState[i] and colors.red or colors.lime)
- term.setTextColor(doorState[i] and colors.black or colors.white)
- term.setCursorPos(doors[i].x1, doors[i].y1)
- write(i == 1 and "+--------+" or "+--+")
- term.setCursorPos(doors[i].x1, doors[i].y1+1)
- write(i == 1 and "Processing" or "Yard")
- term.setCursorPos(doors[i].x1, doors[i].y2)
- write(i == 1 and "+--------+" or "+--+")
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(36,8)
- write("Processing: ")
- if doorState[1] then
- term.setTextColor(colors.red)
- term.setCursorPos(38, 9)
- write("Open ")
- elseif not doorState[1] then
- term.setTextColor(colors.lime)
- term.setCursorPos(38, 9)
- write("Closed")
- end
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(36,10)
- write("Yard gate: ")
- if doorState[2] then
- term.setTextColor(colors.red)
- term.setCursorPos(38, 11)
- write("Open ")
- elseif not doorState[2] then
- term.setTextColor(colors.lime)
- term.setCursorPos(38, 11)
- write("Closed")
- end
- end
- for i = 1, #yard do
- term.setBackgroundColor(yardState[i] and colors.red or colors.lime)
- term.setTextColor(yardState[i] and colors.black or colors.white)
- term.setCursorPos( i == 1 and 4 or 20, 4)
- write("+---------+")
- term.setCursorPos( i == 1 and 4 or 20, 5)
- write("| Yard ")
- write(i == 1 and "A" or "B")
- write(" |")
- term.setCursorPos( i == 1 and 4 or 20, 6)
- write("| |")
- term.setCursorPos( i == 1 and 4 or 20, 7)
- write("+---------+")
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(36, 12 + i)
- write("Yard ")
- write(i == 1 and "A: " or "B: ")
- term.setTextColor(yardState[i] and colors.red or colors.lime)
- write(yardState[i] and "Open " or "Closed")
- end
- term.setBackgroundColor(alarmState and colors.red or colors.lime)
- term.setTextColor(alarmState and colors.black or colors.white)
- term.setCursorPos(39, 16)
- write("+-------+")
- term.setCursorPos(39, 17)
- write("| Alarm |")
- term.setCursorPos(39, 18)
- write("+-------+")
- end
- term.clear()
- for i = 1, 19 do
- paintutils.drawLine(1, i, 51, i, colors.lightGray)
- end
- for i = 11, 19 do
- paintutils.drawLine(10, i, 30, i, colors.black)
- end
- for i = 2, 9 do
- paintutils.drawLine(2, i, 16, i, colors.black)
- paintutils.drawLine(18, i, 32, i, colors.black)
- end
- for i = 3, 8 do
- paintutils.drawLine(3, i, 15, i, colors.gray)
- paintutils.drawLine(19, i, 31, i, colors.gray)
- end
- for i = 1, 19 do
- paintutils.drawLine(35, i, 51, i, colors.white)
- end
- for i = 15, 19 do
- paintutils.drawLine(11, i, 29, i, colors.gray)
- end
- GUI()
- rs.setBundledOutput("bottom", 0)
- while true do
- local events = {os.pullEvent()}
- if events[1] == "mouse_click" and events[2] == 1 then
- for i = 1, #blocks do
- if events[3] >= blocks[i].x1 and events[3] <= blocks[i].x2 then
- if events[4] >= blocks[i].y1 and events[4] <= blocks[i].y2 then
- if blocksState[i] == true then
- blocksState[i] = false
- closeBlock(blocks[i].color)
- GUI()
- break
- elseif blocksState[i] == false then
- blocksState[i] = true
- openBlock(blocks[i].color)
- GUI()
- break
- end
- end
- end
- end
- for i = 1, #doors do
- if events[3] >= doors[i].x1 and events[3] <= doors[i].x2 then
- if events[4] >= doors[i].y1 and events[4] <= doors[i].y2 then
- if doorState[i] == true then
- doorState[i] = false
- closeBlock(doors[i].color)
- GUI()
- break
- elseif doorState[i] == false then
- doorState[i] = true
- openBlock(doors[i].color)
- GUI()
- break
- end
- end
- end
- end
- for i = 1, #yard do
- if events[3] >= yard[i].x1 and events[3] <= yard[i].x2 then
- if events[4] >= yard[i].y1 and events[4] <= yard[i].y2 then
- if yardState[i] == true then
- yardState[i] = false
- closeBlock(yard[i].color)
- GUI()
- break
- elseif yardState[i] == false then
- yardState[i] = true
- openBlock(yard[i].color)
- GUI()
- break
- end
- end
- end
- end
- if events[3] >= alarm[1].x1 and events[3] <= alarm[1].x2 then
- if events[4] >= alarm[1].y1 and events[4] <= alarm[1].y2 then
- if alarmState == true then
- alarmState = false
- rs.setBundledOutput("bottom", 0)
- GUI()
- elseif alarmState == false then
- alarmState = true
- for i = 1, #blocksState do
- blocksState[i] = false
- end
- for i = 1, #yardState do
- yardState[i] = false
- end
- for i = 1, #doorState do
- doorState[i] = false
- end
- rs.setBundledOutput("bottom", colors.red)
- GUI()
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment