Missing wrote: ↑March 19th, 2023, 6:48 pm
I was wondering if there was a way to make the example bellow work.
There is in fact, however not the way you tried.
As you saw, you can't use formulas in the MeasureName option, especially not one which is altered "on the fly". So we need another approach. Here is one.
You need a measure which gets the value of the variable and converts this value into the name of the appropriate measure. Add the following measure to your code:
Code: Select all
[MeasureScrollPos]
Measure=Calc
Formula=#ScrollPos#
RegExpSubstitute=1
Substitute="^(\d{1,2})$":"MeasureImage\1Download"
DynamicVariables=1
This measure is getting the ScrollPos variable and adds MeasureImage in front of it and Download after. This way the string value of this measure is the name of the measure which has to be used into the MeasureName option of the [MeterGame1Image] meter.
Modify the above mentioned MeasureName option of the [MeterGame1Image] meter to: MeasureName=[MeasureScrollPos] (and if anyone askes, no, the brackets are not mistake, they have to be there, to let the option to use the string - or substituted - value of the measure).
In order to get the whole scrolling working smoother, you can add a [!UpdateMeasure "MeasureScrollPos"] bang to the MouseScrollDownAction and MouseScrollUpAction options of the [MeterGame1Image] meter.
Additional tip: to don't complicate things too much, I'd replace the formulas used into the !SetVariable bangs of the MeasureScrollDownAction and MeasureScrollUpAction options of the [MeterGame1Image] meter, using the Clamp function. With all the above additions, the meter should look this way:
Code: Select all
[MeterGame1Image]
Meter=Image
MeasureName=[MeasureScrollPos]
X=0
Y=0
MouseScrollDownAction=[!SetVariable ScrollPos "(Clamp((#ScrollPos#-1),0,10))"][!UpdateMeasure "MeasureScrollPos"][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetVariable ScrollPos "(Clamp((#ScrollPos#+1),0,10))"][!UpdateMeasure "MeasureScrollPos"][!UpdateMeter *][!Redraw]
DynamicVariables=1