-
Notifications
You must be signed in to change notification settings - Fork 31
SimpleSpawner: Rename frequency to period (with backwards compatibility) #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I learned about this annotation in a workshop hosted by Nathan from GDQuest.
This makes it possible to define a block that cannot be added to new block programs, but which will still work if present in a block program. The intended use is to fix SimpleSpawner's "spawn frequency" property and blocks, which is in fact the spawn period (frequency is the reciprocal of period).
da29337 to
bc93c4f
Compare
This property is the time, in seconds, to wait between spawning scenes. This is a period/interval/wavelength, not a frequency, which would be measured in Hz, or 1/seconds. Add a new property and corresponding blocks with the correct definition. Adjust the existing property to delegate to the new property. Use @export_storage to allow its value to be set from existing serialized scenes without it being visible in the inspector. This annotation is new in Godot 4.3 so bump our minimum supported version. When a scene that overrides the old property is loaded in the editor, the value will be propagated to the new property, which is then saved into the scene. Adjusting the new property also adjusts the old property's value. The old property will hang around, harmlessly mirroring the new property, in the .tscn file until it is removed in a text editor. The instances of “frequency” that I have not changed are in the example scene's on-screen documentation. In this case it was actually used correctly: the keyboard action to increase the frequency reduces the property which is now called period, and the decrease action respectively increases the period.
bc93c4f to
17d897e
Compare
|
I'm trying a third version with the ability to |
Huh, I thought I tried to do that in a test project and it worked. Testing again, I see it doesn't. Now I'm not nearly as ambitious about handling this. |
|
I tried adding an
so if I change this to:
then even with an alias so the block is still found, its parameter gets lost. I really don't have the appetite for adding named parameter aliases. Anyway, I'll push my block alias branch for posterity: but I'm not going to work on it further. I think we should either go with this one, or (my preference) #272. |
Indeed, let's just carry on with this. Ultimately I think all of this needs to be handled by adding some kind of scene migration. Unfortunately, I don't know how you'd do that exactly. |
This is an alternative to:
with backwards compatibility with existing block programs. It roughly implements @dbnicholson's suggestion in #272 (review):
Actually it has to be exported; otherwise values in existing
.tscnfiles are not set. I learned about the@export_storageannotation, added in Godot 4.3, which does what we want here. However that does mean bumping the minimum supported Godot version. And also it means that both properties will be saved in scenes – not only existing scenes which instantiated SimpleSpawner and set the old property, but also those that set the new name.I took the
hiddenpath. But having written it, I think the result is kind of ugly. Maybealiaseswould be better.It was interesting to learn some things about properties, but having written all this I kind of think we should just go with #272: make the destructive change and call the next release 0.8.0. I'm interested in other opinions though.