Use startparams for HTML build (SOLVED)

Hey,

I am wondering if it would be possible to run my game with startparams? My plan is to have a link or GET/POST param when opening a page which includes the html build of my game to prefill variables like a username/nickname. I am open for other ways. My maingoal would be to run the game with a prefilled nickname field.

Does anyone have an idea how to manage this?

best regards,

clarix

This is easily possible for GET

For POST params you need your server to digest the POST and embed values into your extra_params

You can also just embed the values you want to get into JS values and get them easily with html5.run(“variable”)

Cookies would be possible too.

1 Like

This is just lovely.

Gonna try both solutions tomorrow.

I just tried out your first example. As soon as I add the parameter to the url I am getting the following Error in Defold:

    java.nio.file.InvalidPathException: Illegal char <?> at index 10: index.html?lang=de

This is a known issue in the Defold fileserver. If you test with any other fileserver like HFS it will work.

I just thought about that. Is there any way I can send console output to the debug console in browsers to quickly test those stuff?

I think HTML5 console output is current bugged if you do Build->Html5 because it might still be doing a release mode only.

You can try https://www.defold.com/community/projects/76578/

Easiest thing you could do for testing is to manually edit your game.project file and include whatever flags you want for language or game mode that you are currently testing then get with sys.get_config(). This is what I do when testing these kinds of things on Windows builds for example. In my project, I support the game.project method, the extra_params method, and the GET method.

GET supersedes extra_params which supersedes game.project values in my projects.

1 Like

Just tested it with my dev webserver. Works like a charm. Thanks alot! :slight_smile:

If you use print()and pprint(), the output shows up in the debug console.

Did not work for me yesterday on Windows 10/Chrome 69.0.3497.100 and print().

Gonna test ist with pprint() later :slight_smile:

What editor version are you using?

Debug versions for HTML5 are working for me again in latest. Make sure your editor version is up to date.

I am using the editor 2 - Version 1.2.137

Then it should have worked for you.

I wonder, do you use an .appmanifest?