Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --(C) by JoJa Productions
- --Monitor 7 breit und 3 hoch
- -- Monitorseite:
- local monSide = "back"
- -- bundledCable Seite:
- local bunSide = "back"
- -- Hintergrundfarbe:
- local bCol = colors.lightGray
- -- Textfarbe:
- local tCol = colors.white
- --Programmbeschreibung
- local prgrm_description = "Schalttafel"
- m = peripheral.wrap(monSide)
- local xMax,yMax = m.getSize()
- local button = {}
- --Knopf xP1 yP1 xP2 yP2 Name Farbe(AUS) Farbe(AN) Ausgang Standardwert(false = Aus, true = an)
- button[1] = { 3, 3,13, 9, "All ON", colors.black, colors.gray, nil,false}
- button[2] = { 3,11,13,17, "All OFF", colors.black, colors.gray, nil,false}
- button[3] = {17, 3,27, 5, "white", colors.red, colors.lime, colors.white,false}
- button[4] = {31, 3,41, 5, "orange", colors.red, colors.lime, colors.orange,false}
- button[5] = {45, 3,55, 5, "magenta", colors.red, colors.lime, colors.magenta,false}
- button[6] = {59, 3,69, 5,"lightBlue", colors.red, colors.lime, colors.lightBlue,false}
- button[7] = {17, 7,27, 9, "yellow", colors.red, colors.lime, colors.yellow,false}
- button[8] = {31, 7,41, 9, "lime", colors.red, colors.lime, colors.lime,false}
- button[9] = {45, 7,55, 9, "pink", colors.red, colors.lime, colors.pink,false}
- button[10] = {59, 7,69, 9, "gray", colors.red, colors.lime, colors.gray,false}
- button[11] = {17,11,27,13,"lightGray", colors.red, colors.lime, colors.lightGray,false}
- button[12] = {31,11,41,13, "cyan", colors.red, colors.lime, colors.cyan,false}
- button[13] = {45,11,55,13, "purple", colors.red, colors.lime, colors.purple,false}
- button[14] = {59,11,69,13, "blue", colors.red, colors.lime, colors.blue,false}
- button[15] = {17,15,27,17, "brown", colors.red, colors.lime, colors.brown,false}
- button[16] = {31,15,41,17, "green", colors.red, colors.lime, colors.green,false}
- button[17] = {45,15,55,17, "red", colors.red, colors.lime, colors.red,false}
- button[18] = {59,15,69,17, "black", colors.red, colors.lime, colors.black,false}
- function writeCentered(txt, yP)
- m.setCursorPos(xMax/2-#txt/2,yP)
- m.write(txt)
- end
- function bg(col)
- m.setBackgroundColor(col)
- for xP = 1,xMax do
- for yP = 1,yMax do
- m.setCursorPos(xP,yP)
- m.write(" ")
- end
- end
- end
- function JoJa()
- m.setBackgroundColor(colors.gray)
- for xP = 1,xMax do
- m.setCursorPos(xP,1)
- m.write(" ")
- end
- m.setCursorPos(1,1)
- m.setTextColor(colors.cyan)
- m.write("Jo")
- m.setTextColor(colors.orange)
- m.write("Ja ")
- m.setTextColor(colors.lightGray)
- m.write("Productions")
- end
- function drawButton(arr)
- for i = 1,#arr do
- if arr[i][9] then
- m.setBackgroundColor(arr[i][7])
- else
- m.setBackgroundColor(arr[i][6])
- end
- for xP = arr[i][1],arr[i][3] do
- for yP = arr[i][2],arr[i][4] do
- m.setCursorPos(xP,yP)
- m.write(" ")
- end
- end
- m.setCursorPos(1+arr[i][1]+(arr[i][3]-arr[i][1])/2-#arr[i][5]/2,arr[i][2]+(arr[i][4]-arr[i][2])/2)
- m.write(arr[i][5])
- end
- end
- function checkButton(arr,xP,yP)
- for i = 1,#arr do
- if xP >= arr[i][1] and xP <= arr[i][3]
- and yP >= arr[i][2] and yP <= arr[i][4] then
- if arr[i][9] then arr[i][9] = false else arr[i][9] = true end
- end
- end
- end
- bg(bCol)
- JoJa()
- m.setTextColor(tCol)
- if prgrm_description == nil then
- prgrm_description = ""
- end
- writeCentered(prgrm_description,1)
- while true do
- drawButton(button)
- local out = 0
- for i = 1,#button do
- if button[i][9] then
- out = out+button[i][8]
- end
- end
- rs.setBundledOutput(bunSide,out)
- sleep(.1)
- local event,_,xP,yP = os.pullEvent("monitor_touch")
- checkButton(button,xP,yP)
- drawButton(button)
- if button[1][9] then
- button[1][9] = false
- for i = 3,#button do
- button[i][9] = true
- end
- elseif button[2][9] then
- button[2][9] = false
- for i = 3,#button do
- button[i][9] = false
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement