Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by Grant. 02/24/26 22:21
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (TipmyPip, clint000, Grant, chsmac85, Martin_HH), 5,858 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Save/load game troubles #110571
02/04/07 14:12
02/04/07 14:12
Joined: Oct 2005
Posts: 131
C
CBSection31 Offline OP
Member
CBSection31  Offline OP
Member
C

Joined: Oct 2005
Posts: 131
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.

Last edited by CBSection31; 02/04/07 14:19.
Re: Save/load game troubles [Re: CBSection31] #110572
02/04/07 18:15
02/04/07 18:15
Joined: Jan 2007
Posts: 651
Germany
R
RedPhoenix Offline
User
RedPhoenix  Offline
User
R

Joined: Jan 2007
Posts: 651
Germany
First I think you have to take "wait" commands between all saving and loading processes. You did between the level_load and the game_load, but I think you should also have one between the game_save and the level_load command.

Then there is something wrong with your save-and load process because you always use the same file. If you're saving autosave before changing your level then the old autosav will be overwritten and when loading it in the other level you will load the date from the old level. Solution: One save file for each level, and your level_changing function has to recognize from where to where you're changing the level. But don't save global vars! With them you have to transport your player's values from one to another level. Otherwise your player would be restored to the time when you left the level you are now entering to.

Re: Save/load game troubles [Re: RedPhoenix] #110573
02/04/07 20:53
02/04/07 20:53
Joined: Oct 2005
Posts: 131
C
CBSection31 Offline OP
Member
CBSection31  Offline OP
Member
C

Joined: Oct 2005
Posts: 131
I see what you are saying. I'll give this a try ASAP. Do you know of a way, then, of hiding these saves (if I do one per level) from the player as load options? I have a main menu screen where the player can load saved games, and I don't want all the separate level saves to be options.

Re: Save/load game troubles [Re: CBSection31] #110574
02/05/07 05:52
02/05/07 05:52
Joined: Aug 2003
Posts: 902
Van Buren, Ar
Gordon Offline
User
Gordon  Offline
User

Joined: Aug 2003
Posts: 902
Van Buren, Ar
I don't think this will do what you want. The "running functions" would be for entities in the first level and not the second level.

The second thing is that changing levels all global variables stay set. So the only thing you need to do is to save the state of the player in global variables then reload them after the level load into the new player entity.

For an example of this look into the template_6 directory for levels00.wdl

now for the second problem you can add a path to your file names.


Our new web site:Westmarch Studios
Re: Save/load game troubles [Re: Gordon] #110575
02/05/07 16:49
02/05/07 16:49
Joined: Oct 2005
Posts: 131
C
CBSection31 Offline OP
Member
CBSection31  Offline OP
Member
C

Joined: Oct 2005
Posts: 131
So the idea is to first use savedir"templevels" to create a separate folder for these saves. Then I create a separate saved game consisting of running functions for EVERY level. (Thus, there's be a level1.sav, level2.sav, etc.). I only reload that save when the player re-enters that specific level. When the player saves his game manually through the main menu, I use savedir again to switch to a second user save folder. I'll try this out today and report back here whether it works or not. Thanks for your help!!!

Re: Save/load game troubles [Re: CBSection31] #110576
02/05/07 18:39
02/05/07 18:39
Joined: Oct 2005
Posts: 131
C
CBSection31 Offline OP
Member
CBSection31  Offline OP
Member
C

Joined: Oct 2005
Posts: 131
Okay, I've managed to get this portion of the code working. I have a new problem now, but I think it's unrelated, and so I am starting a new thread for it. Thanks again!

Last edited by CBSection31; 02/05/07 23:18.

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1