0 votes

So I have a pretty superficial knowledge about GDScript and JavaScript, however, I finished making a javascript gRPC web code that can request responses from the backend, and I made a function called GetHealth() that returns a JSON.

What I want is to call that function and use its value, perhaps in a label or something; is that possible? If anyone can explain me or link me to anywhere making something similar I would be grateful.

My theory is that I have to do something like this:

var response = JavaScript.eval( /* function calling */ )

However, I have no idea where my game needs to be placed or what I have to type to call that specific function. I also figured I can perhaps use localStorage, but I don't think that's a very straight-forward way to do it.

To be even more specific, the function I wanna call is inside a npm project that has a few libraries installed, responsible to convert/compile and read a .proto file, and my objective is to make a game web page.

Godot version 3.3.4
in Engine by (12 points)

1 Answer

+1 vote

Godot 3.4 has a JavaScript interface that makes GDScript <-> JavaScript interaction easier. I recommend upgrading and giving it a try. (Make a backup of your project beforehand, just in case.)

by (12,714 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.