Main
Projects
Art
Music
Scripting
LiveJournal
Forum
Links
Time of Day Script
by Moogle1

Given a time of day from 0 to 23, fades the screen to look like it's that time.


include,plotscr.hsd

define script(1,startup,none) #run this script when you start up!
define script(autonumber,dofade,none)

global variable(1,last_r)
global variable(2,last_g)
global variable(3,last_b)

define constant(200,pal) #where the palette is stored, from 200 to 965
# Change the number 200 if you are using those globals

script,startup,begin
 if (readglobal(245)==0) then
 (
   setvariable(timeoffset,18)
   variable(ctr)
   for(ctr,0,255) do
   (
     writeglobal(pal+ctr*3,readcolor(ctr,color:red))
     writeglobal(pal+1+ctr*3,readcolor(ctr,color:green))
     writeglobal(pal+2+ctr*3,readcolor(ctr,color:blue))
   )
 )
 last_r:=0
 dofade(5) #for 5:00 in the morning... replace 5 with the actual time
 #if you want anything else done when you start up, put it here
end

script,dofade,time,begin
 variable(ratio_r)
 variable(ratio_g)
 variable(ratio_b)
 variable(ctr)
 if (time>>12) then (time:=24--time)
 if (time>>8) then
 (
   ratio_r:=100
   ratio_g:=100
   ratio_b:=100
 )
 if (time<<4) then
 (
   ratio_r:=25
   ratio_g:=30
   ratio_b:=35
 )
 if (time==4) then
 (
   ratio_r:=45
   ratio_g:=35
   ratio_b:=40
 )
 if (time==5) then
 (
   ratio_r:=60
   ratio_g:=50
   ratio_b:=45
 )
 if (time==6) then
 (
   ratio_r:=70
   ratio_g:=60
   ratio_b:=55
 )
 if (time==7) then
 (
   ratio_r:=90
   ratio_g:=80
   ratio_b:=70
 )
 if (time==8) then
 (
   ratio_r:=100
   ratio_g:=100
   ratio_b:=90
 )
 if (last_r<>ratio_r,or,last_g<>ratio_g,or,last_b<>ratio_b) then
 (
   for (ctr,0,255) do
   (
     writecolor(ctr,color:red,(readglobal(200+ctr*3)*ratio_r)/100)
     writecolor(ctr,color:green,(readglobal(201+ctr*3)*ratio_g)/100)
     writecolor(ctr,color:blue,(readglobal(202+ctr*3)*ratio_b)/100)
   )
 )
 last_r:=ratio_r
 last_g:=ratio_g
 last_b:=ratio_b
 updatepalette
end


Site layout (c)2000 Jennifer Raby. Used by permission.