game_load

Posted By: Ruben

game_load - 07/10/15 05:20

For some reason, my "LOAD GAME" button in the beginning of the game (to load a saved game) keeps giving me a pop-up error when I click on it, as shown:

Code:
Error E1513
Script crash in buttonLoadGame:
OK             Cancel



My game_load() function (to load a saved game) is inside the buttonLoadGame() function as shown at the bottom of the code below (game_save code is also shown below):

Code:
...

BMAP *bmpLoadButton_on = "loadGame_button_click.pcx";
BMAP *bmpLoadButton_off = "loadGame_button.pcx";
BMAP *bmpLoadButton_over = "loadGame_button_hover.pcx";

BMAP *bmpNewGameButton_on = "newGame_button_click.pcx";
BMAP *bmpNewGameButton_off = "newGame_button.pcx";
BMAP *bmpNewGameButton_over = "newGame_button_hover.pcx";

...

PANEL* beginGameButtons =
{
   layer = 1;

   button(55, 215, bmpNewGameButton_on, bmpNewGameButton_off, 
      bmpNewGameButton_over, buttonNewGame, NULL, NULL); // "NEW GAME" BUTTON 

   button(675, 215, bmpLoadButton_on, bmpLoadButton_off, 
      bmpLoadButton_over, buttonLoadGame, NULL, NULL); // "LOAD GAME" BUTTON
}

PANEL* endGameButtons =
{
   layer = 1;
	
   button(540, 510, bmpQuitSaveYes_on, bmpQuitSaveYes_off, 
      bmpQuitSaveYes_over, buttonSaveGameQuit, NULL, NULL); // "SAVE AND QUIT" BUTTON
	       
   button(600, 510, bmpQuitSaveNo_on, bmpQuitSaveNo_off, 
      bmpQuitSaveNo_over, buttonNoSaveGameQuit, NULL,
      NULL); // "NO SAVE AND QUIT" BUTTON
}

...

function endGame()
{
   ...

   set(endGameButtons, SHOW); // SHOWS BUTTONS TO END GAME BY
                              //    SAVING OR NOT SAVING

   ...
}

function buttonSaveGameQuit() // "SAVE AND QUIT" BUTTON FUNCTION
{
   result = game_save("test",7,SV_ALL-SV_LEVEL);
      // IF I HAVE "SV_ALL" ONLY, I GET ERROR UNLESS I SUBTRACT
      //    SV_LEVEL FROM IT.
	
   if (result <= 0) { error("Save Error!"); }
	
   sys_exit("123"); 	
}

function buttonNoSaveGameQuit() // "NO SAVE AND QUIT" BUTTON
{
   sys_exit("123"); // EXITS GAME WITHOUT SAVING
}

...

action player_code()
{
   ...

   on_q = endGame; // CLICKING "q" KEY ENDS THE GAME BY GIVING 
                   //    YOU THE OPTION TO "SAVE AND QUIT" OR 
                   //    "NO SAVE AND QUIT".

   ...
}

...

function buttonLoadGame() // GIVING THE ERROR
                          // BUTTON THAT LOADS SAVED GAME
{
   if(game_load("test", 7) > 0) // GIVING POP-UP ERROR
   {
      beep();
   }
   else
   {
      beep();
   }
}

...



If I press the NEW GAME button at the beginning of the game, the program will start a new game just fine.

When I try clicking the LOAD GAME button, I get the pop-up error shown above. Also, none of the beeps are sounding in the buttonLoadGame() function. I just get the pop-up error.

Am I doing something wrong in trying to load the saved game ("test7.SAV" to be more specific)? I thought it seemed pretty clear cut, but maybe not.
Posted By: Logitek

Re: game_load - 07/10/15 07:01

Is savegame number 7 in the savegame folder available?
Do you have specified a savedir folder?
*)But both should make no problems. There would be a beep.

First I thought it is maybe only the savegame. The error message 1513: missing entity, try to use an empty pointer, or a DEP (data execution prevention) problem, or a damaged sound, model or image.

I think it is a missing entity or something like that, because you have saved the game without Levels. So all the entitys are not saved, but you load the savegame with the actions for that missing entity.
Posted By: Ruben

Re: game_load - 07/10/15 08:08

What I find odd is that lets say I start a new game, and lose some health from 500 down to 320. I will then press the "q" key, and the game will ask me if I want to "save and quit" or "not save and quit". I click the button to "save and quit".

I then start the game over, and when the "NEW GAME" and "LOAD GAME" buttons show up, I click the "LOAD GAME" button, but I get the pop-up error mentioned above. However, I am still on the screen with the "NEW GAME" and "LOAD GAME" buttons, so I decide to click the "NEW GAME" button. The game starts up, and I now have 320 health like I had when I saved my game.

