Advertisement
theoriginalbit

OpenPeripheral: Colourful Illuminators

Sep 28th, 2013
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. -- WARNING: Updating a large amount of Glowstone Illuminators will cause framerate lag!
  2.  
  3. local function disperse(col)
  4.   for _,n in pairs(peripheral.getNames()) do
  5.     if peripheral.getType(n) == "glowstone_illuminator" then
  6.       peripheral.call(n, "setColor", col)
  7.     end
  8.   end
  9. end
  10.  
  11. local source = {R = 0; G = 0; B = 0;}
  12.  
  13. local function fade(target)
  14.   for i = 0, 30 do
  15.     local ratio = i/30
  16.     local red = math.floor(target.R * ratio + source.R * (1-ratio))
  17.     local green = math.floor(target.G * ratio + source.G * (1-ratio))
  18.     local blue = math.floor(target.B * ratio + source.B * (1-ratio))
  19.     disperse(bit.bor(bit.blshift(bit.bor(bit.blshift(red, 8), green), 8), blue))
  20.     sleep(0.5)
  21.   end
  22.   source = target
  23. end
  24.  
  25. while true do
  26.   fade({R = math.random(0,255); G = math.random(0,255); B = math.random(0,255);})
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement