Fail to update an object

Hello!

I’m new to gather.town ecosystem, and I’m trying to play with it’s API.

My problem is with mapSetObjects event, that is having no effect and no error is thrown.

I try game.setObject(...) and game.sendAction({$case: "mapSetObjects",...}), in the app.gather.town page’s console and on a node script without look.

Both node and browser’s console can correctly create an object with game.sendAction({$case: "mapAddObject",...}), but not with game.setObject(...).

I have tried to update the “normal” image and the position, without effect.

My updating is like that:

game.sendAction({
      $case: "mapSetObjects",
      mapSetObjects: {
          mapId: MAP_ID,
          objects: { [objId]: { // objId is the same used on mapAddObject
                "id": objId,
                "height": 1,
                "width": 1,
                "distThreshold": 1,
                "x": 37,
                "y": 27,
                "type": 5,
                "previewMessage": "MEOOOOWWW",
                "normal": "data:image/png;base64,xxxxxxxxxx",
                "customState": "tree",
                "_tags": []
          } }
      }
})

Where I’m wrong?

For the Normal image, the expected data type (well, kinda) is a url link to the image, not the image data directly.

Check out this documentation website that was set up a while ago:

It is a little out of date on some things, but common and unchanging methods like setObject will be correctly documented.

By and large, I would recommend against using game.sendAction directly, as it has less than helpful errors, and most of the methods call it for you with the correct data structuring, in the event of something odd happening (looking at you, collisions).

Also, if you are interested in changing multiple objects at once, setMapObjects is the go to. Just be aware of the boolean for new vs overwrites.

Thank you Bill_Uncork-It. It is not the answer, but is enlightening!

The problem is the objects object indexing. I assume the index was the object’s id, however it uses the object’s key.

That was the problem.