Opening a Godot game from another, wrong project lauches

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By andersmmg

I am trying to execute another godot game executable from my main project, but it’s just opening another instance of the main project instead.

I’ve tried multiple ways to launch it, but any way I try always launches the wrong project. It works perfectly when I put the command in the terminal myself, just not runnning it from gdscript.

Is there something else I am supposed to do for this, or is this maybe an engine limitation?

Linux, Godot stable 3.2.3

Do you have some code examples of your tries?

clemens.tolboom | 2021-03-31 19:42

Yeah, the code is really simple and straightforward, but here is where it’s launching it:

var output = []
var path = OS.get_user_data_dir()+"/"+"Laser.x86_64"
var path2 = OS.get_user_data_dir()+"/"+"Laser.pck"
OS.execute(path, ["--main-pack", path2], true, output)

This code launches the the launcher instead of the Laser game executable.
Running ./Laser.x86_64 does exactly what I need in the terminal, but not from gdscript

andersmmg | 2021-03-31 20:32

:bust_in_silhouette: Reply From: Bean_of_all_Beans

Putting OS.execute(OS.get_executable_path(), ["-p"], false) will run a new instance of the Project Manager – "-p" can be replaced with "--project-manager". Putting "-e" or "--editor" will open a new instance of the Godot Editor, opening the project you are currently running.

That false has the execution take place on another thread, allowing the main thread to continue going; otherwise, it would be blocked and could only resume once OS.execute(...) has finished doing its thing. More information on OS can be found here, in the online documentation (linked doc is “stable”, so this may change with future releases).

Also, you could hard-code the path to the executable on your machine, but as one could imagine, this would instantly break if run on any other machine, so putting OS.get_executable_path() is best practice.

If I understand right, this does the opposite of what I need. Right now, it starts a new instance, but that isn’t what I want it to do. It’s supposed to open a totally separate program, in this case a game made in Godot. It’s works as it should with any executable that isn’t a Godot game, but has this issue otherwise.

andersmmg | 2021-03-30 02:39