in my game i have a stage list for each food item and for each stage i want to make the slider one larger in my toolscript so that i can select a stage my code now is: @export var stages: Array[Mesh] = @export var advance_stage: Array[String] =
and i want a slider like this: @export_range(0,len(stages))
but it wont let me
sadly this doesn’t work as @exports require a constant expression.
You can use this hack instead
@tool # add this at the top of your script
[...]
@export var stages: Array[Mesh]
@export_range(0, 99) var stage_range: # Adjust 99 to be whatever you think the highest amount of stages could be
set(value):
if value > stages.size():
stage_range = stages.size()
else:
stage_range = value
this hack will correct the range to be the value of the current size of stages.
Adjust your code to look as I’ve described, save the script, then close the scene and reopen it. @tool will then be in effect