How to get application start parameters in HTML5 (SOLVED)

thanks i solved the issue.
So here is how to do that
1 In game.project defined new section and variable (not sure if it’s mandatory or not). (upd: Add this only if you need default value)

[test] value = 5555555

2 In index.html template instead of one string parameter you need to make an array with string parameters

that’s it.

thanks again!

upd. this is the whole section which i use

	<script type='text/javascript'>
      var engine_args = []
      {{#HAS_DEFOLD_ENGINE_ARGUMENTS}}
      engine_args.push("{{DEFOLD_ENGINE_ARGUMENTS}}")
      {{/HAS_DEFOLD_ENGINE_ARGUMENTS}}
      var url_params = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
      for(var i = 0; i < url_params.length; i++)
         {
           var new_arg = "--config=url.".concat(url_params[i])
           engine_args.push(new_arg);
         }
      var extra_params = {
        archive_location_filter: function( path ) {
          return ("{{DEFOLD_ARCHIVE_LOCATION_PREFIX}}" + path + "{{DEFOLD_ARCHIVE_LOCATION_SUFFIX}}");
        },
        engine_arguments: engine_args,
        splash_image: "{{DEFOLD_SPLASH_IMAGE}}",
        custom_heap_size: {{DEFOLD_HEAP_SIZE}}
      }

      Module.runApp("canvas", extra_params);

	    /* Fullscreen button */
	    document.getElementById("fullscreen").onclick = function (e) {
	      Module.toggleFullscreen();
	    };
	</script>

and then in lua you can use
sys.get_config("url.your_param_here")

7 Likes