Godot: Call GDScript functions from JavaScript code in web export

Created on 22 May 2019  路  4Comments  路  Source: godotengine/godot

When exporting the game for web the interaction between the game and the website is limited to calls from GDScript to JavaScript. The only way to get information back into the game is via the return value of the JavaScript function.

The current workaround is to store the information on the JavaScript side and poll every frame in GDScript if new information is available.

There should be a singleton in JavaScript for calling GDScript functions.

archived feature proposal html5 gdscript porting

All 4 comments

This would be super useful to me as well.

@ChronoDK Please don't bump issues without contributing significant new information; use the :+1: reaction button on the first post instead.

Im just starting to dive in writing some support for our Crypto Wallet Application Lynx and Im having quite a hard time myself. In my case, our javascript sdk contains a number of async functions. With the Javascript.eval() function the immediate return is not quite so helpful. As the original poster pointed out, you have to poll for the result, etc. I think it would be quite useful if we hand another function that we could call into async javascript functions where you could yield for the async result. Id be willing to try and tackle this. Im just not sure where to start or what the best approach would be for Godot.

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

Was this page helpful?
0 / 5 - 0 ratings