Hi!

I want to save the progress of Ork on the server.

Ork's save function seems to store all information.

However
I want to save only the information I need in JSON and store it on the server
(that is, a small amount of the ork's information, only such as the combatant's stats, inventory and exp,level..etc)

1.In my opinion, after accessing each property(combatant.inventory etc..) through scripting,
and save to a variable.
And I need to send it to the server via json parsing for myself.
It seems I need to implement this for myself.

- If so, are there any elements that must be stored in order for Ork to function properly?
( ex) If i store only the inventory, i need to store other elements as well.)

- And I need a scripting path for each element I want to save.
Where can I find this information?

2. Is there a way to start Game based on this loaded information from server(JSON values)?
In other words, it's about how to properly initialize ork with values retrieved from the server.
And I want to ork.stargame () based on it.

Thank you for always!
  • ORK's save data is saved in an XML-formatted string (optionally encrypted). You can manage which data will be saved in Menus > Save Game Menu, as well as use a custom save system via the Save To setting.

    When using a custom system, you need to provide some static functions to save/load the data, but it'll still use the XML format for the data (i.e. pass it on to your function).

    1) Well, yeah, if you want to have it as JSON instead of e.g. just sending the ORK save data string via JSON to the server, you'll have to implement it yourself.
    One way to do it would be to parse ORK's save data DataObject (which is used by ORK to parse it into XML), you can get the save data via:
    DataObject saveData = ORK.SaveGame.GetSaveData();
    Might seem a bit complicated first, but you can get all data of the data object (stored in different dictionaries per data type) and parse it as JSON.

    2) Similar to #1, you can use this to load from a DataObject (which you'd need to create from your JSON data):
    ORK.SaveGame.SetLoadData(saveData);


    It's definitely easier to just pass on ORK's XML save game data and use the custom save system feature instead :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you for answer!!
    Actually, I'm spending a few days to solve this problem.
    I need advice ...

    Yes, I really don't know much about DataObject.
    Therefore, the json parsing process will be very difficult ....

    "It's definitely easier to just pass on ORK's XML save game data and use the custom save system feature instead :)"
    Like your answer above,

    I decided to use XML data and custom save system (static function).

    However, Save To-Custom
    Save function
    Load function
    I have no idea what to write inside and what to set as parameters.
    Need advice.

    For understanding, my scenario looks like this:

    1. I don't want to save it to a file or playerprefs.
    2. I want to send the received xml format data to the server.
    3. However, for # 2, I need to analyze the xml data and separate the data by key and value.
    (for storing key / value pairs)
    4. Step 3 should be performed in the save fuction.

    5. I don't even have an idea to implement the load function.
    Is it necessary to get the string, string value dictionary from the server and then re-create the dataobject?

    So, to summarize the question,

    I need simple examples and advice to write a static save / load function.

    If you need additional information, I'll rewrite it.
    Thanks in advance for the answer!
  • You need a custom class with 4 static functions as explained in the help texts of the save settings, e.g. like this:

    public class CustomSave
    {
    public static void Save(int index, string data)
    {
    // your save handling, gets the XML formatted save data in the 'data' parameter
    }

    public static string Load(int index)
    {
    // your load handling, has to return the saved XML formatted save data
    }

    public static bool Exists(int index)
    {
    // should return true if a save game for save file 'index' exists
    }

    public static void Delete(int index)
    {
    // should delete the save file 'index'
    }
    }


    Here, the Custom setup in ORK would be like:
    - class name: CustomSave
    - save function name: Save
    - load function name: Load
    - exists function name: Exists
    - delete function name: Delete

    Implement your save/load functionality in these functions and they'll be used by ORK.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you for answer!

    Um ... I don't know how to upload the xml string to the server.
    So I want to apply a method other than the json serialization method.

    In your first answer,
    **
    1) Well, yeah, if you want to have it as JSON instead of e.g. just sending the ORK save data string via JSON to the server, you'll have to implement it yourself.
    One way to do it would be to parse ORK's save data DataObject (which is used by ORK to parse it into XML), you can get the save data via:
    DataObject saveData = ORK.SaveGame.GetSaveData ();

    Might seem a bit complicated first, but you can get all data of the data object (stored in different dictionaries per data type) and parse it as JSON.
    **

    Please tell me how to deal with DataObject!
    How to find out what data types exist and what keys can be used to get the values ​​..

    ***
    2) Similar to # 1, you can use this to load from a DataObject (which you'd need to create from your JSON data):
    ORK.SaveGame.SetLoadData (saveData);
    ***

    For example, I want the following function (pseudo code)

    Server.SetData (DataObject [OwnedGold] .Key, DataObject [OwnedGold] .Value);
    and
    Server.GetData (DataObject [OwnedGold] .Key);
    In other words, a method of loading a game into a data object by allocating a portion of all data obtained from the server back to the data object.

    In short, I want the following flow.

    DataObject saveData = ORK.SaveGame.GetSaveData (); // Get all saved data.

    Server.SetData (DataObject [OwnedGold] .Key, DataObject [OwnedGold] .Value);
    // Transmit only some of the stored data to the server. And are there any useful methods that can be used in data objects ?? How can I find out what data type I want?
    (That is, what is the key to the inventory item?)

    saveData [OwnedGold] .Value = Server.GetData (DataObject [OwnedGold] .Key);
    // Get the data through the key from the server.
    //Please tell me how to assign the desired value to the data object

    ORK.SaveGame.SetLoadData (saveData);
    // Load the game through the Data object.
    How to deal with data objects, key types, methods, and reallocation of values ..
    Thanks in advance for the answer
  • The XML string is basically that, a text/string, though usually very long due to save games having lots of data, but your JSON string would be just as long, or even longer.
    You could just add the XML string to your JSON data and send it that way.

    As for the data object, it stores the data in multiple Dictionary instances, each for a separate data type, e.g. Dictionary for bool values, Dictionary for float array values, etc.
    You can get those dictionaries to cycle through their content like this:
    Dictionary<string, bool> boolData = dataObject.GetData<bool>(typeof(bool));
    And for array data:
    Dictionary<string, float[]> floatArrayData = dataObject.GetArrayData<float>(typeof(float));

    There are various data types supported, but for save games, you'll need to check:
    - int
    - float
    - bool
    - string
    - int[]
    - float[]
    - bool[]
    - string[]

    And, a data object can also include sub-data:
    - DataObject
    - DataObject[]
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you for answer!
    I understood everything you answered but,
    There is a problem that has not been solved yet.
    Sorry for the series of questions.
    because This is the most important part of my game for a long time,... I want to understand it clearly.

    For further explanation, I sent it with a photo via contact mail.
    Thank you.
Sign In or Register to comment.