craniumkid22

Illuminator Fader

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