Advertisement
Birog

Ein/Aus Schalter

Jul 5th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[   ### Hier bitte nix mehr machen außer du weißt was du machst! ###
  2. function clear()
  3.         term.clear()
  4.         term.setCursorPos(1,1)
  5. end
  6. print( "Copyright by Birog" )
  7. write( "Es wird nach Updates gesucht... " )
  8. local response = http.get("http://pastebin.com/raw.php?i=EhTQMcyC")    
  9. if response then
  10.    print("Update-suche erfolgreich!")
  11.    local sSource = response.readAll()
  12.    response.close()
  13.    local file = fs.open( "startup", "r" )
  14.    local sTarget = ""    
  15.    if file then
  16.           sTarget = file.readAll()
  17.           file.close()
  18.    end  
  19.    if sSource ~= sTarget then
  20.           term.write("Updates gefunden!")
  21.           file = fs.open( "startup", "w" )
  22.           file.write( sSource )
  23.           file.close()
  24.           print( "Wurde herruntergeladen als - startup - -Datei")
  25.           print("Programm wird Neugestartet!")
  26.           shell.run("startup")
  27.           return  
  28.    else
  29.           print("Es sind keine Updates vorhanden!")
  30.           print("Programm wird gestartet!")
  31.           sleep(3)
  32.           clear()
  33.    end
  34. else
  35.    clear()
  36.    print("ERROR! Informiere bitte Birog!!")
  37.    clear()
  38. end]]
  39. -------------------------------------------------------------------------------------------------------------------
  40. moniside = "right"
  41. --
  42. redout = "left"
  43. --
  44. Info = "Schild"
  45. --
  46. adminpass = "5555"
  47.  
  48. term = peripheral.wrap(moniside)
  49. local pullEvent = os.pullEvent
  50. os.pullEvent = os.pullEventRaw
  51.  
  52. function AnzeigeAus()
  53.     term.setCursorPos(2,1)
  54.     term.setBackgroundColor(colors.red)
  55.     term.write(" ")
  56.     term.setBackgroundColor(colors.black)
  57.     term.setCursorPos(3,1)
  58.     term.setBackgroundColor(colors.red)
  59.     term.write("O")
  60.     term.setBackgroundColor(colors.black)
  61.     term.setCursorPos(4,1)
  62.     term.setBackgroundColor(colors.red)
  63.     term.write("F")
  64.     term.setBackgroundColor(colors.black)
  65.     term.setCursorPos(5,1)
  66.     term.setBackgroundColor(colors.red)
  67.     term.write("F")
  68.     term.setBackgroundColor(colors.black)
  69.     term.setCursorPos(6,1)
  70.     term.setBackgroundColor(colors.red)
  71.     term.write(" ")
  72.     term.setBackgroundColor(colors.black)
  73. end
  74.  
  75. function AnzeigeEin()
  76.     term.setCursorPos(2,1)
  77.     term.setBackgroundColor(colors.green)
  78.     term.write(" ")
  79.     term.setBackgroundColor(colors.black)
  80.     term.setCursorPos(3,1)
  81.     term.setBackgroundColor(colors.green)
  82.     term.write("O")
  83.     term.setBackgroundColor(colors.black)
  84.     term.setCursorPos(4,1)
  85.     term.setBackgroundColor(colors.green)
  86.     term.write("N")
  87.     term.setBackgroundColor(colors.black)
  88.     term.setCursorPos(5,1)
  89.     term.setBackgroundColor(colors.green)
  90.     term.write(" ")
  91.     term.setBackgroundColor(colors.black)
  92.     term.setCursorPos(6,1)
  93.     term.setBackgroundColor(colors.green)
  94.     term.write(" ")
  95.     term.setBackgroundColor(colors.black)
  96. end
  97.  
  98. function Rahmen()
  99. term.clear()
  100. term.setTextColor(colors.white)
  101. -- Information
  102. term.setCursorPos(2,2)
  103. term.setBackgroundColor(colors.blue)
  104. term.write("Hello")
  105. term.setBackgroundColor(colors.black)
  106. -- Anzeige
  107. term.setCursorPos(2,1)
  108. term.setBackgroundColor(colors.orange)
  109. term.write(" ")
  110. term.setBackgroundColor(colors.black)
  111. term.setCursorPos(3,1)
  112. term.setBackgroundColor(colors.orange)
  113. term.write(" ")
  114. term.setBackgroundColor(colors.black)
  115. term.setCursorPos(4,1)
  116. term.setBackgroundColor(colors.orange)
  117. term.write(" ")
  118. term.setBackgroundColor(colors.black)
  119. term.setCursorPos(5,1)
  120. term.setBackgroundColor(colors.orange)
  121. term.write(" ")
  122. term.setBackgroundColor(colors.black)
  123. term.setCursorPos(6,1)
  124. term.setBackgroundColor(colors.orange)
  125. term.write(" ")
  126. term.setBackgroundColor(colors.black)
  127.  
  128. -- Einschalten
  129. term.setCursorPos(2,3)
  130. term.setBackgroundColor(colors.green)
  131. term.write(" ")
  132. term.setBackgroundColor(colors.black)
  133. term.setCursorPos(2,4)
  134. term.setBackgroundColor(colors.green)
  135. term.write(" ")
  136. term.setBackgroundColor(colors.black)
  137. term.setCursorPos(2,5)
  138. term.setBackgroundColor(colors.green)
  139. term.write(" ")
  140. term.setBackgroundColor(colors.black)
  141. term.setCursorPos(3,3)
  142. term.setBackgroundColor(colors.green)
  143. term.write(" ")
  144. term.setBackgroundColor(colors.black)
  145. term.setCursorPos(3,4)
  146. term.setBackgroundColor(colors.green)
  147. term.write(" ")
  148. term.setBackgroundColor(colors.black)
  149. term.setCursorPos(3,5)
  150. term.setBackgroundColor(colors.green)
  151. term.write(" ")
  152. term.setBackgroundColor(colors.black)
  153. -- Ausschalten
  154. term.setCursorPos(5,3)
  155. term.setBackgroundColor(colors.red)
  156. term.write(" ")
  157. term.setBackgroundColor(colors.black)
  158. term.setCursorPos(5,4)
  159. term.setBackgroundColor(colors.red)
  160. term.write(" ")
  161. term.setBackgroundColor(colors.black)
  162. term.setCursorPos(5,5)
  163. term.setBackgroundColor(colors.red)
  164. term.write(" ")
  165. term.setBackgroundColor(colors.black)
  166. term.setCursorPos(6,3)
  167. term.setBackgroundColor(colors.red)
  168. term.write(" ")
  169. term.setBackgroundColor(colors.black)
  170. term.setCursorPos(6,4)
  171. term.setBackgroundColor(colors.red)
  172. term.write(" ")
  173. term.setBackgroundColor(colors.black)
  174. term.setCursorPos(6,5)
  175. term.setBackgroundColor(colors.red)
  176. term.write(" ")
  177. term.setBackgroundColor(colors.black)
  178. end
  179.  
  180.  
  181. function Eingabe()
  182.     event,side,x,y = os.pullEvent()
  183.     if event == "terminate" then
  184.         write("Admin Passwort:")
  185.         admin = read("*")
  186.         if admin == adminpass then
  187.             os.pullEvent = pullEvent
  188.             write("Richtig! Mache jetzt nochmal STRG + T für 4 sec")
  189.             sleep(5)
  190.         end
  191.     end
  192.     if event == "monitor_touch" then
  193.  
  194.         if x == 2 and y == 2 or
  195.            x == 2 and y == 3 or
  196.            x == 2 and y == 4 or
  197.            x == 3 and y == 2 or
  198.            x == 3 and y == 3 or
  199.            x == 3 and y == 4 then
  200.            redstone.setOutput(redout, true)
  201. --         redstone.setOutput(redout2, false)
  202.            AnzeigeEin()
  203.         end
  204.  
  205.         if x == 5 and y == 2 or
  206.            x == 5 and y == 3 or
  207.            x == 5 and y == 4 or
  208.            x == 6 and y == 2 or
  209.            x == 6 and y == 3 or
  210.            x == 6 and y == 4 then
  211.            redstone.setOutput(redout, false)
  212. --         redstone.setOutput(redout2, true)
  213.            AnzeigeAus()
  214.         end
  215.     end
  216. end
  217.  
  218. redstone.setOutput(redout, false)
  219. Rahmen()
  220. while true do
  221. Eingabe()
  222. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement