It is currently December 12th, 2019, 8:14 pm

Randomizing on a specific value

Help with creating, editing & fixing problems with skins
Ignetia
Posts: 2
Joined: November 30th, 2019, 11:34 pm

Randomizing on a specific value

Ignetia » November 30th, 2019, 11:49 pm

Hi,

I'm trying to randomize a set of folders with GIFs inside of them, and every time the GIF reaches a certain frame/PNG, the randomizer should turn on again to switch to another gif, but the randomizer doesn't seem to trigger unless I refresh the skin entirely. Here is the code (I turned on DynamicVariables on all of them because I was unsure which one was at fault):

Code: Select all

[MeasureCalcy]
Measure=Calc
Formula=(Random)
LowBound=1
HighBound=2
DynamicVariables=1

[Variables]
Randomizer=1
DynamicVariables=1

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 44


[ImageMeter]
Meter=Image
ImageName=#@#\Card_Frames\#Randomizer#\frame_[ImageNumberCalc].png
IfCondition=[ImageNumberCalc]=43
IfTrueAction=[!SetVariable Randomizer "[MeasureCalcy]"][!UpdateMeter *][!Redraw]
W= 456
H= 503
AntiAlias=1
DynamicVariables=1
Apologies if the code isn't showing correctly, this is my first time posting.
Last edited by Ignetia on December 1st, 2019, 2:15 pm, edited 1 time in total.
mak_kawa
Posts: 371
Joined: December 30th, 2015, 9:47 am

Re: Randomizing on a specific value

mak_kawa » December 1st, 2019, 2:04 am

IfCondition expression can be located only in measurers, not meters. Move it to [ImageNumberCalc] measure.
User avatar
balala
Rainmeter Sage
Posts: 9258
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Randomizing on a specific value

balala » December 1st, 2019, 1:52 pm

mak_kawa wrote:
December 1st, 2019, 2:04 am
IfCondition expression can be located only in measurers, not meters. Move it to [ImageNumberCalc] measure.
As mak_kawa said, the IfConditions don't make sense on meters, they have to be used on measures. But there are other issues as well.
  • A DynamicVariables=1 variable, declared into the [Variables] section doesn't make sense. Remove it.
  • When checking an IfCondition, section variables don't have to be used, especially that in this case [ImageNumberCalc] returns a number, so its equality with certain value can be checked even if you1re not using section variables (as you did on the IfCondition=[ImageNumberCalc]=43 option of the [ImageMeter] meter - this has to be moved to the [ImageNumberCalc] measure).
  • The #@# variable already has a backslash, so there is no need to add another one. However even if add one or more it still works, but technically it's not needed. I removed it from the ImageName option of the [ImageMeter] meter.
With these, the code should look like this:

Code: Select all

[Variables]
Randomizer=1

[MeasureCalcy]
Measure=Calc
Formula=Random
LowBound=1
HighBound=2
DynamicVariables=1

[ImageNumberCalc]
Measure=Calc
Formula=( Counter % 44 )
IfCondition=(#CURRENTSECTION#=43)
IfTrueAction=[!SetVariable Randomizer "[MeasureCalcy]"][!UpdateMeter "ImageMeter"][!Redraw]

[ImageMeter]
Meter=Image
ImageName=#@#Card_Frames\#Randomizer#\frame_[ImageNumberCalc].png
W=456
H=503
AntiAlias=1
DynamicVariables=1
Ignetia
Posts: 2
Joined: November 30th, 2019, 11:34 pm

Re: Randomizing on a specific value

Ignetia » December 1st, 2019, 2:15 pm

That worked perfectly, thank you very much!
User avatar
balala
Rainmeter Sage
Posts: 9258
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Randomizing on a specific value

balala » December 1st, 2019, 3:21 pm

Ignetia wrote:
December 1st, 2019, 2:15 pm
That worked perfectly, thank you very much!
If you're talking about my above posted code, I'm glad.