Advertisement
absorr

CC Lamp Show

Sep 28th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.00 KB | None | 0 0
  1. local rgb = 31744
  2. local from = "F00"
  3. local to = "FF0"
  4.  
  5. function incR()
  6.   rgb = rgb + 1024
  7. end
  8.  
  9. function decR()
  10.   rgb = rgb - 1024
  11. end
  12.  
  13. function incG()
  14.   rgb = rgb + 32
  15. end
  16.  
  17. function decG()
  18.   rgb = rgb - 32
  19. end
  20.  
  21. function incB()
  22.   rgb = rgb + 1
  23. end
  24.  
  25. function decB()
  26.   rgb = rgb - 1
  27. end
  28.  
  29. function nextColor(c, f, t)
  30.   if f == "F00" and t == "FF0" then
  31.     return c + 32
  32.   elseif f == "FF0" and t == "0F0" then
  33.     return c - 1024
  34.   elseif f == "0F0" and t == "0FF" then
  35.     return c + 1
  36.   elseif f == "0FF" and t == "00F" then
  37.     return c - 32
  38.   elseif f == "00F" and t == "F0F" then
  39.     return c + 1024
  40.   elseif f == "F0F" and t == "F00" then
  41.     return c - 1
  42.   else
  43.     return c
  44.   end
  45. end
  46.  
  47. function getTo(c, t)
  48.     if t == "FF0" and rgb == 32736 then
  49.       return "0F0"
  50.     elseif t == "0F0" and rgb == 992 then
  51.       return "0FF"
  52.     elseif t == "0FF" and rgb == 1023 then
  53.       return "00F"
  54.     elseif t == "00F" and rgb == 31 then
  55.       return "F0F"
  56.     elseif t == "F0F" and rgb == 31775 then
  57.       return "F00"
  58.     elseif t == "F00" and rgb == 31744 then
  59.       return "FF0"
  60.     end
  61. end
  62.  
  63. function getFrom(c, t)
  64.     if t == "FF0" and rgb == 32736 then
  65.       return "FF0"
  66.     elseif t == "0F0" and rgb == 992 then
  67.       return "0F0"
  68.     elseif t == "0FF" and rgb == 1023 then
  69.       return "0FF"
  70.     elseif t == "00F" and rgb == 31 then
  71.       return "00F"
  72.     elseif t == "F0F" and rgb == 31775 then
  73.       return "F0F"
  74.     elseif t == "F00" and rgb == 31744 then
  75.       return "F00"
  76.     end
  77. end
  78.  
  79. local p1 = peripheral.wrap("colorful_lamp_1")
  80. local p2 = peripheral.wrap("colorful_lamp_2")
  81. local p3 = peripheral.wrap("colorful_lamp_3")
  82. local p4 = peripheral.wrap("colorful_lamp_4")
  83. local p5 = peripheral.wrap("colorful_lamp_5")
  84. local p6 = peripheral.wrap("colorful_lamp_6")
  85. local p7 = peripheral.wrap("colorful_lamp_7")
  86. local p8 = peripheral.wrap("colorful_lamp_8")
  87. local p9 = peripheral.wrap("colorful_lamp_9")
  88. local p10 = peripheral.wrap("colorful_lamp_10")
  89. local p11 = peripheral.wrap("colorful_lamp_11")
  90. local p12 = peripheral.wrap("colorful_lamp_12")
  91. local p13 = peripheral.wrap("colorful_lamp_13")
  92. local p14 = peripheral.wrap("colorful_lamp_14")
  93. local p15 = peripheral.wrap("colorful_lamp_15")
  94. local p16 = peripheral.wrap("colorful_lamp_16")
  95. local p17 = peripheral.wrap("colorful_lamp_17")
  96. local p18 = peripheral.wrap("colorful_lamp_18")
  97. local p19 = peripheral.wrap("colorful_lamp_19")
  98. local p20 = peripheral.wrap("colorful_lamp_20")
  99. local p21 = peripheral.wrap("colorful_lamp_21")
  100. local p22 = peripheral.wrap("colorful_lamp_22")
  101. local p23 = peripheral.wrap("colorful_lamp_23")
  102. local p24 = peripheral.wrap("colorful_lamp_24")
  103. local p25 = peripheral.wrap("colorful_lamp_25")
  104.  
  105. function main()
  106.   while true do
  107.     if to == "FF0" and rgb == 32736 then
  108.       to = "0F0"
  109.       from = "FF0"
  110.     elseif to == "0F0" and rgb == 992 then
  111.       to = "0FF"
  112.       from = "0F0"
  113.     elseif to == "0FF" and rgb == 1023 then
  114.       to = "00F"
  115.       from = "0FF"
  116.     elseif to == "00F" and rgb == 31 then
  117.       to = "F0F"
  118.       from = "00F"
  119.     elseif to == "F0F" and rgb == 31775 then
  120.       to = "F00"
  121.       from = "F0F"
  122.     elseif to == "F00" and rgb == 31744 then
  123.       to = "FF0"
  124.       from = "F00"
  125.     end
  126.    
  127.     cl = rgb
  128.     f = from
  129.     t = to
  130.     p1.setLampColor(cl)
  131.     cl = nextColor(cl, f, t)
  132.     f = getFrom(c, t)
  133.     t = getTo(c, t)
  134.     p2.setLampColor(cl)
  135.     cl = nextColor(cl, f, t)
  136.     f = getFrom(c, t)
  137.     t = getTo(c, t)
  138.     p3.setLampColor(cl)
  139.     cl = nextColor(cl, f, t)
  140.     f = getFrom(c, t)
  141.     t = getTo(c, t)
  142.     p4.setLampColor(cl)
  143.     cl = nextColor(cl, f, t)
  144.     f = getFrom(c, t)
  145.     t = getTo(c, t)
  146.     p5.setLampColor(cl)
  147.     cl = nextColor(cl, f, t)
  148.     f = getFrom(c, t)
  149.     t = getTo(c, t)
  150.     p6.setLampColor(cl)
  151.     p16.setLampColor(cl)
  152.     p21.setLampColor(cl)
  153.     cl = nextColor(cl, f, t)
  154.     f = getFrom(c, t)
  155.     t = getTo(c, t)
  156.     p7.setLampColor(cl)
  157.     p17.setLampColor(cl)
  158.     p22.setLampColor(cl)
  159.     cl = nextColor(cl, f, t)
  160.     f = getFrom(c, t)
  161.     t = getTo(c, t)
  162.     p8.setLampColor(cl)
  163.     p18.setLampColor(cl)
  164.     p23.setLampColor(cl)
  165.     cl = nextColor(cl, f, t)
  166.     f = getFrom(c, t)
  167.     t = getTo(c, t)
  168.     p9.setLampColor(cl)
  169.     p19.setLampColor(cl)
  170.     p24.setLampColor(cl)
  171.     cl = nextColor(cl, f, t)
  172.     f = getFrom(c, t)
  173.     t = getTo(c, t)
  174.     p10.setLampColor(cl)
  175.     p20.setLampColor(cl)
  176.     p25.setLampColor(cl)
  177.     cl = nextColor(cl, f, t)
  178.     f = getFrom(c, t)
  179.     t = getTo(c, t)
  180.     p11.setLampColor(cl)
  181.     cl = nextColor(cl, f, t)
  182.     f = getFrom(c, t)
  183.     t = getTo(c, t)
  184.     p12.setLampColor(cl)
  185.     cl = nextColor(cl, f, t)
  186.     f = getFrom(c, t)
  187.     t = getTo(c, t)
  188.     p13.setLampColor(cl)
  189.     cl = nextColor(cl, f, t)
  190.     f = getFrom(c, t)
  191.     t = getTo(c, t)
  192.     p14.setLampColor(cl)
  193.     cl = nextColor(cl, f, t)
  194.     f = getFrom(c, t)
  195.     t = getTo(c, t)
  196.     p15.setLampColor(cl)
  197.     cl = nextColor(cl, f, t)
  198.     f = getFrom(c, t)
  199.     t = getTo(c, t)
  200.    
  201.     rgb = nextColor(rgb, from, to)
  202.    
  203.     os.sleep(0.05)
  204.    
  205.   end
  206. end
  207.  
  208. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement