May 23, 2012, 12:10:36 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Please report any bugs or issues that you might be encountering with the Beta in the Support System so that we can better keep track of any oustanding issues that may come up.

GameCore Support System
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: World Management  (Read 632 times)
Squat
Hero Member
*****
Posts: 592


View Profile
« on: January 14, 2009, 05:19:48 AM »

What is the safest and most efficient way to load a new world while you're in one that's running? I keep getting a fatal exception error if I try to load a new world by my own script instead of going back to the main menu and choosing it.

How does one include worlds in their game, but not have those selectable from the list. For instance, I'm loading a world behind my main menu, but that menu.wld is selectable in my list of levels to choose. I also have a bonus world that you can only get to through a spot in the game and I want it to load that world the instant I get there.
Logged
gekido
Guest
« Reply #1 on: January 15, 2009, 10:04:29 PM »

The following is a pretty safe set of steps to following if you are loading a new world from an old one.

Code:
       // hide the entire interface
HideAllForms();

       // delete any main game scripts
DeleteGameScripts();

       // flush the current world from memory
NewWorld();

       // pause the game (stops any controller scripts / dynamics advance etc)
GetGameManager().SetPaused( true);

       // do the actual load
// show the loading screen
ShowForm( "LoadingScreen");
StartLoadingWorld( "MyNewWorld.wld");
while (!DoneLoadingWorld())
Delay( 0.001f);

// run the new game script
LoadGameScript( "MyNewGameScript.gsl", "MainGame");

        // hide the loading screen
HideForm( "LoadingScreen");

       // clear the background image (if we have one)
ClearBackdrop();

      // unpause the game
GetGameManager().SetPaused( false);
}

The number one reason that things would crash from one world to another is that you are trying to access an invalid object handle either during the load or after the load.
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #2 on: January 15, 2009, 10:58:29 PM »

Thank you, I'll try that next. Any word about how to include background worlds that dont' show up in the selection list?
Logged
Ransom
Full Member
***
Posts: 132



View Profile
« Reply #3 on: January 16, 2009, 01:10:12 PM »

Quote
Any word about how to include background worlds that dont' show up in the selection list?
You have lots of options here, but probably the easiest one would be to put any "background worlds" in a different folder like worlds/backgrounds/ because the script only looks for files with a .wld extensions inside the worlds folder.

Then of course you'll have to point your script or .lay to the correct location.
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #4 on: January 16, 2009, 04:55:30 PM »

Thanks, I'm going to give that a whirl. I was worried about doing that only after exporting the game to a single executable. Now I can have some bonuses Smiley
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #5 on: January 16, 2009, 09:46:42 PM »

K, I'm still getting fatal exception errors on loading a new world from one that's currently running. Can anybody confirm they can do this?
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #6 on: January 16, 2009, 10:14:50 PM »

I'd like to note that I get the same exact results if I point to a map that doesn't exist. However, I have verified the map exists and the script is point to the right location (from its location).

I should also note that just using NewWorld(); by itself crashes it. Though this would be expected if not defining a new world.
Logged
Pages: [1]
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!