Hello guys! I am building a web-based game in which I need a paramter that is passed from my webpage, that embedds the game with an iframe, into the game itself hosted on another webserver (mine) or itch.io both is fine.

Anyone has a clue how to do this? I am using the C# version of Godot.

I tried to follow this page: https://docs.godotengine.org/en/3.2/tutorials/platform/customizing_html5_shell.html#doc-customizing-html5-shell

To create a costum html page for the game, passing command line parameters using the engine.start(["args"]); function, but I have no idea how to follow up after the engine.start() function. I am supposed to call engine.load(basepath) after, but I get an error, that this function doesn't exist.

I also tried this

Use JavaScript.Eval(""); function

string test = (string) JavaScript.Eval("window.test");

But this just fails and the game doesn't seem to be able to fetch the window.test variable. But when I console.log(window.test) it shows it in my console inside the browser.

I am embedding my game into my website using <iframe> , maybe that is the issue?

I want to pass an argument from my website (a number) into my game. Anyone got an idea how to do this?

Sorry for bad english. Not my main language. And thanks guy s :)

4 days later

The issue is because you're referencing window from an iframe. iframes have a different window variable than the window they're embedded in, so that's why it works in the console but not in Godot. You can fix this by replacing window.test with window.parent.test, which will get the test variable in the window the iframe was embedded in. See: https://stackoverflow.com/a/7647123

a year later