Hello guys! First of all thank you for all your work and sorry for bad english. I love thunkable and thunkable’s community and now i need your help! I’m making a real-time multiplayer card game. It looks easy but i’m having trouble finding a suitable way to submit played card. Every player play a card. This card is uploaded into firebase database as an item of one list in a RANDOM position(It’s crucial). This is an example:
Here is my problem: what are the chances that 2 or more players (This game is for 8 players) hit the button at the same time overwrittening/deleting each others’ data?
I cant do it offline because every player has to see the same card in the same position, that’s why i need that the “cardlist” is shuffled online!
Perhaps the problem could be solved doing all those “random placing” locally, sharing a random seed when the game start, but i cant find a way to do it.
Another solution is: every player add their card to the list as text (Using "join text block,[value from firebase]+[,]+[card]. Then the list is uploaded to one player (We can call him “the host”) the host dowload the list, shuffled it, upload it again and then all players download the new list, but i really dont like this workaround.
I am making a dice game that has to show each player the same dice with realtime updates. It’s tricky but I usually make the current players device choose and set the random dice and then it is uploaded and displayed to the others. When a player “rolls” the game has already decided on the random numbers and sent it out so eveyone gets the update at the same timeish. If you need to “place” your cards at the same time you could add a time stamp to the seconds, upload into a list to firebase, then have a the game check for the first time stamp and set it based on that. Games like this are tricky and it takes some playing around with different ways to save and call data to make it work. One thing I will let you know if you havnt already figured it out is sending and calling firebase as much as a game does, you will have to switch to the pay as you go plan as the free plan will run out of calls pretty quick.
thank you for your reply. My app has a lot of block (3000+) and i want to simplify it. Adding a time stamp is smart, of course, but i dont want to increase even more my blocks
Well, no. But i mean… it’s possible. I think there is at least 100-150 milliseconds gap between “get” and “save”, so it’s possibile, thought difficult. I’m trying to understand if there is a way to add data/information/textstring/+1 to a value in a database without download that value. Something like “this procedure will tell firebase to add (Or write) X at the end of existing value in Y database, whetever it is”. Something like the “Changing cloud variable by X” block, that already exist but it’s not good for me since i cant create variables or change variables’ name by code.
Well, maybe i dont know how. I mean… in my card game app every table (3-8 players) has his own database key. That key is created by code (The first player makes a table and chooses a name for it (the key). If i want to use cloud variables in my app, i need one variable for each table. As i know, There is not a way to change that cloud variable’s name by code, making it unique for that table? Am i wrong? I hope I made myself clear
Yes! There is! See my app examples here. You can go to sandbox app. use the side navigator and go to the screen cloud counting. check out the code. you will see how you can set pathways for the cloudvariables. you can replace any part of the pathway with the userID or your unique key.
Well, thank you sir! It works! I didn’t know that i could create variables by code. Now i can use “change cloud variables by X” block to add data without the “get-save” procedure. Thanks!
This looks like the solution to a challenge a lot of us are struggling with… the links from the “Sample Apps - BA Studios” seem presently to be broken. Thank you for making this forum so much richer.