PDA

View Full Version : Automatic saving and restoring



Pleng
05-17-2009, 03:32 PM
Can I automatically save and restore the players progress at given points in the game?

The reason I ask is that whenever the player enters a room I want to save where he is, and if he dies I want the game to restart from the point he entered the room.

Some of the puzzles in the game rely on items moving around the room and conversations occurring in particular orders. If I simply replace the player on the map at the location he started, it may well become impossible for the player to actually get to the exit on the map.

cheers!

Seth
05-17-2009, 08:24 PM
I see what you mean - no, there is currently no way to do that. (Freeze everything where you want and load it later automatically)

For now, the best way would probably be to not use the persistent features at all (make the maps not persistent or turn of profiles completely) and just reload the whole level (unload that map, then load again) if they die or restart the game.

Actually I think I will add this feature as it would be pretty simple to add. (Like RPG's that wanted to save at savepoints only, don't want "save everywhere")

Games would use a temporary visual profile and then at certain times would do a "CopyActiveProfile("SaveGame1"); or such that would flush all data and save to the new profile, which could be loaded later.

Pleng
05-18-2009, 12:48 PM
OK So I have the following code in my After Death routine:



LogMsg("Restarting Map");
GetMapManager:UnloadMapByName("Ship");
GetMapManager:LoadMapByName("Ship");
GetMapManager:SetActiveMapByName("Ship");


However when the map is re-loaded the GUI disappears. I tried reloading it by adding:



//Reload the interface
InterfaceInit("gui/interface.lua");


but this hasn't helped. :(

Any ideas?

Seth
05-19-2009, 03:39 AM
Hm, not sure.

The interface is 100% scripted so you could probably pick around its source and make a InterfaceDestroy() function to turn it off before reloading the map (there might be some weirdness because it is attached to the camera, so even though the world is deleted, if the camera has moved to a new world the interface might live on in some sort of limbo)

I'd have to see the full app with that in it to really be sure.

Pleng
05-19-2009, 06:37 AM
Hi again Seth!

Well the app is the same one I sent you before, and the code replaced what was previously in the RestartMap() function of crayon/ent_player.lua

cheers!
Clayton