Is there a way to see if a script is attached to a node?

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

More specifically, when I’m browsing the scripts in the resource folder (res://), is there a way to check if a script is being used by my game ? In other words, is the script attached to a node ?
It’s kind of a bother to have to click all scenes an check all nodes to see if one of them uses the particular script …

:bust_in_silhouette: Reply From: shmellyorc

in your godot filesystem, NOT YOUR OS. right click the script and click “view owners”. it will show what scenes is using that script.

Ah ! Cross post ! =)

siska | 2019-05-06 18:24

:bust_in_silhouette: Reply From: siska

Ah. Of course. I Just found it !

You need to go to the resource folder (res://), right-click a script, and then go to 'view owners. You can’t do this from the script sidebar !

Fair warning to anybody coming across this in the future, this will not provide a holistic view of nodes that may depend on your script

The example I’ve run into is I’m trying to understand how the multiplayer bomber demo works, and I wanted to know how this file is being used: godot-demo-projects/networking/multiplayer_bomber/gamestate.gd at 4.2 · godotengine/godot-demo-projects · GitHub

It looks like you’re able to just straight up reference these top level script files from other scripts without importing them or attaching to a node: godot-demo-projects/networking/multiplayer_bomber/lobby.gd at 4.2 · godotengine/godot-demo-projects · GitHub

Which in this case begs the question of why the hell they’re using a _ready function in the gamestate object if it won’t ever exist in the scene?

TLDR; you also have to search for the filename and see if it’s being referenced in another script

Quite a spaghettified language with poor examples :confused:

gamestate is an autoload, i don’t know why they didn’t capitalize it like the other singletons built into the engine, i agree about the spaghetti tho, they are using self for some reason :face_vomiting:

1 Like

Oh wow, I see what you’re talking about: Singletons (Autoload) — Godot Engine (stable) documentation in English

You would think the “View Owners” option might want to mention that its registered a global object that can be accessed by anybody?

I am baffled that people are able to successfully build games in this thing lol. Thank you for your help

1 Like