Frictional Games Forum (read-only)
Save data - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: SOMA (https://www.frictionalgames.com/forum/forum-55.html)
+--- Forum: User created content (https://www.frictionalgames.com/forum/forum-79.html)
+---- Forum: Development (https://www.frictionalgames.com/forum/forum-82.html)
+---- Thread: Save data (/thread-31371.html)

Pages: 1 2


RE: Save data - Mudbill - 10-19-2015

How is your code then?


RE: Save data - Kanthos - 10-19-2015

Basically it´s the same that you wrote.


___________________________________________________________________________
void Setup()
{
SetupMapWState;
}



void SetupMapWState()
{

if ( cScript_GetGlobalVarInt("BaseState")==0)
{}

else if ( cScript_GetGlobalVarInt("BaseState")==1)
{
UseBatteries2; //Turns on Light1
}

else if ( cScript_GetGlobalVarInt("BaseState")==2)
{
UseBatteries2; //turns on Light1
boot; //turns on Light2
}
}


UseBatteries2(const tString &in asEntity)
{
.
.
.
cScript_SetGlobalVarInt("StateBase", 1);
}

boot(const tString &in asEntity)
{
.
.
.
cScript_SetGlobalVarInt("StateBase", 2);
}


_____________________________________________________________________

boot and UseBatteries are Callbacks used also by buttons.
When i boot or use the batteries, then leave the map, then return to the map, the lights are off.


Hope i´m not too dump ^^ Sry, guys


RE: Save data - Mudbill - 10-19-2015

Well, first off your getter and setter don't match up. One is called StateBase, the other is BaseState. Little hickup?


RE: Save data - Kanthos - 10-19-2015

Thanks, Mudbill.

Patched it, tested it, but it doesn´t work Sad


RE: Save data - jens - 10-19-2015

How do you test this? You have to leave and enter the level like you normally would go between levels, if you reload the game or use load map in the F1 menu it will not work. Also, my memory might be failing here, but normally things like state of a lamp entity should not have to be controlled with a global var, the state they have when you leave should be the same when you re-enter unless you reset them to a specific state on load.

Add cLux_AddDebugMessages("message"); in your code to print out messages in the bottom left of the screen for easy testing of what actually goes on and what value the vars have. Must have show debug messages enabled in the F1 menu for it to work.


RE: Save data - Kanthos - 10-19-2015

To test it i first launch the SomaDev.bat. Then there are no errors i start the mod through the mod launcher.

Hmm... I copied the Airlock-Event of when you enter tau for my map change. Maybe i find my mistake there.


RE: Save data - Mudbill - 10-19-2015

As a side note, did you remember to tick FullGameSave on the lamp entities? Not sure if that's default or not for a lamp, but that should be the determining factor whether an entity saves its states across levels.


RE: Save data - Kanthos - 10-20-2015

Thanks for you advice Mudbill, but there´s a warning not to determine too many as FullGameSave, so I don´t think that´s the intended solution to safe things.

Here´s what i did in the meantime:

I set up two maps. Each with a plane, light, start area, 1 button with a callback "Map_ChangeMap(...)". (nothing else in the script)
On the first map are also a lever, a button and a light. Each one can be switched.

Checked for mistakes in the dev.bat. Got no errors.
So i checked the map in the mod launcher.
Result: I start on map1, switch lever,button and light, go to map2, return to map1 and nothing is how i left it behind.

Btw: Thanks for your help guys, really appreciate it Smile


RE: Save data - Mudbill - 10-20-2015

The warning is just there so that you don't go and enable it on every single entity. It's fine to do on lamps, especially if you really want that effect to stick around. Obviously it would be more realistic for everything to remember every state, but that requires more memory than the immersion is worth. Most entities are better off reset anyway.


RE: Save data - Kanthos - 10-20-2015

I think i´ll just leave it be and combine the two maps.

Guess i have to work with a "indoor" map and use liquid areas for the outdoor part, like lampda.

Right now i think that changes on entities are "deleted" when leaving a map through the map_changemap instruction (read it in the wiki).

Oh, Mudbill, i´m sure you´re right, but it wouldn´t help me. I would have too much FullGameSave-Entities :/ But thx for the tip!