Folder in OS.shell_open()

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

I want to launch a local html file so I put it in the project root, with the project.godot file, and later in the executable folder, call it with OS.shell_open(“index.html”); and it works.

But if I made a dir named html and place the html there, then call it with OS.shell_open(“html/index.html”); it doesn´t do a damn thing, nothing, nada, zero, not even throw an error.

Is for the “/” character? What am I doing wrong?

Thx,

Belén

From the looks of the description of the function:

Requests the OS to open a resource with the most appropriate program.

It would seem that the default program isn’t running for the desired resource. So there’s some setting in the OS which isn’t launching a web browser and then loading the HTML page. The Godot IDE may be handling this stuff when the game is run from the editor. But outside of the editor, the OS may be handling the HTML file in some other fashion.

Maybe the OS doesn’t want to open up a web browser? Also, it looks like the shell_open() function can return an error message. Maybe the return message can be checked?

Ertain | 2019-05-03 20:55

As I said, it works fine both in the editor and in te executable when the path is “index.html”. But when is “html/index.html”, it don´t work in the editor neither the executable, nor return any kind of error message. The only difference between working ok and not working at all is the path.
Is not an OS problem, is just a Godot engine one.

bethleem | 2019-05-04 09:39

:bust_in_silhouette: Reply From: Calinou

Try opening the absolute path to the file:

OS.shell_open(OS.get_executable_path().get_base_dir() + "/html/index.html")

Yeep, it works. Not in the editor but in the executable, just fine. :slight_smile:

Thx SO much.

Belén

bethleem | 2019-05-05 09:44