-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Recognize inf, nan, and inf_neg constants (note: lower case) #3390
Comments
Instead of allowing The naming convention in GDScript is that constants are uppercase. |
@aaronfranke I would prefer that, yes. As far as I can tell, the inspector shows the serialized value. Are you suggesting to make an special case for the inspector or to change the serialization? The serialization could have been |
I also think we'd better fix the output of the values to match the value literals, but not vice versa. See also godotengine/godot#47502 (and a few more, but I'm too lazy to search). |
@dalexeev @aaronfranke What do you think of #3398? |
Closing in favor of #3398, which seems to have more community support. |
Describe the project you are working on
This is how I stumbled upon this: I was making a custom node that would have an optional maximum distance check. So I exported a variable for the maximum distance. Note: Godot does not have a nullable float type. And I figured that a good way to disable a maximum distance check is to use
INF
. In fact, I can check forINF
in the code to short circuit it.Describe the problem or limitation you are having in your project
This is purely an usability concern.
Most float literals can be typed verbatim in the code inspector. Except for
inf
,nan
, andinf_neg
. Instead we have to useINF
,NAN
and -INF
.Describe the feature / enhancement and how it helps to overcome the problem or limitation
Considering that godotengine/godot#47497 / godotengine/godot#47497 is merged.
The code inspector uses GDScript expressions (this is how -
INF
works, it is the negative of the constantINF
). Thus the evident solution would be to add newinf
,inf_neg
andnan
constants to GDScripts.Honestly, I don't think GDScript needs those constants. And my concern is with the inspector panel.
The alternative is, of course, change the Variant serialization. Which is a breaking change.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
With the new
inf
,inf_neg
andnan
constants in GDScripts, any float literal can be written verbatim in the inspector the same way they are serialized / represented in the inspector. Being the inspector input is a GDScript expression, it would recognize those proposed GDScript constants.If this enhancement will not be used often, can it be worked around with a few lines of script?
Writing
INF
orNAN
in the inspector has no precedence… Since it didn't work. Now it is bound to happen, and if anything you can point people here.However, honestly, it probably isn't a common use case, since a lot of things won't work with those values. For example RayCasts don't work #3389.
And yes, we have a workaround. We can use
INF
andNAN
.Is there a reason why this should be core and not an add-on in the asset library?
Cannot be done with an asset.
The text was updated successfully, but these errors were encountered: