Is it possible to make a Defold program that can open files? As in, you can right-click on a file, select “Open With… My_defold_program.exe”? Or to associate a file extension with the program so you can just double-click on files to open them with it?

Good question. I have no idea. What’s requirements for a “normal” OSX or Windows app to be able to handle an “Open with” command? Can it be achieved with a native extension or do we need to expose more of the app startup lifecycle? (And what’s the use case for this?)

It seems like (at least on windows) when you run the game .exe, it first opens the ‘game.projectc’ file and tries to use it. You can open other .projectc files with it and it works fine unless that file contains weird or missing information.

I would use this for making better tools with Defold (not an intended purpose, I know). At the moment I want it for my multi-image-viewer, so you can double-click on its save files to start the program and open the file, rather than having to start the program, press ctrl-O, find the file, and open it. It’s just much more convenient. Actually I think I already figured out a hacky solution—I should be able to make save files that are like game.project files, but with my extra save information included.

It would be cool to have this feature for other projects though (where the above method definitely won’t work). For example, what if, with my polygon editor, you could double-click a ‘.convexshape’ file anywhere on your computer and the editor would start up and load the file. That would be nice!

Obviously, Defold isn’t meant for this sort of thing, so this isn’t a feature request, I’m just wondering if it’s possible.

If you specify arguments to the engine, the game.projectc should be last. So, it might be a good thing for you to wrap it in a script which you can call instead, in order to control the cwd and arguments

@britzl
Appgamekit has had this requested as well, and the community made a plugin that does it. Not sure if it will help, but maybe the code in it might contain some hints:https://forum.thegamecreators.com/thread/219724
Unfortunately the plugin only handles cmd line arguments for windows

As I said, for desktop it should in theory be easy, but as the original post says, it seems like the engine already checks for additional command line arguments and if those aren’t correct things go wrong.

(Android is trickier though as it uses a completely different system. You’d need to modify your manifest file (not hard) but you also need to have access to the main activity of your app, which currently isn’t possible to do.)

To sum things up: Defold isn’t really made for this sort of thing and I’m not sure if it’s something we should focus on improving. I’ll leave that for @sven, @Mathias_Westerdahl and @Johan_Beck-Noren to decide.

If you specify arguments to the engine, the game.projectc should be last. So, it might be a good thing for you to wrap it in a script which you can call instead, in order to control the cwd and arguments

Just to reiterate that currently, our command line dictates that the game.project file should be the last argument if you wish to launch the engine with command line. As @britzl mentioned, there are API’s to get the command line in an app in C++.