However, when I press the "i" key to bring up my inventory bag, the inventory bag does not display at all, like it normally does. For example:

Code:
player_code()
{
   ...

   on_i = toggleInventory; // WORKS ORIGINALLY, BUT NOT AFTER STARTING A "NEW 
                           //    GAME" BY CLICKING THE "NEW GAME" BUTTON, AFTER 
                           //    UNSUCCESSFULLY TRYING TO LOAD MY LAST SAVE 
                           //    USING THE "LOAD GAME" BUTTON.

   ...
}



In other words, when I start a new game by clicking the "NEW GAME" button, toggling my inventory bag by pressing "i" works. When I save my game, and try to renter the game by restarting it, and click the "LOAD GAME" button to load my last save, I get the pop-up error.

However, I am still on the original page with the "NEW GAME" and "LOAD GAME" buttons. I therefore click the "NEW GAME" button, and my game launches, and even shows the health I had when I last saved my game. However, I am now not able to toggle my inventory bag by pressing the "i" key. Strange...
Posted By: Logitek

Re: game_load - 07/10/15 09:27

Originally Posted By: Ruben


I then start the game over, and when the "NEW GAME" and "LOAD GAME" buttons show up, I click the "LOAD GAME" button, but I get the pop-up error mentioned above. However, I am still on the screen with the "NEW GAME" and "LOAD GAME" buttons, so I decide to click the "NEW GAME" button. The game starts up, and I now have 320 health like I had when I saved my game.


Because of the problem I have written in my first post.
The game is loaded, all the variables I think, BUT not the entity that is missing. So you got the error message.

And if you start then a new game, the health variable is already changed to the saved one, because you have loaded the savegame file. It is only not completely, because "levels" is missing in the save game file.

The health does not change to the original value of 500 because I am sure you have declared it with "500" before you start a new game. Not in the part after you have pressed "Start new game". So it keeps the value from the savegame you have loaded. Also if the savegame gives you an error.
Posted By: Ruben

Re: game_load - 07/10/15 09:51

I am leaving out the SV_LEVEL flag of game_save() because it is the only flag that I get an error with using game_save(). I would like to keep the SV_LEVEL though if I could. Do you know of any way that I can use the SV_LEVEL flag in the game_save() function (use SV_ALL flag only) without it giving a pop-up error?
Posted By: Ch40zzC0d3r

Re: game_load - 07/10/15 10:21

Save the string of the level and load it manually with level_load? ..
Posted By: Logitek

Re: game_load - 07/10/15 11:15

I personally use SV_ALL-SV_INFO

What is the error message you get if you use it with LEVELS?
I have not seen it in your post. Only for loading.
Posted By: Ruben

Re: game_load - 07/11/15 02:54

Originally Posted By: Logitek
I personally use SV_ALL-SV_INFO

What is the error message you get if you use it with LEVELS?
I have not seen it in your post. Only for loading.

I get a pop-up error box stating:

Code:
Error E1513
Script crash in buttonSaveGameQuit:
OK                   Cancel


...when I press the "q" key, and press the "SAVE" button, with the code below.

Code:
...

function buttonSaveGameQuit()
{
   result = game_save("test",7,SV_ALL-SV_INFO); // SV_LEVEL GIVES ERROR
   if (result <= 0) { error("Save Error!"); }

   sys_exit("123"); 	
}

function buttonNoSaveGameQuit()
{
   sys_exit("123"); 
}

...

Posted By: Ruben

Re: game_load - 07/11/15 03:22

Originally Posted By: Ch40zzC0d3r
Save the string of the level and load it manually with level_load? ..

I am sorry, but I am rather new to the whole level_save and level_load.

How would I save the string of a level?
Posted By: Logitek

Re: game_load - 07/11/15 07:18

I know, it is a stupid question, but is it possible that you kill the level before you save it?

I mean, do you unload the level? If yes, then he can not save the level.
There must be any kind of error in the script. Otherwise it makes no sense.

Have you checked if the savegame is in the folder? With and without levels-option.

Which OS do you use? And in which folder do you write? I mean, is it in the program folder? or anywhere else? Because of rights.

What kind of level has the game?
You can try to make a simple level with wed and start it instead of your level and try to save it with your script. I think it will work, because I don't see a problem with the lines you have posted.
Posted By: Ruben

Re: game_load - 07/11/15 08:13

Originally Posted By: Logitek

Have you checked if the savegame is in the folder? With and without levels-option.

