Dose node contain internal script?

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

Hi, new to godot and have been playing around with scripts in my game. Normaly when I save a script it´s name is “nodname.gd” (I am unsure of how I got there) but if I delte the script from the file system and resave it the node it was attached to retains the script and the script gets a new name like “nodnema.tscn::2”. Is this some kind of internal script for the node?

When attaching a new script to a scene, if the scene is already saved to the filesystem, by default the script file will use the same file name.

zhyrin | 2023-02-10 10:36

:bust_in_silhouette: Reply From: zhyrin

Scripts (and resources for that matter) can be external (e.g.: saved in a separate file) or built-in.
If it’s built in, the content of the script is not in a separate file, it’s in the file of the scene (.tscn most likely).
You can check out this file in a text editor and you’ll see it has a script resource defined in it and the entire contents of the script is written into the file.
In a .tscn file, resources are numbered. nodenama.tscn::2 means the script it uses is the second resource in the nodenama.tscn file.

When you deleted your script file, godot checked if you had any references to it. Since you did in your scene, simply deleting the script would break how your scene works, so it copied it as a built-in script before deleting.