I would like to increase or decrease the amount of sunlight (strength of sunlight) during the game through a day/night script and also through some health function of the sun -- if the sun is healthy it shines strongly -- is this possible?

The plants in the level then will grow well when there is enough sunlight, or wither when not according to the light available.

I have as a starting point this code from AUM 32 -- it works with a placed dynamic light, and seems to also measure the sunlight -- but doesnt change when the sun sets.

// place this line of code in the action attached to your player:
// "player_light();" (without the quotes)
/////////////////////////////////////////////////////////////////////////

bmap back_pcx = <back.pcx>;
bmap cursor_pcx = <cursor.pcx>;

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

panel back_pan
{
bmap = back_pcx;
pos_x = 5;
pos_y = 5;
layer = 20;
flags = overlay, refresh, visible;
}

panel cursor_pan
{
bmap = cursor_pcx;
pos_x = 0;
pos_y = 10;
layer = 25;
flags = overlay, refresh, visible;
}

function player_light()
{
while(1)
{
vec_set (temp, my.x);
temp.z -= 1000;
trace_mode = ignore_me + ignore_passable + scan_texture;
trace (my.x, temp);
cursor_pan.pos_x = 10 + 0.38 * tex_light; // the cursor should be able to move from 10 to 107 pixels = tex_light(0..255) * 0.38
wait (1); // no need to trace too often, so you could use a wait (3); here too
}
}



The manual talks about sun_light but doesnt mention how to change the color or intensity of the sunlight.

"If set above 0, a directional light is placed at the sun position.

Range:
0 .. unlimited

Type:
var
Example:
sun_light = 0; // no sun
See also:
spotlight, d3d_spotlightcone, max_light"



And the excellent day/night code:

///////////////////////////////
//////////////Day/Night System programmed by TripleX aka Timo Stark, Oliver2s. Fog added by Loopix
//////////////////////////////

VAR hours; //Time in houres
VAR minutes; //Time in minutes
VAR Zeit = 50; //time factor. Timefactor 1 = 20 min per day
VAR sun_pos1[3]; //reserved

//////////Day Night Zyklus


sky sky_wolken {
type = <wolken.tga>;
speed_u = 6;
speed_v = 5;
scale_y = 2;
scale_x = 2;
tilt = -25;
flags = dome,visible,transparent;
layer = 14;
alpha = 100;
}

sky sky_oberwolken {
type = <oberwolken.tga>;
speed_u = 4;
speed_v = 2;
scale_x = 3;
scale_y = 3;
tilt = -25;
flags = dome,visible,transparent;
layer = 13;
alpha = 100;
}



SKY sky_morgen {
type = <Sky_MexicaDawn+6.tga>;
layer = 5;
alpha = 100;
flags = cube, visible, transparent;
}

SKY sky_tag {
type = <Sky_MexicaNoon+6.tga>;
layer = 7;
alpha = 100;
flags = cube, visible, transparent;
}

SKY sky_abend {
type = <Sky_MexicaSunset+6.tga>;
layer = 6;
alpha = 100;
flags = cube, visible, transparent;
}

SKY sky_nacht {
type = <Sky_MexicaMidnight+6.tga>;
layer = 6;
alpha = 100;
flags = cube, visible, transparent;
}


SKY sky_sonne {
type = <sky_sonne.tga>;
scale_x = 30;
scale_y = 30;
layer = 9;
flags = visible, oriented, transparent, flare, bright;
alpha = 60;
}

SKY sky_sonne_nova {
type = <sky_sonne_nova.tga>;
scale_x = 14;
scale_y = 14;
layer = 10;
alpha = 60;
flags = visible, oriented, transparent, bright, flare;
alpha = 100;
}

SKY sky_mond {
type = <sky_mond.tga>;
scale_x = 5;
scale_y = 5;
layer = 12;
flags = oriented, transparent, visible;
alpha = 100;
}

SKY sky_mondschein {
type = <sky_mondschein.tga>;
scale_x = 12;
scale_y = 12;
layer = 11;
flags = oriented, transparent, visible;
alpha = 70;
}


