Method for the path to .tscn ?

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

I have found out how to get the path to the current script:

get_script().get_path()

I would like something similar to the above,. but for the path to the current scene.

:bust_in_silhouette: Reply From: Koroshiya

I have multiple scenes, when I press the “Back” button in the game, I want to be able to change scene to the last scene before the current scene.
So, before I do get_tree().change_scene() I want to store the path to the current scene in a global.array, so that in a future scene I can return to the last scene stored in the global.array.

As above, this too should be a Comment, not an Answer. Otherwise, people looking at the forum overview page may ignore the question as it already appears to have been answered.

jgodfrey | 2020-09-10 18:17

:bust_in_silhouette: Reply From: Zylann

Nodes have a filename property. If a node is the root of a scene instance (like the current “scene” is), filename will contain the path to the scene file.

For anyone using Godot 4.0; filename has been renamed to scene_file_path.

Ninfur | 2022-10-23 15:05