Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 683 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Game saving/loading stuff #425810
07/11/13 10:19
07/11/13 10:19
Joined: Jul 2013
Posts: 66
Don't have a one...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

Joined: Jul 2013
Posts: 66
Don't have a one...
Hi ,guys!

This is my first thread and I have been dealing with 3DGS and Lite-C for a couple of months ,so I am not a 100% newbie....

I am having an issue concerned with game saving/loading system of Lite-C:

When I wanted to attach a game saving/loading system to my project ,simply it didn't work. Every time I try to load my previously saved game (I used SV_ALL flag for it) ,the engine shows me an error message "can't load ....". When I looked that up in the Troubleshooting section of the manual ,I was surprised. It said that when I save a game and then the engine objects change ,that saved game can't be loaded. Does this mean that if I saved a game ,then closed the application and wanted to open it again later ,I wouldn't be able to load that game?

I'd be grateful if anyone could tell me how to overcome this problem and what advice I should take care of when I deal with game saving/loading.

Thank you for reading

Re: Game saving/loading stuff [Re: DonaldThief] #425822
07/11/13 11:53
07/11/13 11:53
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
If you use any _create function except ent_create (so if you create panels at runtime or something like that) you sadly cannot use game_save.

What kind of game are you working on, what type of levels do you have? Oftentimes it's just better to write your own save and load system.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Game saving/loading stuff [Re: Superku] #425855
07/11/13 18:59
07/11/13 18:59
Joined: Jul 2013
Posts: 66
Don't have a one...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

Joined: Jul 2013
Posts: 66
Don't have a one...
Originally Posted By: Superku
If you use any _create function except ent_create (so if you create panels at runtime or something like that) you sadly cannot use game_save.


All what I use is "ent_create" and "ent_createlayer". But, I'm sure they're not the problem

Originally Posted By: Superku

What kind of game are you working on, what type of levels do you have?


I am working on a normal 3rd person shooter game. Concerning the levels ,I don't know what you mean

Originally Posted By: Superku
Oftentimes it's just better to write your own save and load system.


I think that will be a little bit difficult but how to do it?

Re: Game saving/loading stuff [Re: DonaldThief] #425862
07/11/13 20:24
07/11/13 20:24
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
All what I use is "ent_create" and "ent_createlayer". But, I'm sure they're not the problem

How can you be so sure about that? The ent_createlayer calls are most likely the problem as you can see here:

Originally Posted By: Manual, game_save
All .._create and .._remove functions, except for creating and removing level entities, must be executed before the first game_save or game_load call.

Concerning the levels, I meant if you have checkpoints/ save stations like in Metroid or only want to save after a completed level/ mission, then it will be notably easier to implement (using file_ instructions).


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Game saving/loading stuff [Re: Superku] #425871
07/12/13 03:56
07/12/13 03:56
Joined: Jul 2013
Posts: 66
Don't have a one...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

Joined: Jul 2013
Posts: 66
Don't have a one...
@Superku I'll try with the 'ent_createlayer' and see if it is the problem (I tried before and I'm sure it wasn't the problem ,but I'll see it again). But do you mean that if I saved my game using game_save instruction ,then closed my game and opened it later ,then at the main menu (before even loading a level or creating entities) I won't be able to load my previously saved game?

Also, concerning your talking about saving after a completed mission (I liked that) ,how to use file_ manipulation for it?

Re: Game saving/loading stuff [Re: DonaldThief] #425898
07/12/13 11:47
07/12/13 11:47
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I don't think I understand your first question, sorry. If you don't use create-instructions, game_save usually will work pretty fine and will let you load for instance a scene where you are currently jumping over an obstacle in level 3, even though you may be in level 1 or have opened the main menu and no level loaded.

Assuming you want to save the progress in a save station in your level, you can realize this approx. as follows:

filehandle = file_open_write("save.txt");
file_var_write(filehandle, level_current);
file_var_write(filehandle, level_save_station);
file_var_write(filehandle, player_health);
file_var_write(filehandle, mission_time);
file_close(filehandle);

Then, when you want to load the game, proceed as follows:

filehandle = file_open_read("save.txt");
level_current = file_var_read(filehandle);
level_save_station = file_var_write(filehandle);
player_health = file_var_write(filehandle);
mission_time = file_var_write(filehandle);
file_close(filehandle);

if(level_current == 1) load_level("level1.wmb");
if(level_current == 2) load_level("level2.wmb");
ent_create(player_mdl,save_station[level_save_station],act_player);
...


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Game saving/loading stuff [Re: Superku] #425921
07/12/13 18:10
07/12/13 18:10
Joined: Jul 2013
Posts: 66
Don't have a one...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

Joined: Jul 2013
Posts: 66
Don't have a one...
Don't care about my first question. I really liked your method in using the saving stations & file_ instructions and I'll try hard to implement it

Thank you for helping

Re: Game saving/loading stuff [Re: DonaldThief] #425922
07/12/13 18:46
07/12/13 18:46
Joined: Jul 2013
Posts: 66
Don't have a one...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

Joined: Jul 2013
Posts: 66
Don't have a one...
But wait a minute, is there a way to write the values of an array with only one single line instead of writing every value? For example:

I defined an array like that:
var a[5][5];

I don't want that:
file_var_write(filehandle,a[0][0]);
file_var_write(filehandle,a[0][1]);
file_var_write(filehandle,a[0][2]);
....

I want a single line. Is that possible?

Last edited by DonaldThief; 07/12/13 18:49.
Re: Game saving/loading stuff [Re: DonaldThief] #425924
07/12/13 18:58
07/12/13 18:58
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
use for(...)

edit: something like this:

Code:
int i, j;
for(int i = 0; i < 5; i++)
   for(int j = 0; j < 5; j++)
      file_var_write(filehandle, a[i][j]);

or this, if it looks better to you:

int i, j;
for(int i = 0; i < 5; i++)
{
   for(int j = 0; j < 5; j++)
   {
      file_var_write(filehandle, a[i][j]);
   }
}


Last edited by Kartoffel; 07/12/13 19:01.

POTATO-MAN saves the day! - Random
Re: Game saving/loading stuff [Re: Kartoffel] #425926
07/12/13 19:21
07/12/13 19:21
Joined: Jul 2013
Posts: 66
Don't have a one...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

Joined: Jul 2013
Posts: 66
Don't have a one...
@Kartoffel Thank you very much


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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