Can I import modules/libraries?

Hi there! So Discord recently released a new SDK that allows you to create games that run embedded within Discord. After accepting some permissions, Discord serves the user a webapp. Now, making games in pure html css and Javascript is a quite a pain, even with frameworks to help. So that’s where Gdevelop comes in.

Ideally I’d like to make my game using Gdevelop, but I’m unaware of how I can interact with the SDK from within Gdevelop. Of course, I could just export the project as HTML 5 and edit the source manually, but that would still be less than ideal given if I want to change even the smallest thing about the game or how it uses the SDK, I’d have to export and readd the SDK logic all the time.

I’d like to be able to create my own extension that adds some events to interact with the SDK, but as far as I’m aware there isn’t a way to import and use modules or libraries in Gdevelop. Any advice?

GDevelop supports Javascript.

I am aware. But how can I import and use modules? Gdevelop’s built in JavaScript editor is quite lacking given it’s a primarily a no code engine. There is no way to do an npm import as far as I’m aware, and then be able to access those imported modules.

Even without a package manager like npm, just using your own custom exported modules doesn’t seem possible or at least practical given that code blocks are well, just that, a block in your event sheet. So you can’t really import/export them between other code blocks. Even if you could, it’s not very practical given you’d still be writing all the logic in a single event sheet, at that point just write all your code in one code block.

  • do your thing that uses modules in a file in your preferred JS development environment
  • bundle it all to an IIFE target
  • load the bundle in the js event, and use it

you can also just wait for someone to do it :‎p I also saw this yesterday and was about to create an extension for this myself :sweat_smile: