Parsing Firebase after DataChanged

Hello All,

So I have been out of the game for several months and have forgotten and/or Thunkable X Firebase is different. I have read every post I can find about Firebase and have not found a solution to my problem.

I am making a multiplayer dice game. I need to be able to have certain things happen when the Firebase DataChanged block fires when it relates to the users game they are in. They will be multiple games going at once so each game has its own unique ID and only players of that game can write/call data. The DataChanged block is key because when a player “rolls” it changes the node “Rolling” to true which then triggers all others players dice to “roll” and then display the current players “dice”. However I am not able to get any updated data from the DataChanged block as it always crashes the live app. Note: I am trying to avoid having to use the Get block as I would have to call all the children within that game which seems data heavy.

Does Firebase no longer send the key and value of ONLY the data changed, meaning if Rolling updated for my game would FB DataChanged it would only display Rolling=true/false?

Here are my screen shots. I know it might sound confusing but I dont know how best to describe it LOL.

FB help1
FB help2

1 Like

Of course it will crash the system. This is due to trying to get the value of a property that does not exist in that particular object.

You are trying to get the data of the “Rolling” property from green block value which contains the data saved in that key.

You should get the data from green block key to be sure you are getting what you want.

1 Like

By chance could you show me an example? I seem to be having a brain fart and cant seem to understand the simplicity.

1 Like

Get property 000BB/Rolling

1 Like

So I tried that and still crashing my app. I know it used to be possible to only view the data from an update but that seems to have gone away. I will just have to use the Get block it seems.

1 Like

So I was able to make it work using the variable blocks. I just kept the listener the same.

1 Like

I need some help with this too.
I’m making a quiz app, and each user has to join in a room, and then his/her name is sent to firebase under the bucket(variable room). I’m struggling to get the names and scores of all the players who are also under that same room name and display it in a listviewer.
This is my firebase structure,a nd what it’s supposed to look like:
image
And now, it’s become messed up, and it looks like this.
image

This is my code:


I suppose my problem is that what’s returned is not a list. Since I need to insert my name and score at the end of the list, do you know of a way to convert something into a list? Or at least check whether the value returned from RTDB is a list?
Thanks

Personally I don’t like the way lists save in Firebase. I save all of my lists as a text string with each item being separated by a comma. It makes it easier to store and call. To get this I use the make Text from list block when saving to Firebase and switch it to make List from text when calling the data back and save it to a variable. fb help4

Using your example I would save it like this within my firebase:
Addie/Players: “Player1,Player2,Player3,Player4”
Addie/Scores:“0,0,0,0”
After calling the data I would save it in 2 variable lists. That way if I want player 1 score I would just use the In list get #1 return.

1 Like

Cool, thanks! Is there a way to save objects within firebase?

I think this is what you’re looking for. It would save it as I showed above.

1 Like

That’s genius! But sometimes, the room is empty when a player joins, so the app crashes when I attempt to make it convert nonexistant text into a list with the delimiter ‘,’ .

My updated code:


I got that also. Pretty easy fix most of the time.
fb help6

1 Like

Aha! Let me try that out!

Not working…
image