The water looks terrific. Is there any way to change the water's cubemap so it changes along with this day night script? I have a level with nice dawn, noon, dusk, and midnight cubemaps, with the following script. I would like to tie it to the water so the whole environment changes over time.



var ticks_u_minuti = .16; // 1 min ingame time = 1 sec = 16 ticks

var minuta = 0; // starting game minutes

var sat = 17; // starting game hour

var dan = 1; // starting game day

var mjesec = 1; // starting game month

var godina = 1000; // starting game year

var dan_u_tjednu = 1; // starting day of the week

var brojac = 0;

var vrijeme1 = 0;



font standard_font = <ackfont.pcx>, 6, 9; // uncomment this if you're not using the templates



// months in a year

string 1_mjesec = "January";

string 2_mjesec = "February";

string 3_mjesec = "March";

string 4_mjesec = "April";

string 5_mjesec = "May";

string 6_mjesec = "June";

string 7_mjesec = "July";

string 8_mjesec = "August";

string 9_mjesec = "September";

string 10_mjesec = "October";

string 11_mjesec = "November";

string 12_mjesec = "December";



// days in a week

string 1_dan = "Monday";

string 2_dan = "Tuesday";

string 3_dan = "Wednesday";

string 4_dan = "Thursday";

string 5_dan = "Friday";

string 6_dan = "Saturday";

string 7_dan = "Sunday";



// temp strings

string temp_sat_str[8];

string temp_min_str[2];

string temp_dan_str;

string temp_mjesec_str;

string temp_godina_str;

string temp_day_nmb;

string day_title[2];





// string array for months

text MjesecUGodini

{

strings = 12;

string = 1_mjesec, 2_mjesec, 3_mjesec, 4_mjesec, 5_mjesec, 6_mjesec, 7_mjesec, 8_mjesec, 9_mjesec, 10_mjesec, 11_mjesec, 12_mjesec;

}



//string array for days

text DanUTjednu

{

strings = 7;

string = 1_dan,2_dan,3_dan,4_dan,5_dan,6_dan,7_dan;

}



// display date text object

text PrikaziDatum

{

pos_x = 20;

pos_y = 40;

font = standard_font;

strings = 1;

string = temp_dan_str;

}



// display clock text object

text PrikaziSat

{

pos_x = 20;

pos_y = 80;

font = standard_font;

strings = 1;

string = temp_sat_str;

}



// put this function in Main() if you want the Time Manager only

function init_time()

{

pass_time();

get_datetime();

PrikaziSat.visible = on;

PrikaziDatum.visible = on;

}



// this is time calculation function

function pass_time()

{

while(1)

{

// wait for the given number of ticks (16 ticks = 1 second)

waitt(ticks_u_minuti);

// then increase minute counter by 1

minuta += 1;

IF (minuta > 59)

{ // if one hour has passed

minuta = 0;

sat += 1;

}

if (sat > 23)

{ // ome day has passed

sat = 0;

dan += 1;

dan_u_tjednu += 1;

}

if (dan_u_tjednu > 7)

{ // we check the day of the week, if the number is bigger than 7 then it's Monday again

dan_u_tjednu = 1;

}

// we check what month it is

if ((mjesec == 1) || (mjesec == 3) || (mjesec == 5) || (mjesec == 7) || (mjesec == 8) || (mjesec == 10) || (mjesec == 12))

{

brojac = 31;

}

if ((mjesec == 4) || (mjesec == 6) || (mjesec == 9) || (mjesec == 11))

{

brojac = 30;

}

// if it's February

if (mjesec == 2)

{

brojac = 28;

}

if (dan > brojac)

{ // one month has passed

dan = 1;

mjesec += 1;

}

if (mjesec > 12)

{ // one year has passed

godina += 1;

mjesec = 1;

}

// date check

if (dan == 1)

{

str_cpy(day_title, "st");

}

if (dan == 2)

{

str_cpy(day_title, "nd");

}

if (dan == 3)

{

str_cpy(day_title, "rd");

}

if (dan >= 4)

{

str_cpy(day_title, "th");

}

}

}



// this function creates the apropriate panels for time/date panels

function get_datetime()

