Advertisement
Birog

Test1

Mar 25th, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.90 KB | None | 0 0
  1. local mon = peripheral.wrap("back")
  2. function clear()
  3.         term.clear()
  4.         term.setCursorPos(1,1)
  5. end
  6. print( "Copyright by TheBommel" )
  7. write( "Es wird nach Updates gesucht... " )
  8. local response = http.get("http://pastebin.com/raw.php?i=sUzFGNLu")    
  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 TheBommel!!")
  37.    clear()
  38. end
  39. -----------------------------------------------------------------------------------------------------------------
  40. rednet.open("top")
  41. local mon = peripheral.wrap("back")
  42. -- Farbdecodierer
  43. function decode(int)
  44.         if int == 1 then
  45.                 return 1
  46.         elseif int == 2 then
  47.                 return 2
  48.         elseif int == 3 then
  49.                 return 4
  50.         elseif int == 4 then
  51.                 return 8
  52.         elseif int == 5 then
  53.                 return 16
  54.         elseif int == 6 then
  55.                 return 32
  56.         elseif int == 7 then
  57.                 return 64
  58.         elseif int == 8 then
  59.                 return 128
  60.         elseif int == 9 then
  61.                 return 256
  62.         elseif int == 10 then
  63.                 return 512
  64.         elseif int == 11 then
  65.                 return 1024
  66.         elseif int == 12 then
  67.                 return 2048
  68.         elseif int == 13 then
  69.                 return 4096
  70.         elseif int == 14 then
  71.                 return 8192
  72.         elseif int == 15 then
  73.                 return 16384
  74.         elseif int == 16 then
  75.                 return 32768
  76.         end
  77. end
  78. -----------------------------------------------------------------------------------------------------------------
  79. while true do
  80.  mon.setBackgroundColor(decode(16))
  81.  mon.setCursorPos(14, 1)
  82.  mon.write("Quarry-Control")
  83.  
  84. -- Gruener Quarry
  85.  mon.setBackgroundColor(decode(16))
  86.  mon.setCursorPos(10, 5)
  87.  mon.write("Quarry Gruen")
  88.  mon.setCursorPos(30, 5)
  89.  mon.setBackgroundColor(decode(14))
  90.  mon.write("ON")
  91.  mon.setCursorPos(35, 5)
  92.  mon.setBackgroundColor(decode(15))
  93.  mon.write("OFF")
  94.  mon.setBackgroundColor(decode(16))
  95.  
  96. -- Roter Quarry
  97.  
  98.  mon.setBackgroundColor(decode(16))
  99.  mon.setCursorPos(10, 7)
  100.  mon.write("Quarry Rot")
  101.  mon.setCursorPos(30,7)
  102.  mon.setBackgroundColor(decode(14))
  103.  mon.write("ON")
  104.  mon.setCursorPos(35, 7)
  105.  mon.setBackgroundColor(decode(15))
  106.  mon.write("OFF")
  107.  mon.setBackgroundColor(decode(16))
  108.  
  109. -- Cyan Quarry
  110.  
  111.  mon.setBackgroundColor(decode(16))
  112.  mon.setCursorPos(10, 9)
  113.  mon.write("Quarry Cyan")
  114.  mon.setCursorPos(30, 9)
  115.  mon.setBackgroundColor(decode(14))
  116.  mon.write("ON")
  117.  mon.setCursorPos(35, 9)
  118.  mon.setBackgroundColor(decode(15))
  119.  mon.write("OFF")  
  120.  mon.setBackgroundColor(decode(16))
  121.  
  122. -- Brauner Quarry
  123.  
  124.  mon.setBackgroundColor(decode(16))
  125.  mon.setCursorPos(10, 11)
  126.  mon.write("Quarry Braun")
  127.  mon.setCursorPos(30, 11)
  128.  mon.setBackgroundColor(decode(14))
  129.  mon.write("ON")
  130.  mon.setCursorPos(35, 11)
  131.  mon.setBackgroundColor(decode(15))
  132.  mon.write("OFF")
  133.  mon.setBackgroundColor(decode(16))
  134.  
  135. -- Lime Quarry
  136.  
  137.  mon.setBackgroundColor(decode(16))
  138.  mon.setCursorPos(10, 13)
  139.  mon.write("Quarry Lime")
  140.  mon.setCursorPos(30,13)
  141.  mon.setBackgroundColor(decode(14))
  142.  mon.write("ON")
  143.  mon.setCursorPos(35, 13)
  144.  mon.setBackgroundColor(decode(15))
  145.  mon.write("OFF")
  146.  mon.setBackgroundColor(decode(16))
  147.  
  148. -- Oranger Quarry
  149.  
  150.  mon.setBackgroundColor(decode(16))
  151.  mon.setCursorPos(10, 15)
  152.  mon.write("Quarry Orange")
  153.  mon.setCursorPos(30, 15)
  154.  mon.setBackgroundColor(decode(14))
  155.  mon.write("ON")
  156.  mon.setCursorPos(35, 15)
  157.  mon.setBackgroundColor(decode(15))
  158.  mon.write("OFF")
  159.  mon.setBackgroundColor(decode(16))
  160. -----------------------------------------------------------------------------------------------------------------
  161. -- ON/OFF Schaltung
  162. -- Gruen ON
  163.     e,d,x,y = os.pullEvent()
  164.         if event == "monitor_touch" then
  165.         if x == 30 and y == 5 then
  166.                 rednet.send(277, "on")
  167.     elseif x == 31 and y == 5 then  
  168.                 rednet.send(277, "on")
  169.    
  170. -- Gruen OFF
  171.         elseif x == 35 and y == 5 then
  172.                 rednet.send(277, off)
  173.     elseif x == 36 and y == 5 then  
  174.                 rednet.send(277, off)
  175.     elseif x == 37 and y == 5 then  
  176.                 rednet.send(277, off)
  177.  
  178. -- Rot ON
  179.         elseif y == 30 and x == 7 then
  180.                 rednet.send(284, on)
  181.     elseif y == 31 and x == 5 then  
  182.                 rednet.send(284, on)
  183.  
  184. -- Rot OFF
  185.         elseif y == 35 and x == 7 then
  186.                 rednet.send(284, off)
  187.     elseif y == 36 and x == 5 then  
  188.                 rednet.send(284, off)
  189.     elseif y == 37 and x == 5 then  
  190.                 rednet.send(284, off)
  191.  
  192. -- Cyan ON
  193.         elseif y == 30 and x == 9 then
  194.                 rednet.send(285, on)
  195.     elseif y == 31 and x == 9 then  
  196.                 rednet.send(285, on)
  197.  
  198. -- Cyan OFF
  199.         elseif y == 35 and x == 9 then
  200.                 rednet.send(285, off)
  201.     elseif y == 36 and x == 5 then  
  202.                 rednet.send(285, off)
  203.     elseif y == 37 and x == 9 then  
  204.                 rednet.send(285, off)
  205.  
  206. -- Braun ON
  207.         elseif y == 30 and x == 11 then
  208.                 rednet.send(286, on)
  209.     elseif y == 31 and x == 11 then  
  210.                 rednet.send(286, on)
  211.  
  212. -- Braun OFF
  213.         elseif y == 35 and x == 11 then
  214.                 rednet.send(286, off)
  215.     elseif y == 36 and x == 11 then  
  216.                 rednet.send(286, off)
  217.     elseif y == 37 and x == 11 then  
  218.                 rednet.send(286, off)
  219.  
  220. -- Lime ON
  221.         elseif y == 30 and x == 13 then
  222.                 rednet.send(287, on)
  223.     elseif y == 31 and x == 13 then  
  224.                 rednet.send(287, on)
  225.  
  226. -- Lime OFF
  227.         elseif y == 35 and x == 13 then
  228.                 rednet.send(287, off)
  229.     elseif y == 36 and x == 13 then  
  230.                 rednet.send(287, off)
  231.     elseif y == 37 and x == 13 then  
  232.                 rednet.send(287, off)
  233.  
  234. -- Orange ON
  235.         elseif y == 30 and x == 15 then
  236.                 rednet.send(288, on)
  237.     elseif y == 31 and x == 15 then  
  238.                 rednet.send(288, on)
  239.  
  240. -- Orange OFF
  241.         elseif y == 35 and x == 15 then
  242.                 rednet.send(288, off)
  243.     elseif y == 36 and x == 15 then  
  244.                 rednet.send(288, off)
  245.     elseif y == 37 and x == 15 then  
  246.                 rednet.send(288, off)
  247.     end
  248. end
  249. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement