edited March 2015 in ORK Scripting
At game run time , I want save the game setting to database server .
like below code , Can I have way make DataObject to string (json string) , or create DataObject from string (json string)
I try to use litejson.dll do this , But some DataObject property doesn't support it




// 1. save game
DataObject setting = ORK.Game.SaveGame();
// I want get the string ( or json ) of setting



// 2. Loda game
// I want create the setting1 object from a string .
ORK.Game.LoadGame(setting1);

  • It is litjson.dll.




    // 1. save game
    DataObject setting = ORK.Game.SaveGame();
    // I want save the string ( or json ) data
    string json=JsonMapper.ToJson(setting);



    // 2. Loda game
    // I want create the setting1 object from a string .
    JsonData jsonData1 = JsonMapper.ToObject(json2);
    ORK.Game.LoadGame(setting1);

  • The DataObject can be converted into an XML string like this:

    dataObject.GetDataFile(string namespace, bool encrypt).GetXML();

    To create a DataObject from the XML string, you can use this code:

    DataFile dataFile = new DataFile(string namespace, bool encrypted);
    dataFile.SetXML(string xml);
    DataObject dataObject = dataFile.ToDataObject();
    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 May 2016
    I'm trying to create items/armour/weapons via xml as described here, but it doesn't appear to be working. I've tried using the raw xml from GetXML which I assumed would work, but I get a parsing error.

    Weapon w = ORK.Weapons.data[0];
    string xml = w.GetData().GetDataFile(w.GetName(), false).GetXML();

    ORKDataFile dataFile = new ORKDataFile(w.GetName(), false);
    //dataFile.SetXML(Application.dataPath + "/testfile.xml");
    dataFile.SetXML(xml);
    DataObject dataObject = dataFile.ToDataObject(); // fails here with error below
    int id = ORK.Weapons.Add();
    ORK.Weapons.data[id].SetData(dataObject);
    Error:

    Error while parsing XML data: at System.String.IndexOf (Char value, Int32 startIndex, Int32 count) [0x00013] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/String.cs:1114
    at ORKFramework.XML.XMLParser.Parse () [0x00000] in <filename unknown>:0
    UnityEngine.Debug:LogError(Object)
    ORKFramework.XML.XMLParser:Parse()
    ORKFramework.ORKDataFile:ToDataObject()
    I tried adding a header:

    <?xml version="1.0" encoding="utf - 8" ?>

    but that yields the same error.
    Post edited by deck2k on
  • w.GetName()
    was returning "Black Sword" which created an invalid XML:
    <Black Sword animationID="0"...
    So in theory, ORKDataFile::GetXML() should remove whitespace from its name before returning the XML
  • edited May 2016
    Furthermore, these parts don't seem to conform to XML standards which makes the XML difficult to edit in transition:

    <_floatarrays>
    <spawnOffset 0 0 0 />
    <viewerPosOff 0 0 0 />
    <viewerRotOff 0 0 0 />
    </_floatarrays>
    <_boolarrays>
    <equipPart False True True False />
    <blockPart False False False False />
    <blockViewer False False False False />
    </_boolarrays>
    Post edited by deck2k on
  • ORK uses a custom XML formatting, geared toward fast parsing and small file sizes.
    The name you use for creating the data file doesn't really matter much, using the actual name of the weapon isn't a good idea. Just use something like "weapon" to know what kind of data is stored there.
    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!
  • Is it possible to expose ORK's custom XML parser and writer?
  • No, they're closed source.
    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.