function sonnen_zyklus() {

camera.fog_start = -1000;
camera.fog_end = 20000;
fog_color = 1;

while(1) {

//Sonnenwinkel:
sun_angle.pan += 0.01 * time * Zeit;
sun_angle.pan %= 360;
//Sonnenhöhe:
IF(sun_angle.pan >= 0) && (sun_angle.pan <= 90) {
sun_angle.tilt = ((((sun_angle.pan/15)*10)-30)-sun_angle.pan)*(-1);
}
IF(sun_angle.pan > 90) && (sun_angle.pan <= 180) {
sun_angle.tilt = (((((sun_angle.pan/15)*10)-30)-sun_angle.pan)-180)+300;
}
IF(sun_angle.pan > 180) && (sun_angle.pan <= 360) {
sun_angle.tilt = 30;
}
//Sonnenlicht, Helligkeit:
IF(sun_angle.pan >= 0) && (sun_angle.pan <= 20) {
sun_light = (sun_angle.pan*5);
camera.ambient = (sun_angle.pan*4);
IF(camera.fog_end < 20000 ) {
camera.fog_end+=8*time*zeit;
}
}
IF(sun_angle.pan > 20) && (sun_angle.pan <= 190) {
sun_light = 100;
camera.ambient = 80;
camera.fog_end=20000;
}
IF(sun_angle.pan > 190) && (sun_angle.pan <= 210) {
sun_light = ((((sun_angle.pan-190)*5)-100)*(-1));
camera.ambient = ((((sun_angle.pan-190)*4)-80)*(-1));
IF(camera.fog_end > 1200) {
camera.fog_end-=8*time*zeit;
}
}
IF(sun_angle.pan > 210) && (sun_angle.pan <= 360) {
sun_light = 0;
camera.ambient = 0;
camera.fog_start=-1000;
camera.fog_end=1200;
}
//Sky:
IF(sun_angle.pan >= 0) && (sun_angle.pan <= 20) {
sky_morgen.alpha = (sun_angle.pan*5);
sky_tag.alpha = 0;
sky_abend.alpha = 0;
sky_wolken.alpha = 10;
sky_oberwolken.alpha =10;
}
IF(sun_angle.pan >= 21) && (sun_angle.pan <= 40) {
sky_tag.alpha = ((sun_angle.pan-21)*(100/19));

IF (sky_wolken.alpha < 80){
sky_wolken.alpha += 0.03*time*zeit;
}

IF (sky_oberwolken.alpha < 80){
sky_oberwolken.alpha += 0.03*time*zeit;
}
}
IF(sun_angle.pan >= 41) && (sun_angle.pan <= 180) {
sky_tag.alpha = 100;
sky_wolken.alpha = 80;
sky_oberwolken.alpha = 80;
sky_abend.alpha = 100;
}
IF(sun_angle.pan >= 181) && (sun_angle.pan <= 190) {
sky_tag.alpha = ((((sun_angle.pan-180)*10)-100)*(-1));
sky_morgen.alpha = 0;
}
IF(sun_angle.pan >= 191) && (sun_angle.pan <= 210) {
sky_abend.alpha = ((((sun_angle.pan-191)*(100/19))-100)*(-1));

IF (sky_wolken.alpha > 10){
sky_wolken.alpha -= 0.03*time*zeit;
}
IF (sky_oberwolken.alpha > 10){
sky_oberwolken.alpha -= 0.03*time*zeit;
}
}
IF(sun_angle.pan >= 211) && (sun_angle.pan <= 360) {
sky_morgen.alpha = 0;
sky_tag.alpha = 0;
sky_wolken.alpha = 10;
sky_oberwolken.alpha = 10;
sky_abend.alpha = 0;
}
//Himmelskörper, Sonne:
sky_sonne.x = (sun_pos.x/8);
sky_sonne.y = (sun_pos.y/8);
IF(sun_angle.pan > 15) && (sun_angle.pan <= 90) {
sky_sonne.z = ((sun_angle.pan-15)*(86610/75)/8);
}
IF(sun_angle.pan > 90) && (sun_angle.pan <= 195) {
sky_sonne.z = ((((sun_angle.pan-90)*(86610/105)-86610)*(-1))/8);
sky_mond.tilt = 15;
sky_mondschein.tilt = 15;
}
IF(sun_angle.pan > 195) && (sun_angle.pan <=270 ) {
sky_sonne.z = ((((sun_angle.pan-195)*(86610/75))*(-1))/8);
sky_mond.tilt = (((sun_angle.pan -180)-30)*(-1));
sky_mondschein.tilt = (((sun_angle.pan -180)-30)*(-1));
}
IF(sun_angle.pan > 270) && (sun_angle.pan <= 360) {
sky_sonne.z = (((sun_angle.pan-270)*(74237/90)-86610)/8);
sky_mond.tilt = (((sun_angle.pan -270)-60)*0.5);
sky_mondschein.tilt = (((sun_angle.pan -270)-60)*0.5);
}
IF(sun_angle.pan >= 0) && (sun_angle.pan <= 15) {
sky_sonne.z = ((sun_angle.pan*(12373/15)-12373)/8);
}
sky_sonne.pan = sun_angle.pan;
sky_sonne.tilt = sun_angle.tilt;
//Himmelskörper, Sonne Nova:
sky_sonne_nova.x = sky_sonne.x;
sky_sonne_nova.y = sky_sonne.y;
sky_sonne_nova.z = sky_sonne.z;
sky_sonne_nova.pan = sky_sonne.pan;
sky_sonne_nova.tilt = sky_sonne.tilt;
//Himmelskörper, Mond:
sky_mond.x = sky_sonne.x-(sky_sonne.x*2);
sky_mondschein.x = sky_sonne.x-(sky_sonne.x*2);
sky_mond.y = sky_sonne.y-(sky_sonne.y*2);
sky_mondschein.y = sky_sonne.y-(sky_sonne.y*2);
sky_mond.z = sky_sonne.z-(sky_sonne.z*2);
sky_mondschein.z = sky_sonne.z-(sky_sonne.z*2);
sky_mond.pan = sky_sonne.pan;
sky_mondschein.pan = sky_sonne.pan;
//Sonne, Bildschirmhelligkeit:
vec_set (sun_pos1,sun_pos);
sun_pos1.z = sky_sonne.z-50;
//Uhrzeit, Minuten:
minutes = (sun_angle.pan * 4);
minutes %= 60;
IF (minutes >= 59.5) {
minutes = 0;
}
//Uhrzeit, Stunden:
IF (minutes < 0.2) {
hours = (sun_angle.pan/15)+7;
}
hours %= 24;
IF (hours >= 23.5) {
hours = 0;
}
wait(1);
}
}