I’m reaching out because I’m new to Firebase integration, particularly within GDevelop, and I’m struggling to grasp some of its features. Currently, I’m facing an issue where I need to change a “Field” of a “Document” with a numerical variable. However, I’ve noticed that the Firebase integration in GDevelop only accepts string variables for the Firebase Database.
Could you please provide some guidance or resources on how to handle numerical variables in Firebase within the GDevelop environment? Any help or pointers would be greatly appreciated.
Firebase is actually used to store an account and more stuff to your game.Also for mainly login and create account options for games.But for that u need to go to firebase app create a new project and copy that projects link and put in gdevelops firebase place in order for it to work.You go on web in firebase which is like like </> then register your app with nickname and copy a part of the code.
Thank you, but I already did that step, now i am trying to store a Num Var to the database, i know how to store it but for some reason at field action i can only store a String var and not a Num/Boolean etc.
So i am searching other ways to do it
I believe this is possible with javascript, though I don’t know how. But you can store your variables as strings and convert them back with a simple events.
For numbers:
Store the variable using this expression: ToString(Variable(num_var))
When getting the field, convert the callback variable and store it in your number variable: ToNumber(VariableString(callback))
For booleans, store as “0” or “1” (or you can use “false” / “true”):
if boolean = FALSE → store value “0”
if boolean = TRUE → store value “1”
When getting the field, check if the callback is 0 or 1 then set your boolean variable:
ToNumber() converts a string to a number (the string should already be made up of numbers).
So after you fetch the string and store in a callback variable (let’s say you call it “callback_var”), set your number variable to: ToNumber(VariableString(callback_var))
When i change the variable Candela from String to Number the value becomes always 1. When it goes to the Firebase Database. I have a big issue with “Update the field”
A basic solution would be to save the time when the 24hr starts, then check if the current time > saved time + 24hrs. Use the expression Time(“timestamp”) which gets the device’s current unix timestamp in milliseconds.
I understand the logic but If i follow this path the player/user have the reset on his Hardware, while i want a reset on the server (I need to make some multiplayer stuff), so i need to do this thing in Firebase and not in Gdevelop i suppose. Or I am wrong?
I’m sorry I can’t help you with this, I believe this can be done through firestore functions and I’m not an expert with it. I can help you more with stuff related to GDevelop.
Do a quick google search, maybe you’ll find your answer, or you can ask on platforms like stack overflow. Good luck!
I have another issue now i have a Global Structure Variable called “Saves” where is store all User data, but I can’t put this Structure Var in the Firestore Database because there isn’t an expression to take these Var, so what i can do now?