Plotscript of the Month
Time of Day, by Moogle1
Download an example of this script in action
This is an example script that will allow you to change the palette to make it appear as if it is a certain time of day. The script will not automatically cycle through the different times of day; it is up to you to decide how you want to do this.
| # TIME OF DAY # Original author: Moogle1 include,plotscr.hsd define script(1, startup, none) #run this script when you start up! define script(2, do fade, 1, 12) global variable(1, last r) global variable(2, last g) global variable(3, last b) global variable(4, time of day) define constant(250, pal) # where the palette is stored, from 250 to 1015 # Be sure not to overwrite those global variables! script, startup, begin if (last r == 0) then ( # if this is the first time through, then initialize all the variables time of day := 5 # we'll make it 5:00am so you can see the script's effect # you'll probably want to change that, though 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 do fade(time of day) end script, do fade, 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 ) # check to see if fading is necessary 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(pal + ctr * 3) * ratio r) / 100) writecolor(ctr, color:green, (readglobal(pal + 1 + ctr * 3) * ratio g) / 100) writecolor(ctr, color:blue, (readglobal(pal + 2 + ctr * 3) * ratio b) / 100) ) ) last r := ratio r last g := ratio g last b := ratio b update palette time of day := time end |
Usage
Run startup every time the game is started (new games and loaded games). You can call do fade, either from a text box or another script, to change the time of day. If you do, the resulting palette will be used when the game starts up again.
Due to the way scripts are interpreted, the game will fade in with the normal palette and then flash to the time-of-day adjusted palette. This can't be avoided, but can be worked around in a few different ways, such as only allowing the player to save at noon or always starting the game with a black screen.
If you're familiar with palettes, you might consider changing around the RGB ratios in do fade. The settings provided will give you an orangish tint at sunset/sunrise and a bluish tint at night.
Finally, the script will start your game with the 5:00am palette. Change the line that says time of day := 5 to whatever time you want.