Godot version: 3.0.6.stable
Tested with Firefox 65 and Chromium 72
Issue description:
To avoid duplicating files and be able to translate my HTML text in a Wordpress website, I have to place my game resources files (.js, .pck, .wasm) at another path than the HTML file (generated by Wordpress at an arbitrary path). So I tried to submit another path to the engine.startGame() function in the generated HTML file.
The .wasm and .pck do load, but the game don't start sending an error "No such file or directory". Nothing in the browser console.
I tried to unminify the .js file to find where the error is, but it's beyond my skills. I also read in bug #12498 that I may use Engine.initEngine('path/to/godot.wasm') before calling game.start('path/to/godot.pck') but that function is undefined.
Steps to reproduce:
Here is an export of my game where I simply created a directory called moved where I put the resources files (.js, .pck, .wasm), and I try to load the game by changing the path at engine.startGame() function line 379 of the index.html file
Obviously the game works if everything is in the same folder ;)
For now I can use a workaround in Wordpress by creating an iframe for the game, but that prevent fullscreen to work.
Is there a bug in the generated javascript or should I use another undocumented function ?
@eska014 can you bring your lights ?
Thanks a lot in advance
Engine.initEngine was renamed to Engine.load before 3.0 release (reference at https://docs.godotengine.org/en/latest/tutorials/platform/customizing_html5_shell.html).
So the code should look something like this:
.js
Promise.all([Engine.load('basepath/to/godot'), engine.startGame('path/to/godot.pck')]).then(() => {
// ...
Base path is the path without file name extensions, e.g. engine/godot for engine/godot.wasm.
By the way, you can allow an iframe to request full screen by adding the allowfullscreen attribute <iframe allowfullscreen='true'>
Thanks a lot for your answer Leon, but I get an error TypeError: engine.load is not a function
if I write
engine.load('<?php echo $game_url; ?>' + BASENAME );
engine.startGame('<?php echo $game_url; ?>' + BASENAME + '.pck').then(() => {
setStatusMode('hidden');
initializing = false;
}, err => {
if (DEBUG_ENABLED) {
printError(err.message);
console.warn(err);
}
setStatusNotice(err.message);
setStatusMode('notice');
initializing = false;
});
I suppose I'm doing wrong... ? Sorry if it's not a bug, I must admit documentation is not obvious to me.
Thanks for the iframe tip by the way... !
If I use Engine.load() or Promise.all([Engine.load('basepath/to/godot'), engine.startGame('path/to/godot.pck')]).then(() => { it still doesn't work, here is what Firefox return, much more verbious:
Object { node: undefined, setErrno: setErrno(), errno: 2, code: "ENOENT", message: "No such file or directory", stack: "<generic error, no stack>" } turbo-dispute:445:8
You have to change basepath/to/godot and path/to/godot.pck to the paths on your server
Yes, obviously, I did it ;)
Please link or upload some export sample where this happens. With HTML, pck, Wasm, and JS
I must apologize, because with a fresh export and the exact same edit using
Promise.all([Engine.load('moved/' + BASENAME ), engine.startGame('moved/' + BASENAME + '.pck')]).then(() => { as I did before, it now work.
I suppose I should have tested to export again before because it must have been fixed by a 3.0.X version of Godot. For memory and prove I wasn't hallucinating here is an example of a buggy export (with a previous 3.0 version).
Thanks for your time and advices anyway !
@nylnook Are you still launching the game from another path? Are you able to share an excerpt of your index.html? I'm trying to launch the game from another path (game running on CDN) with Godot 3.2 and hitting various errors. It looks like startGame() takes two arguments now:
Promise.all([Engine.load('HTML5/index' ), engine.startGame('HTML5/index','HTML5/index.pck')]).then(() => {
Using the above gives the following error:
Error: Couldn't load project data at path ".". Is the .pck file missing?
@DavidjMarkham Did you try using Godot 3.2.1? This pull request was merged: https://github.com/godotengine/godot/pull/36165
@DavidjMarkham I finally used an iframe, but you can look at it online here : https://nylnook.art/en/game-viewer/turbo-argument/ (check the source code). Hope this help !
@Calinou Thanks so much! Building with 3.2.1 fixed it! I'm now able to launch the game from one path, and load the .js, .pck, ans .wasm from a different path.
@nylnook Thanks for the link, it was helpful to see how you are launching the game. I'm able to launch now outside of iframes. iframes were causing a number of issues for me, due to browser security issues as well as game integration with our web api.
Most helpful comment
@DavidjMarkham I finally used an iframe, but you can look at it online here : https://nylnook.art/en/game-viewer/turbo-argument/ (check the source code). Hope this help !