0 registered members (),
683
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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...
DonaldThief
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2013
Posts: 66
Don't have a one...
|
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 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 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
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
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: 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: DonaldThief]
#425898
07/12/13 11:47
07/12/13 11:47
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
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: DonaldThief]
#425922
07/12/13 18:46
07/12/13 18:46
|
Joined: Jul 2013
Posts: 66 Don't have a one...
DonaldThief
OP
Junior Member
|
OP
Junior Member
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
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
use for(...) edit: something like this:
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
|
|
|
|