Hello guys, I hope you can help me. I am trying to migrate my logic to change my backend in php and mysql (WebService) to nakama. I have my project with Godot in GDScript. But I’m testing to see if all the logic I have would work for me, in nakama. And I find a problem. I put you in situation. My game the user has, several creatures, with which he will fight against other users. The user acquires these creatures. I want to store those creatures in the DB(Cockroach). I am using docker and nakama. So, I add these creatures with this function…
func write_creature_async(creatures := []) -> void:
yield(Online.nakama_client.write_storage_objects_async(
Online.nakama_session,
[
NakamaWriteStorageObject.new(
"all_creatures",
"creaturesUser",
ReadPermissions.OWNER_READ,
WritePermissions.OWNER_WRITE,
JSON.print({creatures = creatures}),
""
)
]
), "completed")
And creatures is this:
func _on_Button_button_down():
var creatures := [
{id = 0, creatureName = "Floosty", level = 2, experience = 0, max_exp = 25, max_hp = 30, atack1 = "Placaje"},
{id = 0, creatureName = "Floosty", level = 3, experience = 0, max_exp = 25, max_hp = 30, atack1 = "Placaje"},
]
yield(write_creature_async(creatures), "completed")
estos datos aparecen en nakama así:
{
"creatures": [
{
"atack1": "Placaje",
"creatureName": "Floosty",
"experience": 0,
"id": 0,
"level": 2,
"max_exp": 25,
"max_hp": 30
},
{
"atack1": "Placaje",
"creatureName": "Floosty",
"experience": 0,
"id": 1,
"level": 3,
"max_exp": 25,
"max_hp": 30
}
]
}
The problem comes when I try, for example, to change a stat of a single creature. To begin with, I can’t find a way to add an autoincremental ID (I’ve created a function to get out of trouble). And then, I can’t find how I could run update the stats of a single creature. The only option I see is to do a get of all the creatures, add them to an array, search the array for the creature I want to modify, and then do a write_storage_objects_async again adding all the creatures again. It is possible that this cannot be done as it is normally done in a DB with an INSERT or an UPDATE or a DELETE of a creature by id. But it seems strange to me and I can’t find any other options. Thank you!