Which OS do you use? And in which folder do you write? I mean, is it in the program folder? or anywhere else? Because of rights.

What kind of level has the game?
You can try to make a simple level with wed and start it instead of your level and try to save it with your script. I think it will work, because I don't see a problem with the lines you have posted.



Without subtracting SV_LEVELS from SV_ALL, no savegame shows up in the folder. With subtracting SV_LEVELS from SV_ALL, a savegame does show up in the folder.

I use Windows 7, 32 bit.

I am not specifying which folder to write the save_game to. The savegame file shows up in the same folder as my main script file and other SED files used.

What do you mean by "kind of level"? I have multiple WED files associated with this game, to save memory. If the player walks into a door in a particular room for instance (door using EVENT_IMPACT), a new WED file will be loaded to represent the area on the other side of the door.
Posted By: Logitek

Re: game_load - 07/11/15 08:58

By "kind of level" I meant: Is it a wed designed level or an empty level with script placed models in the level. But this question is already answered.

Have you tried to make a new simple wed level, only for testing, and test your save option with levels? Only a small level with one or two models. I am sure it will be saved. If not, then there is a problem with a model, or with the script itself anywhere.
Posted By: Ruben

Re: game_load - 07/11/15 12:16

I have a WED level with script placed models in the level.

I will try your suggestion. Thank you.
Posted By: Ruben

Re: game_load - 07/13/15 07:10

I found a rule in the manual for game_save that "levels, scripts, and objects must not change between game_save and game_load, with exception of level entities. All .._create and .._remove functions, except for creating and removing level entities, must be executed before the first game_save or game_load call. Thus, the number of engine objects like panels or texts must be the same at save and load time. When the script was changed in any way, or when the number of objects is different, game_load will fail."

I am trying to have everything execute before the game_save and game_load commands. Basically, when I play a game and save, and then quit and reload the game, and click the LOAD GAME button, I get this pop-up error:

Code:
E1513
Script crash in buttonLoadGame:
OK              Cancel



My buttonLoadGame() function code looks like this:

Code:
...

function buttonLoadGame()
{
        reset(introBackgroundImage, SHOW); // SHOWS JPEG AS SCREENSHOT
	reset(Arulia_Title, SHOW); // SHOWS TITLE OF GAME
	reset(beginGameButtons, SHOW); // SHOWS "NEW GAME" AND "LOAD GAME"
                                       //    BUTTONS
	snd_stop ( songHandle); // STOPS THE INTRO SONG

        beep();  // THIS BEEP DOES SOUND OFF.

	if (game_load("test",7) > 0) // TRIES TO LOAD THE GAME
 	{ 
		beep(); // THIS BEEP DOES NOT SOUND OFF.
	}
	else
	{
		//beep(); // THIS BEEP DOES NOT SOUND OFF.
	} 
	
        beep(); // THIS BEEP DOES NOT SOUND OFF.

	change_mouse_mode();
}

...



So, the last beep that sounds off is just before the game_load instruction. This seems to tell me that there is something wrong going on with game_load.

Once I click OK on the pop-up error mentioned before, the screen will look black, except the player's health (at the time of the last save) shows up on the screen.

I thought I minimized, transferred, or eliminated all the code from taking place between the game_save and game_load instructions or after them, as shown here:

Code:
// START OF MAIN SCRIPT FILE

...

#include "end_game.c"				 
		 
#include "gameStart_buttons.c" 

#include "mainProgram.c" 

// END OF MAIN SCRIPT FILE

...

// LAST FUNCTION IN endGame.c

function buttonSaveGameQuit()
{
	result = game_save("test",7,SV_ALL-SV_LEVEL); // SV_LEVEL GIVES ERROR
	if (result <= 0) { error("Save Error!"); }
	
	sys_exit("123"); 	
}

...

// LAST FUNCTION IN gameStart_buttons.c

function buttonLoadGame()
{
	reset(introBackgroundImage, SHOW);
	reset(Arulia_Title, SHOW);
	reset(beginGameButtons, SHOW);
	snd_stop ( songHandle);

	beep(); // THIS IS BEEPING

        if (game_load("test",7) > 0) 
	{ 
		beep(); // THIS IS NOT BEEPING
	}
	else
	{
		beep(); // THIS IS NOT BEEPING
	} 
     
        beep(); // THIS IS NOT BEEPING

	change_mouse_mode();
}

...

