this post was submitted on 30 Jul 2024
17 points (94.7% liked)
Godot
5916 readers
18 users here now
Welcome to the programming.dev Godot community!
This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.
Make sure to follow the Godot CoC while chatting
We have a matrix room that can be used for chatting with other members of the community here
Links
Other Communities
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
Rules
- Posts need to be in english
- Posts with explicit content must be tagged with nsfw
- We do not condone harassment inside the community as well as trolling or equivalent behaviour
- Do not post illegal materials or post things encouraging actions such as pirating games
We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent
Wormhole
Credits
- The icon is a modified version of the official godot engine logo (changing the colors to a gradient and black background)
- The banner is from Godot Design
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Yes exactly. but how do I detect a specific script in my scene view? Or in other words: how do I find the source of my meta information in a scene?
Oh you want to know the name of the script that was previously attached to a node?
get_script().get_path() should return the filepath to the script that you used, not sure if thats what you want tho.
not the name, the
class_name
I set inside of the scriptI added an example in the thread
I see, looks like that is actually an issue.
https://github.com/godotengine/godot/issues/21789
Seems like you have to overwrite the get_class function if you want to detect custom classes.
But is my solution actually a good one?
Defining a unique class name gets you the same thing as giving each script a unique filename and then differentiating between the get_script().get_path() but i can see how its not as clean for comparison.
Another solution would be to just give all your custom classes a var called "class_id" or something and then you can read that out if you need it.
Oh I meant the general solution for getting level / scene meta data 😅
Im assuming you have a predefined level scene, which you instantiate and add as a child to your main scene. If i were to save a bunch of metadata about that level scene, i would add a dictionary named "level_data" to the script of the root node of that levels scene.
After you instantiate that level from your main scene with:
You can then get or modify the metadata from that instance reference.
When you are done you can then add it as a child to the main scene with add_child(level1).
You can also do that right away and access the data later ofcourse, but if the values are needed in the _ready function of the level, then you need to modify them before adding it to the main scene.
That seems very nice. Thanks for the input :) I am very much new to Godot and I gotta say most Unity systems in my head still work, but some just let me run against a wall, like the one I described here XD
Added something to the previous comment.
Im also not super experienced, i just make unsuccessfull attempts at making games from time to time :) But i do love godot a lot.
You generally use the same logic for literally everything in godot.
Spawning a bullet, enemy, item, ui component?
Ah good find, I will read through that shortly, thanks :)