game_start, SetRestartPoint and "Restart" problems with player

Started by Knox, Wed 27/10/2010 01:43:10

Previous topic - Next topic

Knox

I placed "SetRestartPoint()" in my game_start because Im having trouble with loading certain versions of my main character (I have a script that changes the age of the character).

To debug, I wrote this expecting to see "Debug Restart" displayed at the start of  the game. This happens on the 1st time, but if I press "restart", the next time the game loads, I dont see that message...meaning that game_start doesnt get passed after "Restart"?

So right now when I load the 1st time, my character appears in the right room with the right views, etc...but when I press restart, if the game doesnt pass "start_game", then my whole character swap script wont work...

Code: ags

function game_start()
{
  SetRestartPoint();
  Display("Debug Restart");
  Debug(4, 1);
  InitializeInterface();
  ...etc

--All that is necessary for evil to triumph is for good men to do nothing.

Gilbert

From the manual:
QuoteNOTE: The restart point cannot be set while a script is running -- therefore, when you call this it will actually set the restart point at the next game loop where there is not a blocking script running in the background.

So, the restart point will be set after the whole game_start() script has ended.

Knox

Well lets say I comment out the SetRestartPoint, shouldn't "Restart" restart the game from start_game in the global script...? Where does the game "start" after "Restart" is called, exactly? Everything after start_game? Im confused! :P

(I thought I would see "Debug Restart" message upon restarting the game, even with SetRestartPoint commented out)

*try saying that post 5 times fast*
--All that is necessary for evil to triumph is for good men to do nothing.

Gilbert

The manual doesn't explicitly state where the restart point is, but with good reasons it can be assume that it's at least after the whole game_start() script has ended.

The implementation of this feature is just the engine saving a (temporal) save game (numbered 999) at the beginning of the game (so it's probably like just saving the game at least after the first game loop in the game), and when you use SetRestartPoint() the engine just saves to that save game entry when the next unblocked loop arrives.

Khris

When a game is run, AGS runs game_start, then saves the game using slot 999. Afterwards the engine goes into its main loop.
When you restart the game (e.g. by pressing F9), all AGS does is load savegame 999. Consequently, all SetRestartPoint(); does is tell the engine to overwrite savegame 999 with the current state of the game.

If you want to do something only after a restart, put it in here:

Code: ags
void on_event (EventType event, int data) {
  if (event == eEventRestoreGame && data == 999) {
    // ...
  }
}

SMF spam blocked by CleanTalk