A question about Java Scripts. Theory

I looked at the JS documentation in GD. Everything there duplicates visual programming in GD. Question - in what cases should I use JS and what are the advantages of this?

Sorry for the bad English…

The JS events are not very nice to use, as the API is designed to be used by events first. Object selection is not out of the box there and requires more work. The advantages are that as you have to do object selection yourself you can have more control over it, and that you have access to all Browser APIs that you cannot use from GDevelop.

Personally I’m using GDevelop to overcome my obsession with writing highly optimized code and never getting to the game design work. So I only use the Javascript API for these types of occasions:

  1. The conditions/actions/events/behaviors don’t support what I need to do (i.e. detect an empty string, write to the console, generate a UUID) [Note: some of those may exist now, just examples from my memory]
  2. String parsing/manipulation. There are some string utilities built in, but it’s a lot more work than using a single JavaScript method with a regular expression most times.
  3. Complicated looping / Data Conversion. I wrote an extension to export scene data to an LDTK format and it was just much simpler to write code using normal for loops and I also needed access to some lower level collision data that is only available via GDJS.
1 Like