function main()
{
   ...

   set(introBackgroundImage, SHOW);
   set(Arulia_Title, SHOW);
   set(beginGameButtons, SHOW); // DISPLAYS "NEW GAME" AND "LOAD GAME" BUTTONS.

   while(1)
   {
   	if ( active_weapon != NULL )
   		active_weapon->pan += 5*time_step;
   		
   	mouse_pos.x = mouse_cursor.x;
        mouse_pos.y = mouse_cursor.y;
      
        // if we've enabled the mouse:
        if(mouse_mode > 0)
        {
      	  // move it's position with a cursor:
      	  vec_set(mouse_pos.x, mouse_cursor.x);
      	
        }
   		
   	wait(1);
     }
	
     sys_exit ( NULL );

     // END OF ALL MY GAME PROGRAMS AND FILES.
}



Even though I pushed the game_save and game_load functions as far down as I could in the main script file, I am still bugs mentioned above.

Anybody have a clue why?
Posted By: Wjbender

Re: game_load - 07/14/15 13:01

its quite simple , make a complete copy of your project , edit the copied project , remove everything one by one untill your left with the minimalistic size of the project where the bug is stil reproduced , upload your project , give us a download link ..

anything other than that is spitting in the wind.
Posted By: EpsiloN

Re: game_load - 07/14/15 21:26

Yes, the best thing you can do is strip down your project until the bug disappears. This way you will know what EXACTLY is causing it.
(!First make a copy!)

And by the way, pushing functions down in a file doesnt change the order they get executed.
Its the place where you're calling the function that matters. And its probably in a while loop or attached to a button. This way, you can never know when the function will get executed, because the user has to click somewhere to do it...

Just strip down everything piece by piece, start with commenting function calls and features of your project, and see where the bug disappears. Its a lot of work, but you have to be prepared to do it in order to move forward with your current project.
Posted By: Ruben

Re: game_load - 07/25/15 01:26

So, I found out what was causing the pop-up error with game_save(). I had this code in my player_code:

Code:
action player_code()
{
   ...

   my.shadow = 1; // THIS CAUSED THE game_save SCRIPT CRASH

   ...
}




The "my.shadow = 1" code caused the script crash when I used the SV_ALL flag for game_save, as shown below:

Code:
game_save("test", 7, SV_ALL);



Now that I commented "my.shadow = 1" code out, I am no longer getting a pop-up error when I game_save using only the SV_ALL flag.

Now however, I am getting some new errors, particularly when I have entities in my level that use the ent_movepath() command to travel a preset route. After saving the game (seemingly successfully), restarting the game, and pressing the LOAD GAME button, I get a pop-up error that states:

Code:
Malfunction W1508
Can't load test7.SAV
OK          Cancel



Once I click OK on this pop-up bug, another pop-up bug comes up saying:

Code:
Error E1515
Invalid function arguments in ent_placefloor
OK                   Cancel



When I press OK on this bug, I get another bug that immediately pops up as shown:

Code:
Error E1515
Invalid function arguments in ent_movepath
OK               Cancel



When I click OK on this pop-up bug, the first "ent_placefloor" error repeats itself, and these two pop-up bugs (mentioned above) alternatively repeat themselves over and over forever when I keep clicking the OK button.

Every time I click OK on these pop-up bugs, everything in the level, like moving entities, move a tiny increment in their movement pattern, in between every bug that I press the OK button on.

I only get these two pop-up bugs when an entity is using the ent_movepath() command, in the level that I save the game in. If I comment out the ent_movepath() command from whatever entity in the level is using it, the load seems to work fine.

As of now, I have a knight and ogre in my level that use the ent_movepath() command. Here are their code:

Code:
action ogre_action()
{
	
   ...

	
   if(ogre_dead == 0)
   {
      ent_movepath(me, "path_003", 2, 1+2); // IF I COMMENT 
         //    THIS OUT, THE game_load LOADS FINE.
   }
	
   ...
}	

action knight_action() 
{
   ...
	
   if(knight_dead == 0)
   {
      my.STATE = 1;
      ent_movepath(me, "path_003", 2, 1+2); // IF I COMMENT
         //    THIS OUT, THE game_load WORKS FINE.
   }
   if(knight_dead == 1)
   {
      my.STATE = 4;
      ent_movepath(me, NULL, NULL, NULL); // IF I COMMENT
         //    THIS OUT, THE game_load WORKS FINE.
   }
	
   while (1)
   { 
      knight_loc();
      knight_health();

      // state 1: wait until player comes close enough ////// 
      if(my.STATE == 1) 
      {
         my.tilt = 0;
         my.z = -544;
			
         my.ANIMATION += 3*time_step;
			
         ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
			
         // detect all FLAG2 entities within 750 
         //    quants 	
		
         c_scan(my.x,my.pan,vector(360,0,750),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);
			
         if (you) // player detected?
         {  
            my.tilt = 0;
	    my.z = -544;
				
	    ent_movepath(my,NULL,0,0); // IF I COMMENT
               //    THIS OUT, THE game_load WORKS FINE.
	    snd_stop ( songHandle );
	    songHandle = snd_loop ( sndObBtl, 80, 0 );
			
	    my.STATE = 2; 
	    enemy = your.CREATOR;
	 }				
      }
	
      ...
   }
}		

