I’m integrating my existing pitch detection code for a friend into gdevelop. This JS code depends on a webassembly module.
Given that gdevelop can run both in browser and in electron I assume that there is an API or standard for loading data blobs from extension code? Where should I put the wasm file to be accessable from the extension?
Hello fellow JavaScript game dev! Welcome to the forum! this forum and the people who are here are GDevelop devs… GDevelop is a no coding game engine, and so this forum is gear towards just that! I’m here a fellow JavaScript or just plain software developer cause i want to learn all i can about how the developers attended for us to use the tool and than push it to do what i want!
Anyway your best bet is to head over to our JavaScript party friends at GitHub and post this question there as they are more likely to be able to help you!
this questions sound like something to post under:
What are you talking about, this forum is for everything around GDevelop, including JavaScript usage in it.
That is most definitely false, the GitHub issues are not for questions and the GitHub discussions topic you linked is not for JavaScript questions but for contributors to GDevelop’s source to ask a question about the internal code of GDevelop. The GitHub is not the right place to ask any other type of question.
And now to actually answer the question. GDevelop doesn’t allow to manipulate resouces, and therefore can’t let you have your extension include a file in the export. What you will have to do is embed the binary in the JavaScript code in the onFirstSceneLoaded function. I suggest also compressing it to make the extension smaller, for example with pako.
You could do a node script something along the lines of
Read binary file
Compress it into an UInt8Array with require(“pako”).deflate
Write The UInt8Array as string (use something like let string = "new UInt8Array(["; for(let i of array) string += i + ","; string = string.slice(-1) + "])";) into a file
Execute the script, copy it, then in your JS event, do somwthing like
// Insert pako.min.js file contents here to import pako
const compressedFile = /* Paste the generated array here */;
const rawFile = pako.inflate(compressedFile);
// Do your thing with the binary file, e.g. WebAssembly.instantiate(rawFile, ...
I wouldn’t say that GD is just for beginners to game development as its a well designed abstraction. The events system allows easy implementation of common behaviours with the trivial ability to fall back to JavaScript for things that it can’t do.
It looks like it would be useful for me for quick prototyping of ideas.
@arthuro555 every dev questions i ask and ever dev questions i seen ask point to the gui way of doing things when a questions about the code way of doing something. And you right, github repo isn’t a place i just found out to ask simple questions related to more in depth. @Silver-Streak pointed me to the discord than lock my self answer post, but the discord offer no channel to even type in. So I guess you right that this is the best place to ask any questions as it is more accessible than the other two. And yes you right @Robehickman , gdevelop is well designed abstraction although i wish it utilities more advance features like events trigger by other means than in the game loop, and if else would be nice with the conditions to make one conditions two conditions and async than would be nice to wait for something to finish… but as you said, it can be extended if you really want those features.
I agree about events being triggered by different things. However gdevelop’s events are not ‘events’ in the sense the term is used in other programming languages. They are really just a long string of if statements called from top to bottom once per game loop. Personally I wouldn’t have called them ‘events’ at all if it was my project. In most languages an event is a message - a piece of data - which can be acted on.
Given that what it is is already a long string of if statements, adding an ‘else’ clause should be easy, and I agree would be a good idea.
Async / running something as a thread is probably best handled by just using javascript as it already has good abstractions (promises, workers and message queues). Having a way to run something in a worker would be a useful though.