1 registered members (TipmyPip),
18,619
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Save Error
#246099
01/13/09 16:22
01/13/09 16:22
|
Joined: Nov 2008
Posts: 50
Secret_V
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2008
Posts: 50
|
I'm trying to create a good working save script in my game, but something just seems to go wrong. When I start the game, I check whether the save file exists. If it does, I show two buttons, Continue and New Game. If it doesn't, I only show the New Game button. So far, so good. If you click New Game, the game starts from the very beginning, just like I told it to. All events in the game world work as well. But when I click Continue... a certain event (and probably even more as soon as I insert them) doesn't work any more. Also, when I run it in Debug Run and then click on Continue, I get the message: Error E1513 - Crash in Event. These are the pieces of code which should take care of the Saving and Loading:
continue_handle = file_open_read("my_save1.SAV");
if (continue_handle) {continue_pan.flags = VISIBLE;
file_close(continue_handle);}
PANEL* save_pan =
{
pos_x = 0;
pos_y = 0;
layer = 1;
button(0, 0, save_bmp, save_bmp, save_bmp, save, null, null);
}
function save()
{
game_save("my_save", 1, SV_ALL);
}
function continu()
{
while(key_any) wait(1);
game_load("my_save", 1);
wait(-1);
}
This is the action() that's not working any more after loading the game.
action grass()
{
my.emask |= ENABLE_IMPACT;
my.event = battle;
}
function battle()
{
if(event_type == EVENT_IMPACT)
{
battle_var = integer(random(101));
if(battle_var == 100)
{
gevecht();
}
}
}
I tried asking in the liteC part of the forum, but there was no one there who could help me.
|
|
|
Re: Save Error
[Re: Secret_V]
#246101
01/13/09 16:34
01/13/09 16:34
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
There was mention of save / load problems (bugs) for some version(s) of the engine. Are 'you' using the latest version of the engine? *check return value of game_load? --does the load fail outright? *check format of button function? *function not declared prior to use? *superfluous while(key_any) wait(1); ? *block inappropriate repeat calls for continu? (already mentioned) *save / load incompatibility with modified scripts / level? (already mentioned) *DYNAMIC flag? Save Error (previous thread)
|
|
|
Re: Save Error
[Re: Secret_V]
#246114
01/13/09 17:41
01/13/09 17:41
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
Quoting a version of the manual: game_load(STRING* name,var num) Loads a saved game in the savedir folder. ... > 0 - successfully loaded, <= 0 - file couldn't be loaded.
var bSuccess = 0;
function continu() {
bSuccess = game_load("my_save", 1);
// if (bSuccess == 0) { // failed outright }
}
// different format of button function
function continu(PANEL* _p, var _buttonNum) {
}
Gamestudio 7.66 public betaQuoting pegamode. Thanks for publishing version 7.66.3 ... I was wondering why my savegames don't work anymore ?!?
With 7.66.3 everything works fine again. The issues might be unrelated. (Bah, 'I' don't even really use Lite-C / A7...still using A6.)
|
|
|
Re: Save Error
[Re: testDummy]
#246124
01/13/09 18:32
01/13/09 18:32
|
Joined: Nov 2008
Posts: 50
Secret_V
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2008
Posts: 50
|
Well, the game does load normally, but the action attached to my model doesn't work any more. So in this case, bSuccess equals 1 after loading the game, cause the load itself is successful. This is the panel I used for the function:
PANEL* continue_pan =
{
pos_x = 30;
pos_y = 10;
button(0, 0, continue_bmp, continue_bmp, continue_bmp, continu, null, null);
flags = VISIBLE;
}
It has a size of 580x118, but I don't think there's a problem with the panel, cause the function works and all, but the action doesn't work any more. I'm using the latest version, not a beta version. So it's the version I got from the download page.
|
|
|
Re: Save Error
[Re: Secret_V]
#246146
01/13/09 20:35
01/13/09 20:35
|
Joined: Nov 2008
Posts: 50
Secret_V
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2008
Posts: 50
|
If I were to change var into var_nsave, it gives me an error message: 'var_nsave' undeclared identifier.
I think continue_handle is indeed saved in my_save1.SAV, but that simply can't be the problem. Cause when I start the engine, it's value is set to a positive value if the save file exists or to 0 if it doesn't exist. If the value is positive, I can press continue. And when I press continue, the value (which should be zero) is loaded from the save file, but that doesn't matter, cause continue_handle is of no use to me any more after I load the game.
I checked all the flags of my model in my WED, but there's not a single one called Dynamic...
Edit: For some reason, the previous post I was replying to, has been deleted...
|
|
|
Re: Save Error
[Re: Secret_V]
#246196
01/14/09 01:12
01/14/09 01:12
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
According to one version of the manual, var_nsave is replaced by a suffix of _n.
var continue_handle_n = 0;
That is, any var with a name ending in _n, might NOT be saved by an invocation of game_save. Of course, as expected, that might be consistent with the current trend of absurdity (=correctness). Feel free to do a search in some version of the manual for term "DYNAMIC", or don't, that's OK too. On a more or less relevant note: Perhaps, it was suggested that jcl would be 'out' for a week, but maybe not. 'I' am not one of the developers from the aptly named forum category "Ask the Developers".
|
|
|
Re: Save Error
[Re: testDummy]
#246372
01/14/09 20:46
01/14/09 20:46
|
Joined: Nov 2008
Posts: 50
Secret_V
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2008
Posts: 50
|
Well, my model has an action attached to it, so it should be DYNAMIC, right? And when I use game_save, any DYNAMIC entity should be saved. So when the level loads with game_load, the DYNAMIC status of the entity should be loaded as well, am I not correct? I tried setting the DYNAMIC flag for the entity after loading using:
grass_ent.emask |= DYNAMIC;
But then when I touch the entity, it gives me an error message: Crash in Continu().
|
|
|
Re: Save Error
[Re: Secret_V]
#246410
01/15/09 02:30
01/15/09 02:30
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
Quoting Secret_V. Well, my model has an action attached to it, so it should be DYNAMIC, right? And when I use game_save, any DYNAMIC entity should be saved. So when the level loads with game_load, the DYNAMIC status of the entity should be loaded as well, am I not correct? OK. (continu -> remove waits)
|
|
|
|