YoYoGames / GMEXT-Firebase

Repository for GameMaker's Firebase Extension
Other
8 stars 6 forks source link

Firebase firestore ext doesn't work with web/html5 #25

Closed NotAnEmptyBox closed 1 month ago

NotAnEmptyBox commented 1 month ago

I have been trying to use the firebase firestore extenssion provided by YoYo games that I have discovered with this video from the official Game Maker Studio channel : video. First the creator of the video forgot to mention how to link a gms project to a firebase project but it is ok because I found the way. I have reproduced the project in the video and I have tried the project povided with the video both method worked for me to create a simple leaderboard but each time I try to export the project to html5, nothing work as supposed. I have in fact read the documentation, did the method for web setup and tried understanding the problem numerous times. But still noting work, I get this error message each time : 127.0.0.1-1721070887148.log Capture d’écran 2024-07-15 150437. It seems like there is a new method to do web setup using the FirebaseSetuf provided with the extenssion, this work even less. I am really stuck since I really want to be able to use this extenssion to do a cool leaderboard for a game jam and future project. Here is one of the many project I have tried the extenssion with GameMaker-Firestore-Tutorial (3).zip with no success. I am using the v2024.6.1.160 IDE and the v2024.6.1.208 Runtime with the lastest extenssion version : GMS2.3 - Version 2.4.4. Published June 8, 2024. As you can see on window the project work but not on html5. I would really like to know why and and get a reply not too late since my gamejam start on the 26 of July. Ask me any question if some information are missing.

Extra question: How can I create a document in a collection and get it id easily?

jzavala-YYG commented 1 month ago

Hello @NotAnEmptyBox!

I can confirm your issue, but isn't exactly the extension, it's an issue happening in the runner side and constructors, I have this hot fix for you until this is fixed in the runtime side:

basically you need split the Firestore functions:

Example 1: From: FirebaseFirestore("Collection").Set({value:choose("Opera","YoYoGames","GameMaker","Firebase"), points: irandom(999)}) To:

var aux = FirebaseFirestore("Collection")
aux.Set({value:choose("Opera","YoYoGames","GameMaker","Firebase"), points: irandom(999)}) 

Example 2: From: FirebaseFirestore().ListenerRemove(listener) To:

    var aux = FirebaseFirestore()
    aux.ListenerRemove(listener)

Just for general info, this fix works in similar way with Firebase RealTime Database

Regards

NotAnEmptyBox commented 1 month ago

Hello @jzavala-YYG,

Thank a lot for this useful and straight to the point response. It is a weird workaround and I hope it get fixed in future update but it get the job done.

Sadly, I ran out in to another problem, when I query the collection and get the "value" in the async social event, window give me a struct with all the documents as I need it but html5 give me an array instead containing the documents. This give the same result when I get the value with "FirebaseFirestore_Collection_Listener" type. The problem with arrays is that they don't give us their id, so I have no way to get to a specific document to update it or delete it later. Here is the async event code that I changed to get the value even when it is in array format : Capture d’écran 2024-07-20 124134. And here is the "value" firebase give me on html5 : Capture d’écran 2024-07-20 123059 and on window : Capture d’écran 2024-07-20 123326. I am still using the same version of gamemaker as when I wrote my other message. Should I create an other issue for this question or should I stay in this one?

Either way, I hope you can help me with this or at least give me some answers to better understand how it work

Thank again!