I've been unable to reproduce this behaviour. Setting objects to a player's script data is working as expected for me. Could you try the following:
- Hard-coding an object and setting it the player's scriptData, see if you're getting the same result
- Logging the value of Spark.getData().scriptData.regInfo prior to setting it to scriptData to ensure it is being retrieved correctly.
Regards,
Vinnie
I ended up having to do it this way- just taking the individual values and making them into a JSON on my end. This is fine for now because these are all the values I need to put into scriptData.
However as far as my runtimeCollections go, I need to save much larger classes.
var email = Spark.getData().scriptData.email; var age = Spark.getData().scriptData.age; var birthday = Spark.getData().scriptData.birthday; var pClass = Spark.getData().scriptData.pClass; var times = Spark.getData().scriptData.times; var iden = Spark.getData().scriptData.iden; var goodnoodle = Spark.getData().scriptData.goodnoodle; var or = Spark.getData().scriptData.or; var suspended = Spark.getData().scriptData.suspended; var susptime = Spark.getData().scriptData.susptime; var susptimebeginhour = Spark.getData().scriptData.susptimebeginhour; var susptimebeginday = Spark.getData().scriptData.susptimebeginday; var banned = Spark.getData().scriptData.banned; var reas = Spark.getData().scriptData.reason; var staff = Spark.getData().scriptData.staff; var mainData ={ "pClass":pClass, "email":email, "age":age, "times":times, "iden":iden, "birthday":birthday, "goodnoodle":goodnoodle, "or":or, "suspended":suspended, "susptime":susptime, "susptimebeginhour":susptimebeginhour, "susptimebeginday":susptimebeginday, "banned":banned, "reason":reas, "staff":staff };
I'm hoping this tutorial https://docs.gamesparks.com/tutorials/database-access-and-cloud-storage/submitting-json-document-queries.html
Will help with that, although I also have arrays of ints/floats inside of my regular classes as well. I'm hoping that this is a working solution out of the box.
As long as it's valid json you should be able to insert it into your runtime collection. I would recommend that you reduce all of your 'Spark.getData()' calls into a single call though:
var scriptData = Spark.getData().scriptData;
var email = scriptData.email;
var age = scriptData.age;
or, if these vars aren't being used elsewhere in the script you can skip assigning the values to variables altogether:
var scriptData = Spark.getData().scriptData;
var mainData = {
"email":scriptData.email,
"age":scriptData.age
...
}
Regards,
Vinnie
Vivian Manders
I know how to set singular values into scriptData, but I think this is tedious as I'd rather pull a JSON of several values at once instead of grabbing single values 6 times.
var mainData = Spark.getData().scriptData.regInfo;
"RegInfo" is the JSON I'm submitting
Spark.getPlayer().setScriptData("mainData", mainData);
What results is the JSON appears under ScriptData, however when it's unfolded, it has no values, which means it is detecting it's a JSON but it won't treat it like one. How can I make it detect all the values inside?