Can a compiled script (.gdc) be added to a project just like a normal script?

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

I fear I already know the answer but I just want to confirm. Can it be added to a project and used in the usual way?

Ideally what I’m looking for is a way to prevent a script being accidentally edited in some way, and this seemed an ideal solution, in leiu of not being able to create (say) something like a DLL.

:bust_in_silhouette: Reply From: Lopy

Not sure about .gdcs, and not something I care to check. A big problem with using this method would be that you would also not be able to easily read the script yourself, which would likely cause issues with function names and the like.

To make a script (pseudo) read-only, you can:

  • Use your file system’s permissions, to make yourself unable to edit it (until you grant yourself the permission again). This is very OS, filesystem format and file manager dependent. It might be impossible or just as easy as clicking a button.

  • Use symbolic links (or even hard links). This lets you have the exact same file in multiple places in your file structure, turning your file architecture from a tree into an acyclic-graph. Again, it depends on your OS and filesystem format.

  • Use Godot’s load function with paths outside of res://. You could have a folder somewhere with all your “dlls”, and use load to load those scripts. You can even write var MyScript = load("/path/to/my/script.gd"), and then use MyScript.new() (inside the script with the variable MyScript). The main issue is that completion, typing, and symbol lookup (ctrl+click), won’t be available.