Modding:SaveGame Data Storage: Difference between revisions

From Vintage Story Wiki
Line 88: Line 88:
<code>byte[] data = serverApi.WorldManager.SaveGame.GetData("lfg");</code>
<code>byte[] data = serverApi.WorldManager.SaveGame.GetData("lfg");</code>


As you can see, we're retrieving an array of bytes, which is data type we actually store on the SaveGame. Let's convert it to a <code>List</code> of strings:
As you can see, we're retrieving an array of bytes, which is a data type we actually store on the <code>SaveGame</code>. Let's convert it to a <code>List</code> of strings:


<code>List<string> players = data == null ? new List<string>() : SerializerUtil.Deserialize<List<string>>(data);</code>
<code>List<string> players = data == null ? new List<string>() : SerializerUtil.Deserialize<List<string>>(data);</code>