0 votes

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

Godot version 3.2.3
in Engine by (621 points)
edited by

Do you have some code examples of your tries?

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

1 Answer

0 votes

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.

by (335 points)

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.