Advertisement
Guest User

1

a guest
Jun 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.64 KB | None | 0 0
  1. -- Monitorseite:
  2. local monSide = "back"
  3. -- bundledCable Seite:
  4. local bunSide = "front"
  5. -- Hintergrundfarbe:
  6. local bCol = colors.lightGray
  7. -- Textfarbe:
  8. local tCol = colors.white
  9.  
  10. m = peripheral.wrap(monSide)
  11.  
  12. local xMax,yMax = m.getSize()
  13.  
  14. local button = {}
  15. button[1]  = { 3, 3,13, 9,   "All ON", colors.black, colors.gray,                nil,false}
  16. button[2]  = { 3,11,13,17,  "All OFF", colors.black, colors.gray,                nil,false}
  17. button[3]  = {17, 3,27, 5,    "white",   colors.red, colors.lime,       colors.white,false}
  18. button[4]  = {31, 3,41, 5,   "orange",   colors.red, colors.lime,      colors.orange,false}
  19. button[5]  = {45, 3,55, 5,  "magenta",   colors.red, colors.lime,     colors.magenta,false}
  20. button[6]  = {59, 3,69, 5,"lightBlue",   colors.red, colors.lime,   colors.lightBlue,false}
  21. button[7]  = {17, 7,27, 9,   "yellow",   colors.red, colors.lime,      colors.yellow,false}
  22. button[8]  = {31, 7,41, 9,     "lime",   colors.red, colors.lime,        colors.lime,false}
  23. button[9]  = {45, 7,55, 9,     "pink",   colors.red, colors.lime,        colors.pink,false}
  24. button[10] = {59, 7,69, 9,     "gray",   colors.red, colors.lime,        colors.gray,false}
  25. button[11] = {17,11,27,13,"lightGray",   colors.red, colors.lime,   colors.lightGray,false}
  26. button[12] = {31,11,41,13,     "cyan",   colors.red, colors.lime,        colors.cyan,false}
  27. button[13] = {45,11,55,13,   "purple",   colors.red, colors.lime,      colors.purple,false}
  28. button[14] = {59,11,69,13,     "blue",   colors.red, colors.lime,        colors.blue,false}
  29. button[15] = {17,15,27,17,    "brown",   colors.red, colors.lime,       colors.brown,false}
  30. button[16] = {31,15,41,17,    "green",   colors.red, colors.lime,       colors.green,false}
  31. button[17] = {45,15,55,17,      "red",   colors.red, colors.lime,         colors.red,false}
  32. button[18] = {59,15,69,17,    "black",   colors.red, colors.lime,       colors.black,false}
  33.  
  34. function bg(col)
  35.   m.setBackgroundColor(col)
  36.   for xP = 1,xMax do
  37.     for yP = 1,yMax do
  38.       m.setCursorPos(xP,yP)
  39.       m.write(" ")
  40.     end
  41.   end
  42. end
  43.  
  44. function JoJa()
  45.   m.setBackgroundColor(colors.gray)
  46.   for xP = 1,xMax do
  47.     m.setCursorPos(xP,1)
  48.     m.write(" ")
  49.   end
  50.   m.setCursorPos(xMax/2-7,1)
  51.   m.setTextColor(colors.cyan)
  52.   m.write("Jo")
  53.   m.setTextColor(colors.orange)
  54.   m.write("Ja ")
  55.   m.setTextColor(colors.lightGray)
  56.   m.write("Productions")
  57. end
  58.  
  59. function drawButton(arr)
  60.   for i = 1,#arr do
  61.     if arr[i][9] then
  62.       m.setBackgroundColor(arr[i][7])
  63.     else
  64.       m.setBackgroundColor(arr[i][6])
  65.     end
  66.     for xP = arr[i][1],arr[i][3] do
  67.       for yP = arr[i][2],arr[i][4] do
  68.         m.setCursorPos(xP,yP)
  69.         m.write(" ")
  70.       end
  71.     end
  72.     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)
  73.     m.write(arr[i][5])
  74.   end
  75. end
  76.  
  77. function checkButton(arr,xP,yP)
  78.   for i = 1,#arr do
  79.     if  xP >= arr[i][1] and xP <= arr[i][3]
  80.     and yP >= arr[i][2] and yP <= arr[i][4] then
  81.       if arr[i][9] then arr[i][9] = false else arr[i][9] = true end
  82.     end  
  83.   end
  84. end
  85.  
  86. bg(bCol)
  87. JoJa()
  88. m.setTextColor(tCol)
  89. while true do
  90.   drawButton(button)
  91.   local event,_,xP,yP = os.pullEvent("monitor_touch")
  92.   checkButton(button,xP,yP)
  93.   drawButton(button)
  94.   if button[1][9] then
  95.     button[1][9] = false
  96.     for i = 3,#button do
  97.       button[i][9] = true
  98.     end
  99.   elseif button[2][9] then
  100.     button[2][9] = false
  101.     for i = 3,#button do
  102.       button[i][9] = false
  103.     end
  104.   end
  105.   local out = 0
  106.   for i = 1,#button do
  107.     if button[i][9] then
  108.       out = out+button[i][8]
  109.     end
  110.   end
  111.   rs.setBundledOutput(bunSide,out)
  112.   sleep(.1)
  113. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement