0 votes

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.

Godot version 3.4.2
in Engine by (440 points)

1 Answer

+1 vote

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.

by (2,630 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.