void temple_ogre()
{
	if(ogre_dead == 0)
	{
		ogre = ent_create ( "ogre.mdl", vector(-693,-36,-567), ogre_action );
   
		...

                // CREATES PATH THAT OGRE WALKS ON.
	
		path_create(ogre, 3, 3);
		path_setnode(ogre, 1, vector(-692, -36, -567), NULL);
		path_setnode(ogre, 2, vector(-269, -140, -567), NULL);
		path_setnode(ogre, 3, vector(-773, 739, -567), NULL);
	 
		vec_set(ogre.min_x,vector(-9,-9,0)); // set bounding box to individual values
		vec_set(ogre.max_x,vector(9,9,75));
	}	
	else if(ogre_dead == 1)
	{
		ogre = ent_create ( "ogre.mdl", vector(ogre_x_loc,ogre_y_loc,ogre_z_loc), ogre_action );
		ogre.scale_x = 0.23; // TEMPLE LEVEL OGRE SCALE
		ogre.scale_y = 0.23;
		ogre.scale_z = 0.23;
	}
}

void temple_knight()
{
	if(knight_dead == 0)
	{
	
		knight = ent_create ( "a_knight.mdl", vector(-879,-1744,-550), knight_action );

                // CREATES PATH THAT KNIGHT WALKS ON.

		path_create(knight, 3, 3);
		path_setnode(knight, 1, vector(-1061, -1335, -567), NULL);
		path_setnode(knight, 2, vector(-1224, -177, -567), NULL);
		path_setnode(knight, 3, vector(-1964, -304, -567), NULL);
	
		vec_set(knight.min_x,vector(-9,-9,-25)); // set bounding box to individual values
		vec_set(knight.max_x,vector(9,9,35));
	}
	else if(knight_dead == 1)
	{
		knight = ent_create ( "a_knight.mdl", vector(knight_x_loc,knight_y_loc,knight_z_loc), knight_action );
	}
	
}

function to_STemple_door_f() // ENTERING THE SOUTH DOOR OF TEMPLE ROOM
{
	if(event_type == EVENT_IMPACT) // TOUCHING THE DOOR THAT LEADS INTO
                                       //    SOUTH ENTRANCE OF TEMPLE ROOM
                                       //    LOADS CODE BELOW.
	{
		...
		
                temple_knight();
                temple_ogre();
     
                ...
      
	}
}



Can a game be saved when an entity in the level being saved in uses the ent_movepath() function to travel a certain route?
Posted By: Ruben

Re: game_load - 07/27/15 01:43

Maybe this is a more easily understandable message of my situation:

I am able to save my game using game_save(). I can even successfully load the game I saved using game_load. However, if I saved a game while the player was in the same level as an entity that uses ent_movepath() to move along a certain path by default, I get errors when I try to load the game I saved, as shown:

Code:
Malfunction W1508
Can't load test7.SAV
OK          Cancel



Once I click OK on this pop-up bug, another pop-up bug immediately comes up saying:

Code:
Error E1515
Invalid function arguments in ent_placefloor
OK                   Cancel



When I press OK on this bug, I get another bug that immediately pops up as shown:

Code:
Error E1515
Invalid function arguments in ent_movepath
OK               Cancel



The two bugs above repeat themselves back and forth infinitely, every time I click their OK buttons.

When I comment out the ent_movepath() function calls for the entities in the level, I do not get the above bugs anymore when saving and loading the game in that level. I am able to save and load the game just fine.

Has anyone else come across this situation? Can the game be saved in a level containing an entity that uses the ent_movepath() function to move along a certain route by default?
Posted By: Logitek

Re: game_load - 07/27/15 07:22

W1508 means: You load a savegame that has nothing to do with your current script. for example: from other games laugh I think that is not true laugh

E1515: I think you have a problem with a null pointer. Maybe you have changed anything between save_game and load_game.

Try to save your game. Then kill the current level and load an empty level with level_load(""); And then try to load the game. Normally it should work. Otherwise there is anywhere an error.
Posted By: Logitek

Re: game_load - 07/27/15 07:24

Try to load your savegame also after start. And also after you have saved a game. Look if all the error messages are the same.
© 2024 lite-C Forums