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
Kanthos Offline
Junior Member

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

Hey guys, it´s me again ^^

So i came over an interesting problem: I want to save a global variable from one map, because i want to return to this map later on.

So my first idea was to read and write into a txt-file via the fstream function. This does not work, because fstream seems not to be supported.

Later i saw the fuction LastOnSoma_SetText(tString), which i suspect to be a similar instruction, but couldn´t find it in the scripts.


Was anyone of you already in that stuff and has some advice?

Greets!
10-18-2015, 01:54 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: Save data

I don't know specifically what the global variable syntax is, but LastOnSoma_SetText(string) is used for the Loading Screen when you specify what section of the story the player is up to.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
10-18-2015, 02:01 PM
Find
Kanthos Offline
Junior Member

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

I see :/ thanks Modulator
10-18-2015, 02:13 PM
Find
Kanthos Offline
Junior Member

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

Modulator, do you know where LastOnSoma_SetText is defined? Wanna throw a look at it.
10-19-2015, 11:05 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#5
RE: Save data

As in, where it appears in Frictional Games' code? Of course! Most are probably located in OnStart(); however some change later on in the map. Here's an example from theta_exit.hps, where they have two instances of changing the SetText.

PHP Code: (Select All)
void OnStart()
    {
    
//Unrelated Code Here
    //
        //////Level Audio and Preloads    
        
Sound_PreloadProject("02_07_theta_exit_a");
        
Sound_PreloadGroup("Flashback/Level/02_07"true);
        
        
LastOnSoma_SetText("02_07_theta_exit_1");
    }

    
void SequenceWakeup(const tStringin asName)
    {
    
//There is lots of code here for this sequence. Good job FG! o.0
    //This particular part seems to be when you detach from the wall.
    
Player_SetFlashlightDisabled(false);    
        
    
LastOnSoma_SetText("02_07_theta_exit_2");
    } 

As we can see here, in the first instance, the LastOnSoma_SetText(); string is changed to become an entry called "02_07_theta_exit_1" when entering the map. Which would be located in the config/english.lang file. And sure enough, it is. (Spoilered and removing other entries for obvious reasons).

Spoiler below!
<CATEGORY Name="LastOnSOMAText">
    <Entry Name="02_07_theta_exit_1">Simon is lost somewhere inside Theta, looking for a way out.</Entry>
    <Entry Name="02_07_theta_exit_2">Simon is lost somewhere inside Theta, hunted by strange creatures.</Entry>
</CATEGORY>


I've included the second instance it changes also because it appears that you can change it at any time. Handy!

In a way, it is a global variable, since such text is stored in memory within the save. It is setting the string to display when you hit continue or load game. Here's another example from earlier on in the game (pardon the twitch chat. Sourced from Kreekakon's stream).

Spoiler below!
[Image: f336ef1318.jpg]

This particular string appears in the english.lang file, with this entry.
Spoiler below!
<Entry Name="01_04_transport_station_2">Simon's shuttle has crashed and he now has to find another way to get to Lambda, the place where Catherine, the woman on the radio, is waiting for him.</Entry>


And... well, that's how that particular thing works. The value is saved in memory whenever the game autosaves or the player presses Save and Exit, and is then set for when the Player returns to the game should they need a reminder of where they are.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
10-19-2015, 11:29 AM
Find
Kanthos Offline
Junior Member

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

Thanks, Mod! Smile This will help me a lot!
10-19-2015, 11:53 AM
Find
jens Offline
Frictional Games

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

Saving a global variable you do with cScript_SetGlobalVar... for example cScript_SetGlobalVarInt("MyInt", -4); and then cScript_GetGlobalVarInt("MyInt");
10-19-2015, 11:58 AM
Website Find
Kanthos Offline
Junior Member

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

Hey jens, thanks for your reply!
Do you have a hint how to best "store" such a global variable?

I want that the player of my mod can go to an other map, do things, then return to the first map, but the lights he turned on at its first visit are still on and not reset to the initial map configuration (for example).
(This post was last modified: 10-19-2015, 12:35 PM by Kanthos.)
10-19-2015, 12:32 PM
Find
Mudbill Offline
Muderator

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

That's what he just explained. You store a global variable using cScript_SetGlobalVarInt for example.
You do not need to save a text file or whatever. The global variable is likely saved within the story's Autosaves.

Use this to save your variable:
PHP Code: (Select All)
cScript_SetGlobalVarInt("MyInt"1); 

Then use this to check what the variable is, in another map if need be:
PHP Code: (Select All)
if(cScript_GetGlobalVarInt("MyInt") == 1

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

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

I quick-tested it and it has not worked :/ Did the same thing that you mentioned, Mudbill.
10-19-2015, 12:40 PM
Find




Users browsing this thread: 1 Guest(s)