Modding:SaveGame Data Storage: Difference between revisions

From Vintage Story Wiki
Line 90: Line 90:
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 data type we actually store on the SaveGame. Let's convert it to a <code>List</code> of strings:


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


Here we use a ternary operator to assign our <code>players</code> list a new <code>List<string></code> if there was nothing stored under the "lfg" key.
Here we use a ternary operator to assign our <code>players</code> list a new <code>List<string></code> if there was nothing stored under the "lfg" key.