0 registered members (),
18,008
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Save error
#245541
01/10/09 16:14
01/10/09 16:14
|
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);
}
|
|
|
Re: Save error
[Re: Secret_V]
#245544
01/10/09 16:28
01/10/09 16:28
|
Joined: May 2007
Posts: 2,043 Germany
Lukas
 
Programmer
|
 
Programmer
Joined: May 2007
Posts: 2,043
Germany
|
I think this: continue_handle = file_open_read("my_save1.SAV");
if (continue_handle) continue_pan.flags = VISIBLE;
file_close(continue_handle); must be changed to: continue_handle = file_open_read("my_save1.SAV"); if (continue_handle) {continue_pan.flags = VISIBLE; file_close(continue_handle); }
|
|
|
Re: Save error
[Re: Lukas]
#245551
01/10/09 16:53
01/10/09 16:53
|
Joined: Nov 2008
Posts: 50
Secret_V
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2008
Posts: 50
|
I'm afraid it's still the same...
By the way, the event not working any more is an action, attached to an entity (model).
Last edited by Secret_V; 01/10/09 17:04.
|
|
|
Re: Save error
[Re: testDummy]
#245610
01/10/09 21:47
01/10/09 21:47
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
replace continue_pan.flags = VISIBLE; with continue_pan.flags |= VISIBLE; or set(continue_pan,VISIBLE);
and the panel should be visible.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Save error
[Re: testDummy]
#245614
01/10/09 22:07
01/10/09 22:07
|
Joined: Nov 2008
Posts: 50
Secret_V
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2008
Posts: 50
|
the following may be irrelevant: 'I' was under the impression, that, perhaps surprisingly, if the standard save 'feature' is used, after each modification of the script, the save file must be recreated a new, or the engine may crash. You are absolutely right, but, I was already aware of that. But that is not the problem. Cause when I use Test Run and then click continue, the file loads and everything looks the way it should be. Thing is... a certain action attached to an entity doesn't work any more. Also, when I click continue in Debug Run, sometimes the engine simply shuts down, sometimes my whole SED crashes and sometimes it gives me one of two error messages. The first being the one in my first post and the second one is: Crash in Continu, continu being one of the functions from my first post. This is the action not working any more after I load the save file, while it does work when I load the level instead of the save file:
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();
}
}
} @Sylar: There is nothing wrong with my code for showing the panel, but thanks nevertheless. 
|
|
|
Re: Save error
[Re: Secret_V]
#245618
01/10/09 22:22
01/10/09 22:22
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
Perhaps, in some version(s) of the engine, game_load does not always return the correct value on failure? (It seems the return value is not received / evaluated in function continu().) Of course, it seems 'you' have already indicated that nothing was changed in the script, level, etc. between save and load. irrelevant but... file_open_read probably wasn't designed for that exact purpose. Seemingly, if such a function is not already provided for that specific purpose, a file_exists function for that exact purpose, might be useful. Of course, if file_open_read is effective already, then... Maybe also irrelevant but... What does the function body look like for gevecht() ? Is the function continu() called in an inappropriate fashion (maybe more than once in a certain period, etc.)? Quoting Secret_V Crash in Continu, continu being one of the functions from my first post. ...a crash in the function which invokes game_load...
|
|
|
Re: Save error
[Re: testDummy]
#245622
01/10/09 22:46
01/10/09 22:46
|
Joined: Nov 2008
Posts: 50
Secret_V
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2008
Posts: 50
|
I am aware that file_open_read is not designed for this purpose, but I'm afraid such a function as file_exists doesn't exist. Plus, file_open_read works just fine. It returns a positive value when the file does exist and it returns 0 when it doesn't. So when it returns a positive value, which would mean that the file exists, it shows continue_pan. The body of function gevecht() looks like this:
function gevecht()
{
randomize();
mouse_mode = 2;
background_pan.flags = VISIBLE;
in_battle = 1;
choose_txt.flags = VISIBLE;
character1_pan.flags = VISIBLE | OVERLAY;
character2_pan.flags = VISIBLE | OVERLAY;
character3_pan.flags = VISIBLE | OVERLAY;
}
Those three panels I show are buttons which lead to other functions, it's used for an RPG battle script. But I am quite sure that there is nothing wrong with this function, I think the problem lies in the grass() action. Cause I've set a watch on battle_var to check it's value at all times. When I first load the level without using continue and then walk against the entity with the grass() action, I see the value changing continually until it equals 100, thus triggering gevecht(). But when I check the value after I use the Continue button (thus I have loaded the game using game_load) battle_var equals zero at all times, never to change it's value any more, as if the grass() action doesn't exist or apply to the entity. The first error said: "Crash in Event", the second says "Crash in Continu". And now all of a sudden when I use Debug Run and click Continue, it actually loads my game sometimes, but the action still doesn't work. The function continu() is called by clicking a button, only once and then the button disappears because it's flags are set to '0' with game_load.
Last edited by Secret_V; 01/10/09 22:49.
|
|
|
Re: Save error
[Re: Secret_V]
#246399
01/14/09 23:49
01/14/09 23:49
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi! 1) I noticed that action grass is ahead of function battle I think that battle (the event) should be ahead of the action. 2) Check all your flags. Go to the free ressources section and pick up "Flags at a glance" Hope this helps Ottawa 
|
|
|
|