Hey, is there any way to let users import/export the save files generated by the game in Ork 2? I haven't seen anything on it anywhere
  • No, that's not possible.
    ORK 2 data is also not complatible with ORK 3.
    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!
  • edited August 2022
    I saw there was a "Custom" field for Save Game Settings, but couldn't find any documentations/examples on it, could this be used? image
    Post edited by Xavi on
  • Check the help texts for the individual fields.
    In short, you need to write a custom class with the 4 required functions (as stated in their help texts) to handle saving/loading data.

    This could be used to change the save data, which is provided in an XML-formatted string.
    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!
  • edited August 2022
    So i've managed to save files, load files, and even change the read/write directory for my custom save solution, however i'm stuck at actually importing saves because once I get to a save file ORKFramework.ORK.Game.LoadGame(_gameData) needs the _gameData to be of the ORKFramework.DataObject type, and I can't find anything on converting strings to DataObject.

    I know it's possible because to save and load games because SaveGame() and LoadGame() save as/pass in a string respectively, but how do i do this manually through code?

    Edit: I'm on ORK 2.25.2, haven't upgraded for fear of breaking project
    Post edited by Xavi on
  • edited August 2022
    So I dug around the API Docs + forums and figured out a solution, however when I call ORKFramework.ORK.Game.LoadGame(saveData) nothing actually happens.

    It's not throwing any errors and any test code I put after it executes so i'm not sure what's wrong. I know the save files are valid because i'm using the same ones the game loads from in main menu (which still works), and when I Debug.Log the output looks identical. Code below

    public static void ImportSave()
    {
    //get File Path
    string filePath = OpenFileWindow.Apply(extension);

    if (File.Exists(filePath))
    {
    string saveData = File.ReadAllText(filePath);
    var parser = new ORKFramework.XML.XMLParser(saveData, new ORKFramework.AssetLookUp());

    ORKFramework.DataObject saveDataObj = parser.Parse();

    ORKFramework.ORK.Game.LoadGame(saveDataObj);

    Debug.Log("FILE: " + saveData);
    }

    }
    Post edited by Xavi on
  • Save games are handled via ORK.SaveGame - that's where you need to call saving or loading the game.

    ORK.Game.LoadGame is the function that's called by the save game handling to load some of the data.
    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!
  • edited August 2022
    Took a lot of trial and error but got everything working! Still need to clean it up but here's the gist for posterity.
    Import Save is from MainMenu, Export Save is called by an event, and OpenFileWindow is a simple custom class to open/save files based on EditorUtility examples

    //Export current save data
    public static void ExportSave()
    {
    ORKFramework.DataObject data = ORKFramework.ORK.SaveGame.GetSaveData();
    ORKFramework.ORKDataFile orkData = data.GetDataFile("Exported_Save", false); //NOTE: Newer versions of Ork 2 just let you do data.ToXML();
    string saveData = orkData.GetXML();

    OpenFileWindow.SaveFile(saveData, extension);
    }


    //Import a save file. TODO: Use try/catch to abort if there's a problem
    public static void ImportSave()
    {
    //get File Path
    string filePath = OpenFileWindow.Apply(extension);

    if (File.Exists(filePath))
    {
    string saveData = File.ReadAllText(filePath);
    var parser = new ORKFramework.XML.XMLParser(saveData, new ORKFramework.AssetLookUp());

    ORKFramework.DataObject saveDataObj = parser.Parse();

    ORKFramework.ORK.SaveGame.SetLoadData(saveDataObj);
    ORKFramework.ORK.SaveGame.Load(-1);

    //Debug.Log("FILE: " + saveData);
    }

    }
    Post edited by Xavi on
  • I allow myself to go up this subject even if my question relates to ORK, in order not to create an infinity of topic.

    Is it possible/considerable to use save/load in the cloud.
    Do you think this is complex to set up (has anyone ever succeeded with ork?)

    It is an essential and practical function today, especially for mobile games.

    I intend to implement this in my future project.
    I don't think I'll be able to do anything because my level of programming is way too low.
    I would surely pay for the development of this aspect or am ready to support (financially) the creation of a "plugin" / "asset" aimed at integrating this functionality.
  • Yeah, that's possible.

    In ORK 3, you can either use the Custom save file type (in UI > Save Game Settings or write your own custom save file handler.
    Those can be used to save/load stuff wherever you want, even in the cloud. You'd also use this e.g. if you need special save handling for consoles (Nintendo Switch, etc.).

    The functions require an immediate response, though. E.g. the load function can't wait for some save data to be loaded from the cloud - you'd have to get the save data from clould before that, e.g. when the game is first initialized load all save files from the cloud to have them available locally and access immediately.
    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!
Sign In or Register to comment.