jamawie

Nike - Haussteuerung

May 6th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.97 KB | None | 0 0
  1. local monitorside = "back"
  2. mon = peripheral.wrap(monitorside)
  3. local x,y = mon.getSize()
  4.  
  5. function Background()
  6.   for i=1,y do
  7.     mon.setCursorPos(1,i)
  8.     mon.setBackgroundColor(colors.white)
  9.     for j=1,x do
  10.       mon.write(" ")
  11.     end
  12.   end
  13. end
  14.  
  15. function bdraw(xp1,yp1,xp2,yp2,txt,col)
  16.  if col==nil then
  17.  mon.setBackgroundColor(colors.lime)
  18.  else
  19.  mon.setBackgroundColor(col)
  20.  end
  21.  mon.setCursorPos(xp1,yp1)
  22.  for i=1,(xp2-xp1) do
  23.   mon.write("-")
  24.  end
  25.  mon.setCursorPos(xp1,yp2)
  26.  for i=1,(xp2-xp1) do
  27.   mon.write("-")
  28.  end
  29.  for i=yp1,yp2 do
  30.   mon.setCursorPos(xp1,i)
  31.   mon.write("|")
  32.   mon.setCursorPos(xp2,i)
  33.   mon.write("|")
  34.  end
  35.  for i=(yp1+1),(yp2-1) do
  36.   mon.setCursorPos((xp1+1),i)
  37.   for j=(xp1+1),(xp2-1) do
  38.    mon.write(" ")
  39.    j = j+1
  40.   end
  41.   i = i+1
  42.  end
  43.  if math.floor(((xp2-xp1)-#txt)/2)==0 then
  44.   xp1 = xp1+1
  45.  end
  46.  mon.setCursorPos(math.floor(((xp2-xp1)-#txt)/2)+xp1,math.floor((yp2-yp1)/2)+yp1)
  47.  print(math.floor(((xp2-xp1)-#txt)/2))
  48.  mon.write(txt)
  49. end
  50.  
  51. Background()
  52. mon.setTextColor(colors.black)
  53. mon.setCursorPos(13,1)
  54. mon.write("Haussteuerung")
  55. mon.setTextColor(colors.blue)
  56. mon.setCursorPos(1,3)    
  57. mon.write("Automatische Erzschmelze: ")
  58. mon.setCursorPos(1,4)
  59. mon.write("Mass Fabricator: ")
  60. mon.setCursorPos(1,5)
  61. mon.write("Crystallizer: ")
  62. mon.setCursorPos(1,6)
  63. mon.setTextColor(colors.black)
  64. mon.write("---------------------------------------")
  65. mon.setCursorPos(1,8)
  66. mon.setTextColor(colors.cyan)
  67. mon.write("Haustuer: ")
  68. mon.setCursorPos(1,9)
  69. mon.setTextColor(colors.black)
  70. mon.write("---------------------------------------")
  71. mon.setCursorPos(1,11)
  72. mon.setTextColor(colors.lightBlue)
  73. mon.write("ME-Home System: ")
  74. mon.setCursorPos(1,12)
  75. mon.setTextColor(colors.orange)
  76. mon.write("Me-Home Notstrom: ")
  77.  
  78. while true do
  79. if rs.testBundledInput("front", colors.green) then
  80. mon.setCursorPos(26,3)
  81. mon.setTextColor(colors.lime)
  82. mon.write("(AN) ")
  83. else
  84. mon.setCursorPos(26,3)
  85. mon.setTextColor(colors.red)
  86. mon.write("(AUS)")
  87. end
  88. if rs.testBundledInput("front", colors.red) then
  89. mon.setCursorPos(26,4)
  90. mon.setTextColor(colors.lime)
  91. mon.write("(AN) ")
  92. else
  93. mon.setCursorPos(26,4)
  94. mon.setTextColor(colors.red)
  95. mon.write("(AUS)")
  96. end
  97. if rs.testBundledInput("front", colors.blue) then
  98. mon.setCursorPos(31,4)
  99. mon.setTextColor(colors.orange)
  100. mon.write("(Tag)  ")
  101. else
  102. mon.setCursorPos(31,4)
  103. mon.setTextColor(colors.black)
  104. mon.write("(Nacht)")
  105. end
  106. if rs.testBundledInput("front", colors.brown) then
  107. mon.setCursorPos(26,5)
  108. mon.setTextColor(colors.lime)
  109. mon.write("(AN) ")
  110. else
  111. mon.setCursorPos(26,5)
  112. mon.setTextColor(colors.red)
  113. mon.write("(AUS)")
  114. end
  115. if rs.testBundledInput("front", colors.purple) then
  116. mon.setCursorPos(26,8)
  117. mon.setTextColor(colors.lime)
  118. mon.write("(AUF)")
  119. else
  120. mon.setCursorPos(26,8)
  121. mon.setTextColor(colors.red)
  122. mon.write("(ZU) ")
  123. end
  124. if rs.testBundledInput("front",colors.yellow) then
  125. mon.setCursorPos(31,8)
  126. mon.setTextColor(colors.orange)
  127. mon.write("(Klingel)")
  128. sleep(0.5)
  129. mon.setCursorPos(31,8)
  130. mon.write("         ")
  131. sleep(0.5)
  132. mon.setCursorPos(31,8)
  133. mon.write("(Klingel)")
  134. mon.setCursorPos(31,8)
  135. sleep(0.5)
  136. mon.write("         ")
  137. mon.setCursorPos(31,8)
  138. sleep(0.5)
  139. mon.write("(Klingel)")
  140. sleep(0.5)
  141. mon.setCursorPos(31,8)
  142. mon.write("         ")
  143. end
  144. mon.setCursorPos(1,9)
  145. mon.setTextColor(colors.black)
  146. mon.write("---------------------------------------")
  147. if rs.testBundledInput("front",colors.cyan) then
  148. mon.setCursorPos(26,11)
  149. mon.setTextColor(colors.red)
  150. mon.write("(AUS)")
  151. else
  152. mon.setCursorPos(26,11)
  153. mon.setTextColor(colours.lime)
  154. mon.write("(AN) ")
  155. end
  156. if rs.testBundledInput("front",colors.orange) then
  157. mon.setCursorPos(26,12)
  158. mon.setTextColor(colors.red)
  159. mon.write("(AUS)")
  160. else
  161. mon.setCursorPos(26,12)
  162. mon.setTextColor(colors.lime)
  163. mon.write("(AN) ")
  164. end
  165.  
  166. bdraw(x-8,y-2,x,y,"zurueck",colors.red)
  167. event,_,xPos,yPos = os.pullEvent()
  168.  
  169. if event=="monitor_touch" then
  170.     if xPos>=x-8 and xPos<=x and yPos>=y-2 and yPos<=y then
  171.         os.reboot()
  172.     end
  173. end
  174. end
Add Comment
Please, Sign In to add comment