Sign In Register

How can we help you today?

Start a new topic

Can't find any information regarding the new DataService.

I have absolutely no idea if I'm doing this right and I can't find ANY information regarding updating specific fields. Here is how I add a monster object to my player:


var API = Spark.getGameDataService();

var entry = API.createItem("MONSTER", Spark.getData().ID);

var data = entry.getData();

data.name = Spark.getData().NAME;
data.type = Spark.getData().TYPE;
data.level = Spark.getData().LEVEL;
data.defense = Spark.getData().DEFENSE;
data.attack = Spark.getData().ATTACK;
data.agility = Spark.getData().AGILITY;
data.actionPoints = Spark.getData().ACTIONPOINTS;
data.slot = Spark.getData().SLOT;
data.id = Spark.getData().ID;
data.hunger = Spark.getData().HUNGER;
data.lastMeal = Spark.getData().LASTMEAL;
data.playerId = Spark.getPlayer().playerId;

var status = entry.persistor().persist().error();

if(status){
    Spark.setScriptError("ERROR", status);
    Spark.exit();
}

 This works perfectly fine (although have no idea if I'm doing it correctly) and I can request and show the monsters, but have no idea how I would go about updating a single field like level or hunger. Could someone point me to where the documentation is or let me know how to do it? Thanks :)


1 person has this question
1 Comment

Also, how would I go about parsing this in C#?


 

"{\"inventory\":{\"inventory\":[[1,\"26f0e377-f194-49e7-a826-fbddc23d6d95\"]]}}"

 

Login to post a comment