{

while(1)

{

// date panel

str_cpy(temp_dan_str, DanUTjednu.string[dan - 1]);

str_cpy(temp_mjesec_str, MjesecUGodini.string[mjesec - 1]);

str_for_num(temp_godina_str,godina);

str_for_num(temp_day_nmb,dan);

str_cat(temp_dan_str, " ");

str_cat(temp_dan_str, temp_day_nmb);

str_cat(temp_dan_str, day_title);

str_cat(temp_dan_str, ", ");

str_cat(temp_dan_str, temp_mjesec_str);

str_cat(temp_dan_str, ", ");

str_cat(temp_dan_str, temp_godina_str);

str_cat(temp_dan_str, " NR");

// clock panel

str_for_num(temp_sat_str, sat);

str_cat(temp_sat_str, " : ");

str_for_num(temp_min_str,minuta);

str_cat(temp_sat_str, temp_min_str);

wait(1);

}

}



//////////////////////////////////////////////////////////////////////////////////////////

// Day/Night change


sky jutro // this is the noon skycube
{
type = <Sky_MexicaNoon+6.tga>;
flags = cube,visible;
layer = 1;
flags = cube, visible, transparent;
alpha = 100;
layer = 2;
}

sky sumrak // this is the sunset skycube
{
type = <Sky_MexicaSunset+6.tga>;
flags = cube,visible;
layer = 1;
flags = cube, visible, transparent;
alpha = 100;
layer = 2;
}

sky noc // night skycube
{
type = <Sky_MexicaMidnight+6.tga>;
flags = cube,visible;
layer = 1;
flags = cube, visible, transparent;
alpha = 100;
layer = 2;
}

sky podne // morning skycube
{
type = <Sky_MexicaDawn+6.tga>;
flags = cube,visible;
layer = 1;
flags = cube, visible, transparent;
alpha = 100;
layer = 2;
}

// state vars

var dan_ili_noc = 1; // 0 - Night, 1 - Noon, 3 - Sunset, 4 - Morning, 0.5 - transition



// noon to sunset transition function

function podne_u_sumrak(duration)

{

var trans;

if(dan_ili_noc != 1) { return(-1); }

sumrak.visible = on;

if(duration > 0)

{

dan_ili_noc = 0.5;

trans = duration;

while(trans > 0)

{

jutro.alpha = 100*(trans/duration);

trans -= time;

wait(1);

}

dan_ili_noc = 3;

}

jutro.alpha = 0;

jutro.visible = off;

}



// sunset to night transition function

function sumrak_u_noc(duration)

{

var trans;

if(dan_ili_noc != 3) { return(-1); }

noc.visible = on;

if(duration > 0)

{

dan_ili_noc = 0.5;

trans = duration;

while(trans > 0)

{

sumrak.alpha = 100*(trans/duration);

trans -= time;

wait(1);

}

dan_ili_noc = 0;

}

sumrak.alpha = 0;

sumrak.visible = off;

}



//night to morning transition function

function noc_u_zoru(duration)

{

var trans;

if(dan_ili_noc != 0) { return(-1); }

podne.visible = on;

if(duration > 0)

{

dan_ili_noc = 0.5;

trans = duration;

while(trans > 0)

{

noc.alpha = 100*(trans/duration);

trans -= time;

wait(1);

}

dan_ili_noc = 4;

}

noc.alpha = 0;

noc.visible = off;

}



// morning to noon transition function

function zora_u_podne(duration)

{

var trans;

if(dan_ili_noc != 4) { return(-1); }

jutro.visible = on; //

if(duration > 0)

{

dan_ili_noc = 0.5; // transition flag

trans = 0;

while(trans < duration)

{

jutro.alpha = 100 * (trans/duration);

trans += time;

wait(1);

}

dan_ili_noc = 1; //

}

jutro.alpha = 100;

podne.visible = off;

}



// state changing function, put this into the Main() function if you want the Day/Night Manager only

function change_sky()

{

while(1)

{

if (sat == 5) // if it's 6 AM then change the sky from night to morning

{

noc_u_zoru(128 * ticks_u_minuti); // change the number 16 to a higher number if you want a longer transition

}

if (sat == 11) // if it's 12 PM then change the sky from morning to noon

{

zora_u_podne(128 * ticks_u_minuti);

}

if (sat == 17) // if it's 6 PM then change the sky from noon to sunset

{

podne_u_sumrak(128 * ticks_u_minuti);

}

if (sat == 19) // if it's 8 PM then change the sky from sunset to night

{

sumrak_u_noc(128 * ticks_u_minuti);

}

wait(1);

}

}


// put this function in your main() function if you want both features

function daytime_manager()

{

init_time();

change_sky();

}