88 lines
1.6 KiB
Lua
88 lines
1.6 KiB
Lua
fade={
|
|
--table={13,15,5,3,12,5,6,7,12,9,10,16,9,13,14},
|
|
table={2,3,5,7,6,0,5,4,11,16,6,9,12,10,14,11},
|
|
pal={},
|
|
old_update=nil,
|
|
step=0,
|
|
max_steps=6,
|
|
outin=false,
|
|
|
|
init = function()
|
|
for i=1,16 do
|
|
local r,g,b=getcolor(i)
|
|
fade.pal[i]={r,g,b}
|
|
end
|
|
end,
|
|
|
|
getstep=function(num,steps)
|
|
if steps==0 or num==0 then return num end
|
|
for i=1,steps do
|
|
num=fade.table[num]
|
|
if num==0 then return num end
|
|
end
|
|
return num
|
|
end,
|
|
|
|
fadeout = function(steps)
|
|
fade.old_update=update
|
|
update=fade.update_fadeout
|
|
fade.step=0
|
|
fade.max_steps=steps or 6
|
|
end,
|
|
|
|
fadeoutin = function()
|
|
fade.old_update=update
|
|
update=fade.update_fadeout
|
|
fade.step=0
|
|
fade.outin=true
|
|
end,
|
|
|
|
update_fadeout=function()
|
|
if beat() then
|
|
for i=1,16 do
|
|
local v=fade.getstep(i,fade.step)
|
|
if v==0 then
|
|
setcolor(i,0,0,0)
|
|
else
|
|
setcolor(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3])
|
|
end
|
|
end
|
|
fade.step=fade.step+1
|
|
if fade.step>fade.max_steps then
|
|
update = fade.old_update
|
|
if fade.outin then
|
|
fade.outin=false;
|
|
fade.fadein()
|
|
end
|
|
end
|
|
end
|
|
end,
|
|
|
|
fadein = function()
|
|
fade.old_update=update
|
|
update=fade.update_fadein
|
|
fade.step=6
|
|
for i=1,16 do setcolor(i,0,0,0) end
|
|
end,
|
|
|
|
update_fadein=function()
|
|
fade.old_update()
|
|
|
|
if beat() then
|
|
for i=1,16 do
|
|
local v=fade.getstep(i,fade.step)
|
|
if v==0 then
|
|
setcolor(i,0,0,0)
|
|
else
|
|
setcolor(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3])
|
|
end
|
|
end
|
|
fade.step=fade.step-1
|
|
if fade.step<0 then
|
|
update = fade.old_update
|
|
end
|
|
end
|
|
end
|
|
|
|
}
|