Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "/tech/doubletap.lua"
- function init()
- storage.rainbowCounter = 0
- self.color1 = 0x95d14f
- self.color2 = 0x50b754
- self.color3 = 0x00a192
- end
- function transition(color1, color2, position)
- local r1 = color1 / 65536
- r1 = r1 - r1 % 1
- local g1 = (color1 - r1 * 65536) / 256
- g1 = g1 - g1 % 1
- local b1 = color1 - r1 * 65536 - g1 * 256
- local r2 = color2 / 65536
- r2 = r2 - r2 % 1
- local g2 = (color2 - r2 * 65536) / 256
- g2 = g2 - g2 % 1
- local r, g, b =
- r1 + (r2 - r1) * position,
- g1 + (g2 - g1) * position,
- b1 + (color2 - r2 * 65536 - g2 * 256 - b1) * position
- return
- (r - r % 1) * 65536 +
- (g - g % 1) * 256 +
- (b - b % 1)
- end
- function uninit()
- tech.setParentDirectives()
- end
- function update(args)
- storage.rainbowCounter = storage.rainbowCounter + 1
- if storage.rainbowCounter >= 300 then
- storage.rainbowCounter = 0
- end
- if storage.rainbowCounter <= 100 then
- tech.setParentDirectives(string.format("?setcolor=%x", transition(color1,color2,(storage.rainbowCounter)/100)) .. "ff")
- elseif storage.rainbowCounter <= 200 then
- tech.setParentDirectives(string.format("?setcolor=%x", transition(color2,color3,(storage.rainbowCounter-200)/100)) .. "ff")
- elseif storage.rainbowCounter <=300 then
- tech.setParentDirectives(string.format("?setcolor=%x", transition(color3,color1,(storage.rainbowCounter-300)/100)) .. "ff")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement