All I did was combine some functions and rearrange until everything worked the way I did before and when I was done I found that the error had disappeared. If it helps, here is my code, its long though.
Code:
string senior_product_wmb = <senior_product.wmb>;
string safelevel_wmb = <safelevel.wmb>;
/////////////////////////////////////////////////////////////////////////
var game_started = 0; // will be set to 1 when the game is started
var sound_vol = 70; // default sound value at game start; sound_vol is an engine variable
var video_value = 7; // default resolution at game start (800x600)
//////////////////////////////////////////////////////////////////////////
bmap main_bmp = <main.bmp>;
bmap new_bmp = <new.bmp>;
bmap new1_bmp = <new1.bmp>;
bmap exit_bmp = <exit.bmp>;
bmap exit1_bmp = <exit1.bmp>;
bmap sound1_pcx = <sound1.pcx>;
bmap sound2_pcx = <sound2.pcx>;
bmap video1_pcx = <video1.pcx>;
bmap video2_pcx = <video2.pcx>;
bmap cursor_bmp = <cursor.bmp>;
bmap sound_pcx = <sound.pcx>; // sound volume panel
bmap video_pcx = <video.pcx>; // video resolution panel
bmap slider_pcx = <slider.pcx>;
//////////////////////////////////////////////////////////////////////////
sound mouse_snd = <mousesnd.wav>;
//////////////////////////////////////////////////////////////////////////
function game_init();
function mouse_over();
function mainmenu_mouse();
function start_game();
function set_volume();
function set_resolution();
function quit_game();
///////////////////////////////////////////////////////////////////////////
panel main_pan // main panel
{
bmap = main_bmp;
layer = 20;
pos_x = 220; // for now
pos_y = 200; // for now
button = 50, 65, new_bmp, new_bmp, new1_bmp, null, start_game, mouse_over;
button = 50, 115, sound1_pcx, sound1_pcx, sound2_pcx, null, set_volume, mouse_over;
button = 50, 165, video1_pcx, video1_pcx, video2_pcx, null, set_resolution, mouse_over;
button = 50, 215, exit_bmp, exit_bmp, exit1_bmp, null, quit_game, mouse_over;
flags = d3d, overlay, refresh;
}
panel sound_pan // sound panel
{
bmap = sound_pcx;
layer = 20;
pos_x = 160; // for now
pos_y = 240; // for now
hslider = 60, 95, 200, slider_pcx, 0, 100, sound_vol;
flags = d3d, overlay, refresh;
}
panel video_pan // video resolution panel
{
bmap = video_pcx;
layer = 20;
pos_x = 160; // for now
pos_y = 240; // for now
hslider = 60, 95, 200, slider_pcx, 4, 8, video_value;
flags = d3d, overlay, refresh;
}
/////////////////////////////////////////////////////////////////////////
function main()
{
// set some common flags and variables
// warn_level = 2; // announce bad texture sizes and bad wdl code
tex_share = on; // map entities share their textures
// center the splash screen for non-640x480 resolutions, and display it
splashscreen.pos_x = (screen_size.x - bmap_width(splashmap))/2;
splashscreen.pos_y = (screen_size.y - bmap_height(splashmap))/2;
splashscreen.visible = on;
// wait 3 frames (for triple buffering) until it is flipped to the foreground
wait(1);
// now load the level
level_load(level_str);
// freeze the game
freeze_mode = 1;
// wait the required second, then switch the splashscreen off.
sleep(1);
splashscreen.visible = off;
bmap_purge(splashmap); // remove splashscreen from video memory
// load some global variables, like sound volume
load_status();
// display the initial message
msg_show(mission_str,10);
// initialize lens flares when edition supports flares
ifdef CAPS_FLARE;
lensflare_start();
endif;
// use the new 3rd person camera
move_view_cap = 1;
// un-freeze the game
freeze_mode = 0;
// client_move(); // for a possible multiplayer game
// call further functions here...
random_tunes();
on_esc = null;
level_load (safelevel_wmb);
wait (2);
game_init(); // checks the Esc key state and changes the panels if needed
main_pan.visible = on; // show the main panel
mainmenu_mouse(); // and give me a cursor to play with
vec_set (camera.pos, nullvector); // move camera to the origin
while (game_started == 0) // we haven't pressed New yet
{
camera.pan += 0.3 * time; // rotate the camera gently
camera.tilt += 0.1 * time;
camera.roll += 0.05 * time;
wait (1);
}
}
/////////////////////////////////////////////////////////////////
// The following definitions are for the pro edition window composer
// to define the start and exit window of the application.
WINDOW WINSTART
{
TITLE "3D GameStudio";
SIZE 480,320;
MODE IMAGE; //STANDARD;
BG_COLOR RGB(240,240,240);
FRAME FTYP1,0,0,480,320;
// BUTTON BUTTON_START,SYS_DEFAULT,"Start",400,288,72,24;
BUTTON BUTTON_QUIT,SYS_DEFAULT,"Abort",400,288,72,24;
TEXT_STDOUT "Arial",RGB(0,0,0),10,10,460,280;
}
/* no exit window at all..
WINDOW WINEND
{
TITLE "Finished";
SIZE 540,320;
MODE STANDARD;
BG_COLOR RGB(0,0,0);
TEXT_STDOUT "",RGB(255,40,40),10,20,520,270;
SET FONT "",RGB(0,255,255);
TEXT "Any key to exit",10,270;
}*/
/////////////////////////////////////////////////////////////////
//INCLUDE <debug.wdl>;
//////////////////////////////////////////////////////////////////////////
action eye_checker // attached to the sprite
{
my.oriented = on;
}
function mouse_over() // is executed when we are over the menu buttons
{
play_sound (mouse_snd, 70);
}
function mainmenu_mouse ()
{
mouse_mode = 2;
mouse_map = cursor_bmp;
while (game_started == 0)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
wait (1);
}
}
function start_game()
{
main_pan.visible = off;
game_started = 1;
mouse_mode = 0;
level_load (senior_product_wmb);
wait (2);
camera.z = 220;
camera.tilt = -90;
}
function set_volume() // shows the sound panel
{
main_pan.visible = off;
sound_pan.visible = on;
}
function set_resolution() // shows the video panel
{
main_pan.visible = off;
video_pan.visible = on;
}
function quit_game()
{
exit;
}
function game_init() // checks the Esc state and changes the panels accordingly
{
while (1)
{
// first of all, calculate pos_x and pos_y for all the panels
// to make sure that they are centered at any resolution
main_pan.pos_x = (screen_size.x - bmap_width(main_bmp)) / 2;
main_pan.pos_y = (screen_size.y - bmap_height(main_bmp)) / 2;
sound_pan.pos_x = (screen_size.x - bmap_width(sound_pcx)) / 2;
sound_pan.pos_y = (screen_size.y - bmap_height(sound_pcx)) / 2;
video_pan.pos_x = (screen_size.x - bmap_width(video_pcx)) / 2;
video_pan.pos_y = (screen_size.y - bmap_height(video_pcx)) / 2;
if (key_esc == 1)
{
while (key_esc == 1) {wait (1);} // wait for release
if (main_pan.visible == on)
{
freeze_mode = 0; //let the player and everything move again
main_pan.visible = off;
mouse_mode = 0; // hide the cursor
}
else // main_pan isn't visible
{
freeze_mode = 1; //you just about turned on the menu, freeze the game
if (sound_pan.visible == off && video_pan.visible == off)
{
main_pan.visible = on;
game_started = 0; // stop the game
mainmenu_mouse(); // show the cursor
}
}
if (sound_pan.visible == on)
{
sound_pan.visible = off;
main_pan.visible = on;
}
if (video_pan.visible == on)
{
video_pan.visible = off;
main_pan.visible = on;
if (int (video_value != video_mode)) // resolution has changed
{
switch_video (video_value, 16, 1);
}
}
}
wait (1);
}
}