Hi everyone,
On the game I am working on, I have set it up so the player can travel back and forth between multiple levels. In each level are entities that have unique values set to my.skill. I want to store these values even after the player has gone to another level, so that when the player returns, the values are restored.
For instance, in level A is a lightswitch. When the player clicks on it, my.skill1=1. The player then goes to level B. Later, when the player returns to level A, I want the lightswitch to automatically have my.skill1 set to 1.
I assume that using game_save and game_load is the only way to do this, correct? I am encountering a problem, though. The game gets an error message when I save before the level transition and load after the new level has loaded. I assume this is because not every entity in level A is in level B, and vice versa.
My code, if it helps:
Code:
function changelevel
{
wait (1);
my=null;
vec_set(temp_player_data,player.x);
vec_set(temp_player_ang,player.pan);
game_save("autosave",0,sv_functions);
freeze_mode=1;
if (level_to_load==1)
{
level_to_load=0;
loading_panel.pos_x = (screen_size.x - bmap_width(loading_pic))/2;
loading_panel.pos_y = (screen_size.y - bmap_height(loading_pic))/2;
loading_panel.visible=on;
camera.visible=off;
level_load("PrisonEastWing.wmb");
freeze_mode=0;
wait(10);
game_load("autosave",0);
camera.visible=on;
loading_panel.visible=off;
islevelloading=0;
player.x=temp_play_data[0]+648;
player.y=temp_play_data[1]+1506;
vec_set(player.pan,temp_play_ang);
}
}
I am using sv_functions only, because for some reason the game crashes when I use sv_all or sv_level, even though the save game code is at the end of my script.
As you can probably tell by my code, I'm new at all this, so I may be missing something simple. Any help would be greatly appreciated! Thanks in advance for your time.
