I texured the skycube with "skywhite" from the standard wad file and compiled it. Running the script below works with the pan and tilt functions. I see the sky. However changing the brightness via the functions bright_lights() and dim_lights() still gives that irritating error message "empty pointer in bright_lights()...".
Basically, these two functions should work, since I defined the skycube as "sky" within WED. Therefore the sky_cube_level pointer should be defined and not NULL. I don't get it.

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

var video_mode = 7; // 800x600 pixels
var video_depth=32;

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

function bright_lights()
{
sky_cube_level.blue += 10;
sky_cube_level.green += 10;
sky_cube_level.red += 10;
}

function dim_lights()
{
sky_cube_level.blue -= 10;
sky_cube_level.green -= 10;
sky_cube_level.red -= 10;
}

function main()
{

level_load ("work13.wmb");



while (1)
{
on_1 = bright_lights;
on_2 = dim_lights;
if (key_w == ON)
{
camera.tilt += 1;
}
if (key_s == ON)
{
camera.tilt -= 1;
}
if (key_a == ON)
{
camera.pan += 1;
}
if (key_d == ON)
{
camera.pan -= 1;
}
if (key_lastpressed == 19) // if [R] is pressed
{
camera.pan = 0;
camera.tilt = 0;
sky_cube_level.blue = 128; // medium brightness
sky_cube_level.green = 128;
sky_cube_level.red = 128;
}
wait (1);
}
}