Author Topic: serializator.fos - how to use it for loads and saves of world data.  (Read 2201 times)

Hello,

I have question about serializator.fos script. Seriously, I don't understant it well. Can someone explain me this script? I want to know how to use it for loads and saves of world data.

Thank you.
rem

Re: serializator.fos - how to use it for loads and saves of world data.
« Reply #1 on: March 25, 2018, 11:38:40 pm »
It's a wrapper for server side AnyData thingie, you might try to save like this
Code: [Select]
void SaveData() // call when needed to save something, i.e in main.fos world save section
{
    Serializator@ serializer = @Serializator(); // create an instance of Serializator
    serializer << DataToSave; // put your stuff into it
    serializer.Save("DataName"); // save it, name is whatever you like
}
And then load like this
Code: [Select]
void LoadData() // call when need to load smth
{
    Serializator@ serializer = @Serializator();  // create an instance of Serializator
    if (serializer.Load("DataName"))             // try to load data, if none found, go for else
    {
       serializer >> VariableToHoldData; // put your loaded stuff into something
       // anything you might need
    }
    else            // do stuff if data was not found
        DoStuffIfNotLoaded();
}

P.S if those "<<" and ">>" won't work on your revision, try using Set and Get serializator methods ( those are multiply overloaded to fit different data types and their sizes ), it should be equivalent. And yes, you can Set and Get more than 1 "object" with it, even your own types if you teach the wrapper to push it into it's byte buffer and take it back when needed. And you probably want to load stuff in the same order as you saved it.
« Last Edit: March 27, 2018, 12:11:10 am by Vice Dice »