Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monSide = "right"
- --button colours = red,lime,blue,gray,magenta
- --lime/red will toggle colour
- --blue/gray/magenta will NOT change colour.
- tButtons = {
- --name, xmin, xmax, ymin, ymax, ColourButton, colorBoundledCable, BoundledCable.active
- {"Control Room",1,12,3,4,"red",1,"active"},
- {"Machine Room",1,12,6,7,"red",2,"active"},
- {"Generator Rm",1,12,9,10,"red",4,"active"},
- -- Control room
- {"1",17,17,4,4,"red",8,"active"},
- {"2",19,19,4,4,"red",16,"active"},
- {"3",21,21,4,4,"red"},
- {"4",23,23,4,4,"red"},
- {"5",25,25,4,4,"red"},
- -- Machine room
- {"1",17,17,7,7,"red"},
- {"2",19,19,7,7,"red"},
- {"3",21,21,7,7,"red"},
- {"4",23,23,7,7,"red"},
- {"5",25,25,7,7,"red"},
- -- titles
- {"[Light Control Interface]",1,29,1,1,"blue"},
- {"Corridors",17,27,3,3,"blue"},
- {"Straircases",17,27,6,6,"blue"},
- {"Other",17,27,9,9,"gray"},
- }
- ---------------------
- colorWhite = 1
- colorOrange = 2
- colorMagenta = 4
- colorLightBlue = 8
- colorYellow = 16
- colorLime = 32
- colorPink = 64
- colorGray = 128
- colorLightGray = 256
- colorCayan = 512
- colorPurple = 2014
- colorBlue = 2048
- colorBrown = 4096
- colorGreen = 8192
- colorRed = 16384
- colorBlack = 32768
- local num = 0
- function userInput(Touch)
- if tButtons[Touch][8] == "active" then
- num = num + tButtons[Touch][7]
- tButtons[Touch][8] = "disable"
- elseif tButtons[Touch][8] == "disable" then
- tButtons[Touch][8] = "active"
- num = num - tButtons[Touch][7]
- if num < 0 then
- num = 0
- end
- elseif tButtons[Touch][7] == nil then
- tButtons[Touch][7] = 0
- end
- if rs.setBundledOutput("back",tButtons[Touch][7]) then
- rs.setBundledOutput("back",0)
- else
- rs.setBundledOutput("back",num)
- end
- end
- function drawButtons()
- mon.setBackgroundColour(colours.black)
- mon.clear()
- for i = 1,#tButtons do
- if tButtons[i][6] == "red" then
- mon.setBackgroundColor(colorRed)
- elseif tButtons[i][6] == "lime" then
- mon.setBackgroundColor(colorLime)
- elseif tButtons[i][6] == "blue" then
- mon.setBackgroundColor(colorBlue)
- elseif tButtons[i][6] == "gray" then
- mon.setBackgroundColor(colorLightGray)
- elseif tButtons[i][6] == "magenta" then
- mon.setBackgroundColor(colorMagenta)
- end
- for i2 = tButtons[i][4],tButtons[i][5] do
- for i3 = tButtons[i][2],tButtons[i][3] do
- mon.setCursorPos(i3,i2)
- mon.write(" ")
- end
- end
- mon.setCursorPos((tButtons[i][2] + tButtons[i][3]) /2 -(#tButtons[i][1]/2 -1 ), (tButtons[i][4] + tButtons[i][5])/2 )
- mon.write(tButtons[i][1])
- end
- end
- function miceClick()
- event, button, miceX, miceY = os.pullEvent("monitor_touch")
- for i4 = 1,#tButtons do
- if miceX >= tButtons[i4][2] and miceX <= tButtons[i4][3] and miceY >= tButtons[i4][4] and miceY <= tButtons[i4][5] then
- if tButtons[i4][6] == "lime" then
- tButtons[i4][6] = "red"
- elseif tButtons[i4][6] == "red" then
- tButtons[i4][6] = "lime"
- end
- Touch = i4
- userInput(Touch)
- end
- end
- end
- mon = peripheral.wrap(monSide)
- mon.setBackgroundColour(colours.black)
- mon.clear()
- while true do
- drawButtons()
- miceClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment