How to reference the editor's default float step from code?

Godot Version

Godot 4.3.stable

Question

When exporting a float with @export_range I cannot add the “or_greater” extra hint without specifying a step first. The default value for the step is (Editor) > Interface > Inspector > Default Float Step. How can I still use the “or_greater” hint and keep the step defaulting to the default float step as specified above? How can I reference this editor setting from the code?

1 Like

Why not just make the step the same as the default?

Have you tried putting zero? Or left it blank with an extra comment?

According to the gd parser it needs to be the forth argument.

Making it the same means that it won’t change as the default changes.

Putting in zero seems to allow any float values to be imputed through the slider. It definitely does not follow the default value.

Leaving it blank is treated as an error in the editor. Specifically: Expected expression as the annotation argument.

@export_range(0, 1, , "or_greater") var a : float
1 Like

I think your out of luck on this. Although I don’t see the problem of setting the resolution manually. I would think an exported variable like this would require some resolution control based on its context. Which the project default step could never given context.

I might have one last suggestion, but I’m not at Godot to try.

Can you place the project variable into the parameters, or does it say literals only?

Putting in a variable like so

@export_range(0, 1, my_var, "or_greater") var a : float

gives an error in the editor. Namely "Argument 3 of annotation “@export_range” isn’t a constant expression.

I don’t know how to access the project variable, or if it would yield the same error.

1 Like

I mean how badly do you need that.
if you really want to get into endless problems their is always EditorInspector and EditorInspectorPlugin.
but I really really don’t recommend going down the scope creep rabbit hole.
it’s been a about a while but I think property_edited signal then _parse_property to deal with changing the thing the user of the plug in is trying to change.
anyway it’s a place to start.
I am being unfair you are only changing one thing perhaps I just tried to do to much and got in over my head.

I don’t know how you can get the default value for this in GDScript. But I think you should at least be able to work around this “constant expression” error by using _get, _set, and _get_property_list instead of @export_range.

And I think it may alternatively be possible using _validate_property?

1 Like