Attribute initialization table #4987
colorworlds
started this conversation in
Editor
Replies: 2 comments 5 replies
-
For exported variables refactoring, I believe there is an open proposal already. Your proposal seems to boil down to using Resources to initialize values. How is that safe from the same renaming variables problem? |
Beta Was this translation helpful? Give feedback.
3 replies
-
IIRC if you rename the variable you're animating, you lose the track (and no, an animation can have multiple values... one track can only animate one variable but can have multiple values, i.e. multiple dots) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Attribute initialization table
Problems I encountered
When I used Godot to develop game projects, there was a problem that always bothered me. That is, I found the exported attributes to be unsafe.Because their values are very easy to lose.
For example, I have an exported variable, the equipment name variable:
In the editor, I can assign a value to this variable to set different instances, which have the same scene.Like a
sword
and ahelmet
.But when I use it like this, there will be great risks. These attribute values ,such as
sword
and ahelmet
,may disappear after a certain modification.There are two common situations that cause attribute values to be lost:
1.Modify attribute name:
I later found that this scene can be applied to all items, not just equipment
At this time, the attribute values of
equip_name
will disappear. such assword
and ahelmet
.2.Modify the attribute of the parent scene.
If you modify the attribute value of the parent scene, such as setting
equip_name
to an empty string.the attribute value of the child scene will also become empty string. All attribute values will be lost.
3.There is another additional case. If you localize the scene, you will expand a custom node and assign its attributes, but when you cancel localization, all attribute values will be lost.
In essence, I just want an initial value that can be customized, and the initial value will not be lost casually, so why not use a specific script resource to initialize all variables of a scene?
Attribute initialization table
I hope to have a table that can initialize the attributes of all nodes in the current scene. I call it
attribute initialization table
.In fact, it is not just the exported values. When considering inheritance, the values of all child scenes may be lost due to operations in the parent scene.
I think the attribute initialization table should contain two parts:
1.Attribute Name Path (like the track name in the Animation used by the AnimationPlayer , such as
Sprite:position
)2.Attribute initial value.
Features
1.
Attribute initialization table
sheet should be a resource.2.You can specify an
attribute initialization table
for each scene to initialize the scene.3.
Attribute initialization table
will run in the editor Similar to thetool
keyword.It maybe can replace thetool
keyword.4.An instance of a scene can be initialized at one time through the code transfer an
Attribute initialization table
. for example:At present, in my game, some child scenes inherit the parent scene just to change the initial value of the parent scene to customize a parent scene.
If you use an initialization table, you can directly specify different initialization tables for the parent scene to get different scenes, so you don't need to customize the parent scene through inheritance.There is no need to create these sub scenes.
Change logic may be like this:
Beta Was this translation helpful? Give feedback.
All reactions