Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Save data
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#11
RE: Save data

How is your code then?

10-19-2015, 12:41 PM
Find
Kanthos Offline
Junior Member

Posts: 48
Threads: 7
Joined: Oct 2015
Reputation: 1
#12
RE: Save data

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
10-19-2015, 02:24 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#13
RE: Save data

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

(This post was last modified: 10-19-2015, 02:35 PM by Mudbill.)
10-19-2015, 02:35 PM
Find
Kanthos Offline
Junior Member

Posts: 48
Threads: 7
Joined: Oct 2015
Reputation: 1
#14
RE: Save data

Thanks, Mudbill.

Patched it, tested it, but it doesn´t work Sad
10-19-2015, 02:45 PM
Find
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#15
RE: Save data

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.
10-19-2015, 05:22 PM
Website Find
Kanthos Offline
Junior Member

Posts: 48
Threads: 7
Joined: Oct 2015
Reputation: 1
#16
RE: Save data

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.
10-19-2015, 07:44 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#17
RE: Save data

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.

(This post was last modified: 10-19-2015, 09:31 PM by Mudbill.)
10-19-2015, 09:31 PM
Find
Kanthos Offline
Junior Member

Posts: 48
Threads: 7
Joined: Oct 2015
Reputation: 1
#18
RE: Save data

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
10-20-2015, 12:41 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#19
RE: Save data

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.

10-20-2015, 02:20 AM
Find
Kanthos Offline
Junior Member

Posts: 48
Threads: 7
Joined: Oct 2015
Reputation: 1
#20
RE: Save data

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!
(This post was last modified: 10-20-2015, 04:36 PM by Kanthos.)
10-20-2015, 02:39 PM
Find




Users browsing this thread: 1 Guest(s)