How to detect if engine was built as headless?

Is this possible to detect from scripts?

Maybe sys.get_engine_info().is_headless ?

No, not currently. Perhaps you could set a custom field in game.project when building your headless version or pass it in as an additional argument when you run dmengine and check it via sys.get_config()?

How does this work? Arguments passed to the executable are accessible in this way?

Yes, passed like this:

1 Like

Cool! Didn’t know this was possible but have been wondering about it.

Do you have to do --config= for each thing you want to set or can you set multiple at once?

I can’t remember :slight_smile: You’ll have to try! I think multiple --config options.

1 Like

Test.exe --config=ace.ace=7 --config=test.test=999

works

–config=ace.ace=7,test.test=999

does not

–config=ace.ace=7;test.test=999

also does not work.

This should be added to the docs https://www.defold.com/ref/sys/#sys.get_config:key

2 Likes

Did you click:

18

2 Likes

Internally, out projects use a system where they replace the game.project depending on what they target: qa.game.properties, live.game.properties etc.

So, you can use a similar approach to use a headless.game.properties, and then sys.get_config()

Also, in headless, the console (debug) is enabled: sys.get_engine_info().is_debug

2 Likes

What’s the best way to do this for HTML5 builds? Is there any way for adding custom sys.get_config() for HTML5 builds or do I need to check vars manually?

Maybe best way is to put the vars in the extra_vars and grab them with

print(html5.run("extra_params.splash_image"))

Yes you can do this on html5 as well. On my phone now so I can’t dig it up for you, but if you check the html for Blossom Blast Saga on Facebook you see it in action.

1 Like

Is it var config = { … ?

It’s in extra_params with key engine_arguments. Like this:

<script type='text/javascript'>
	var extra_params = {
		archive_location_filter: function( path ) {
			return ("archive" + path + "");
		},
		
		splash_image: "splash_image.png",
		custom_heap_size: 268435456,
		engine_arguments : [
			"--config=project.title=Foobar",
			"--config=display.width=1000"
		]		
	}

	Module.runApp("canvas", extra_params);

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

Ah, I didn’t look in canvas.js!

Useful!

It would be nice to be able to list custom arguments when running engine from editor as well. I could temp edit the game.project file but it would be more convenient to have these able to be in a separate file next to the game.project file for dev only arguments.