|
Saving / Loading crashing game
#426836
07/30/13 15:11
07/30/13 15:11
|
Joined: Sep 2007
Posts: 173 USA, Florida
3dworld
OP
Member
|
OP
Member
Joined: Sep 2007
Posts: 173
USA, Florida
|
Hi Everyone; I'm trying to save and load my game using the F2 for save and F3 for load. Every time I press F2 it saves the game correctly but when I press F3 it just freezes. Any ideas welcome? This is my code:
function mySave()
{
if (inkey_active == 1) {return;}
if (players_health <= 0) {return;}
game_save("save01", 1, SV_ALL-SV_INFO);
file_for_screen("save01.png",01); // saves a screenshot to "shot01.png"
}
function myLoad()
{
if (game_load("save01",1) <= 0) {
slot1_txt.flags |= SHOW;
}
else{
slot1_txt.flags &= ~SHOW;
game_load("save01", 1);
}
}
Then in my main function:
void main()
{
video_mode = 10;
video_depth = 32; // 32 bit mode
video_screen = 1; // C-Script: start settings for Fullscreen*/
fps_max = 60;
level_load("level.wmb");
// Wait for 3 frames, until the level is loaded
on_f2 = mySave;
on_f3 = myLoad;
wait (3);
}
Thank you in advance. Any ideas welcome.
|
|
|
Re: Saving / Loading crashing game
[Re: rayp]
#426866
07/31/13 00:20
07/31/13 00:20
|
Joined: Sep 2007
Posts: 173 USA, Florida
3dworld
OP
Member
|
OP
Member
Joined: Sep 2007
Posts: 173
USA, Florida
|
That's a really good advice. My problem now is as follow: Let me put the code first and the the error: My save function now:
function Mysave()
{
//remove pp bloom effect
BloomChecker = 1;
Bloom();
if (inkey_active == 1) {return;}
if (players_health <= 0) {return;}
game_save("save", 1, SV_ALL);
//restart pp bloom
BloomChecker = 0;
Bloom();
}
My Load function:
function Myload()
{
if (game_load("save",1) <= 0) {
slot1_txt.flags |= SHOW;
}
else{
slot1_txt.flags &= ~SHOW;
game_load("save", 1);
BloomChecker = 0;
Bloom();
}
}
Then in my main function:
void main()
{
d3d_anisotropy = 2;
d3d_mipmapping = 4;
video_mode = 10;
video_depth = 32; // 32 bit mode
video_screen = 1; // C-Script: start settings for Fullscreen*/
fps_max = 60;
level_load("level.wmb");
shadow_offset = 2;
mouse_sync = 1;
mouse_mode = 0;
d3d_automaterial = 1+2; // automatically assign materials to textures and entities
shadow_stencil = 4; // activate z-fail stencil shadows
shadow_lod = 2; // use the second LOD stage for stencil shadows
stencil_blur(1); // activate blurred shadows (included in mtlView.c, look better)
on_f2 = save_progress;
on_f3 = load_progress;
//pp bloom effect
Bloom();
// Wait for 3 frames, until the level is loaded
wait (3);
}
I got no problems saving the game now and restarting the pp bloom effect, then after it finish loading the previous saved game it shows me this error, and a green square bitmap in the left hand side: Malfunction W1508 Can't load save01.SAVAny ideas. Thank you in advance.
|
|
|
Re: Saving / Loading crashing game
[Re: rayp]
#426934
07/31/13 14:02
07/31/13 14:02
|
Joined: Sep 2007
Posts: 173 USA, Florida
3dworld
OP
Member
|
OP
Member
Joined: Sep 2007
Posts: 173
USA, Florida
|
Yeap, the .SAV file saved into the directory of the working folder where of my project itself. I'm going to try the solution from Rayp and I let you know.
Thank you for your help.
No matter what people tell you, words and ideas can change the world.
|
|
|
Re: Saving / Loading crashing game
[Re: 3dworld]
#426938
07/31/13 14:19
07/31/13 14:19
|
Joined: Sep 2007
Posts: 173 USA, Florida
3dworld
OP
Member
|
OP
Member
Joined: Sep 2007
Posts: 173
USA, Florida
|
I've try the solution from Rayp and problem persist. The same error still displaying. If I take of the bloom effect everything works just fine but then I lost the effect any suggestions? Thanks in advance guys.
No matter what people tell you, words and ideas can change the world.
|
|
|
Re: Saving / Loading crashing game
[Re: 3dworld]
#426949
07/31/13 14:45
07/31/13 14:45
|
Joined: Sep 2007
Posts: 173 USA, Florida
3dworld
OP
Member
|
OP
Member
Joined: Sep 2007
Posts: 173
USA, Florida
|
OK, got it working. Here is the code, maybe this will help someone else: Basic save and load function:
var BloomChecker = 1;
function saving_game()
{
//disable pp bloom before saving
BloomChecker = 1;
Bloom();
if (inkey_active == 1) {return;}
if (players_health <= 0) {return;}
game_save("save", 1, SV_ALL-SV_INFO);
//enable pp bloom after saving
BloomChecker = 0;
Bloom();
}
function loading_game()
{
//disable pp bloom before loading
BloomChecker = 1;
Bloom();
//enable pp bloom after loading
game_load("save", 1);
BloomChecker = 0;
Bloom();
}
Main function:
void main()
{
video_mode = 10;
video_depth = 32;
video_screen = 2;
...................................................
level_load("level.wmb");
on_f2 = saving_game;
on_f3 = loading_game;
..................................................
wait (3);
//initializing bloom effect
while(BloomChecker!=0){
Bloom();
BloomChecker = 1;
wait(1);
}
}
Thank you for your help everyone. Enjoy
No matter what people tell you, words and ideas can change the world.
|
|
|
|