VPX Functions
Lights

Rainbow Changing Lights

1min
&#x9;' &#x9;' rainbow changing lights &#x9;' &#x9;dim rgbstep, rgbfactor, rred, rgreen, rblue, rainbowlights &#x9;sub startrainbow(n) &#x9; set rainbowlights = n &#x9; rgbstep = 0 &#x9; rgbfactor = 5 &#x9; rred = 255 &#x9; rgreen = 0 &#x9; rblue = 0 &#x9; rainbowtimer enabled = 1 &#x9;end sub &#x9;dim rgbstep2, rgbfactor2, rred2, rgreen2, rblue2, rainbowlights2 &#x9;sub startrainbow2(n) &#x9; set rainbowlights2 = n &#x9; rgbstep2 = 0 &#x9; rgbfactor2 = 5 &#x9; rred2 = 255 &#x9; rgreen2 = 0 &#x9; rblue2 = 0 &#x9; rainbowtimer1 enabled = 1 &#x9;end sub &#x9;sub stoprainbow(n) &#x9; dim obj &#x9; rainbowtimer enabled = 0 &#x9; rainbowtimer enabled = 0 &#x9; for each obj in rainbowlights &#x9; setlightcolor obj, "white", 0 &#x9; next &#x9;end sub &#x9;sub stoprainbow2(n) &#x9; dim obj &#x9; rainbowtimer1 enabled = 0 &#x9; for each obj in rainbowlights2 &#x9; setlightcolor obj, "white", 0 &#x9; obj state = 1 &#x9; obj intensity = 7 &#x9; next &#x9;end sub &#x9;sub rainbowtimer timer 'rainbow led light color changing &#x9; dim obj &#x9; select case rgbstep &#x9; case 0 'green &#x9; rgreen = rgreen + rgbfactor &#x9; if rgreen > 255 then &#x9; rgreen = 255 &#x9; rgbstep = 1 &#x9; end if &#x9; case 1 'red &#x9; rred = rred rgbfactor &#x9; if rred < 0 then &#x9; rred = 0 &#x9; rgbstep = 2 &#x9; end if &#x9; case 2 'blue &#x9; rblue = rblue + rgbfactor &#x9; if rblue > 255 then &#x9; rblue = 255 &#x9; rgbstep = 3 &#x9; end if &#x9; case 3 'green &#x9; rgreen = rgreen rgbfactor &#x9; if rgreen < 0 then &#x9; rgreen = 0 &#x9; rgbstep = 4 &#x9; end if &#x9; case 4 'red &#x9; rred = rred + rgbfactor &#x9; if rred > 255 then &#x9; rred = 255 &#x9; rgbstep = 5 &#x9; end if &#x9; case 5 'blue &#x9; rblue = rblue rgbfactor &#x9; if rblue < 0 then &#x9; rblue = 0 &#x9; rgbstep = 0 &#x9; end if &#x9; end select &#x9; for each obj in rainbowlights &#x9; obj color = rgb(rred \ 10, rgreen \ 10, rblue \ 10) &#x9; obj colorfull = rgb(rred, rgreen, rblue) &#x9; next &#x9;end sub &#x9;sub rainbowtimer1 timer 'rainbow led light color changing &#x9; dim obj &#x9; select case rgbstep2 &#x9; case 0 'green &#x9; rgreen2 = rgreen2 + rgbfactor2 &#x9; if rgreen2 > 255 then &#x9; rgreen2 = 255 &#x9; rgbstep2 = 1 &#x9; end if &#x9; case 1 'red &#x9; rred2 = rred2 rgbfactor2 &#x9; if rred2 < 0 then &#x9; rred2 = 0 &#x9; rgbstep2 = 2 &#x9; end if &#x9; case 2 'blue &#x9; rblue2 = rblue2 + rgbfactor2 &#x9; if rblue2 > 255 then &#x9; rblue2 = 255 &#x9; rgbstep2 = 3 &#x9; end if &#x9; case 3 'green &#x9; rgreen2 = rgreen2 rgbfactor2 &#x9; if rgreen2 < 0 then &#x9; rgreen2 = 0 &#x9; rgbstep2 = 4 &#x9; end if &#x9; case 4 'red &#x9; rred2 = rred2 + rgbfactor2 &#x9; if rred2 > 255 then &#x9; rred2 = 255 &#x9; rgbstep2 = 5 &#x9; end if &#x9; case 5 'blue &#x9; rblue2 = rblue2 rgbfactor2 &#x9; if rblue2 < 0 then &#x9; rblue2 = 0 &#x9; rgbstep2 = 0 &#x9; end if &#x9; end select &#x9; ' for each obj in rainbowlights2 &#x9; ' obj color = rgb(rred2 \ 10, rgreen2 \ 10, rblue2 \ 10) &#x9; ' obj colorfull = rgb(rred2, rgreen2, rblue2) &#x9; ' next &#x9;end sub