Random beginner-question: scipt shows in Editor-Scene but not in FileSystem

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

Hi everyone,

the program works fine. I can click on the little script-icon next to its Node in the Scene-tree in the Editor, but it’s nowhere to be found in ther FileSystem. This applies to a couple of scripts in my project. I’m confused, it’s obviously there but…not really?

How can I make the scripts re-appear in their folders?

Is the script built into the node? The engine has a feature where a script can be embedded into a node.

Ertain | 2021-04-12 17:59

I don’t really know. In the Inspector the path leads directly to a scene…
Right-click - attach script is the way I do it.

If it’s built into a node, is there a way to “extract” it? I like my scripts stored in their folders.

pferft | 2021-04-12 18:23

:bust_in_silhouette: Reply From: Hoimar

You probably stored your script(s) directly “in the node”, or rather as an internal resource of the scene (when you open the .tscn file in a text editor, you should see the code).

To save the script as file, open the scene, click on the node in question, then in the inspector, go to the “Script” property and click on the little arrow to the right of the script, where you can select “Save” to save it like any other resource in Godot.

As I mentioned in a comment below, I assume this directly-in-the-node storing happens when I accidently erase a folder with my files in it (which might have happened here) as a lucky backup, so the scripts don’t really get lost? I wouldn’t even know how do deliberately store one “in a node”…

But anyway, thank you, your hint is exactly what I was looking for!

pferft | 2021-04-13 08:52

Yes, that’s a way for this to happen. You delete the underlying script files while still having the scene open, then save the scene again (all resources are still loaded in memory), and Godot will embed the scripts as resources into the scene.
On a related note, you should of course not rely on a “lucky backup” but make a proper (automatic) backup of all your important data regularly :slight_smile:

Hoimar | 2021-04-13 15:23

Thanks for the insight. So if I’d close the Editor without saving the scene once more, the scripts would really be lost, I take it.

No worries, my drive is flooded with backups! ; )

pferft | 2021-04-13 15:46

:bust_in_silhouette: Reply From: Inces

When You clicked on script icons, You must have already named new script and chose its path, before You could even create it. From that moment, they must have been placed in file system.
Maybe You are searching wrong, You know that scripts are*.gd and scenes are *.tscn ?

Unfortunately I can’t choose two answers as “best”…

You’re right of course, and it ususally works fine. My theory in this case: I “cleaned up” the file folders a bit and I can imagine that I accidently “erased” some scripts, but then again, “not really”, as it appears. So perhaps instead of a script getting lost completely (which would be bad) it then “bakes” into the scene? Sort of saves the day, I guess.

Thanks for your help!

pferft | 2021-04-13 08:45