2 registered members (AndrewAMD, VoroneTZ),
779
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
game_load
#453168
07/10/15 05:20
07/10/15 05:20
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
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:
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):
...
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.
Last edited by Ruben; 07/10/15 05:40.
|
|
|
Re: game_load
[Re: Logitek]
#453171
07/10/15 08:08
07/10/15 08:08
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
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:
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...
|
|
|
Re: game_load
[Re: Ruben]
#453172
07/10/15 09:27
07/10/15 09:27
|
Joined: Nov 2009
Posts: 201
Logitek
Member
|
Member
Joined: Nov 2009
Posts: 201
|
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.
|
|
|
Re: game_load
[Re: Logitek]
#453189
07/11/15 02:54
07/11/15 02:54
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
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:
Error E1513
Script crash in buttonSaveGameQuit:
OK Cancel
...when I press the "q" key, and press the "SAVE" button, with the code below.
...
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");
}
...
Last edited by Ruben; 07/11/15 03:20.
|
|
|
Re: game_load
[Re: Ch40zzC0d3r]
#453191
07/11/15 03:22
07/11/15 03:22
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
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?
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|