String measures and webparser measures are the only ones that can return arbitrary string values. And I didn't realize a webparser measure could have the regexpsubstitute on it as well as the regex. That makes it ok then, they're added to the list of extremely powerful measures then. (which is 2)
It is currently September 8th, 2024, 4:43 am
RainGame - A functional game engine without scrip... WITH a custom scripting language!
-
- Posts: 134
- Joined: June 30th, 2014, 8:44 am
Re: RainGame - A functional game engine without scripts or plugins | Now with Scrolling!
-
- Developer
- Posts: 22716
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: RainGame - A functional game engine without scripts or plugins | Now with Scrolling!
String and Time measures can have an "arbitrary" string value, while a WebParser measure really can't. A WebParser measure must parse something external, be it site or file.Yamajac wrote: ↑November 16th, 2019, 11:24 pm String measures and webparser measures are the only ones that can return arbitrary string values. And I didn't realize a webparser measure could have the regexpsubstitute on it as well as the regex. That makes it ok then, they're added to the list of extremely powerful measures then. (which is 2)
I guess I don't want to get in the middle of this. I don't really understand what is being objected to or what is at stake in this discussion. Forget I poked my nose into it.
-
- Posts: 134
- Joined: June 30th, 2014, 8:44 am
Re: RainGame - A functional game engine without scripts or plugins | Now with Scrolling!
O yea, I suppose time measures could have an arbitrary string value as well through the format key. Anyway, that's not really the important part. Point is just that regular expressions are extremely powerful. Whether you use it with a string measure or time measure or webparser or NowPlaying if you really wanted to push it.jsmorley wrote: ↑November 16th, 2019, 11:35 pm String and Time measures can have an "arbitrary" string value, while a WebParser measure really can't. A WebParser measure must parse something external, site or file.
I guess I don't want to get in the middle of this. I don't really understand what is being objected to or what is at stake in this discussion. Forget I poked my nose into it.
-
- Developer
- Posts: 22716
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: RainGame - A functional game engine without scripts or plugins | Now with Scrolling!
It is really powerful, and can be used with ANY measure that returns a string or number value. I'd have to double-check but I think they ALL do.Yamajac wrote: ↑November 16th, 2019, 11:43 pm O yea, I suppose time measures could have an arbitrary string value as well through the format key. Anyway, that's not really the important part. Point is just that regular expressions are extremely powerful. Whether you use it with a string measure or time measure or webparser or NowPlaying if you really wanted to push it.
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
[MeasureLoop]
Measure=Loop
StartValue=1
EndValue=15
RegExpSubstitute=1
Substitute="^5$":"Hey, it's FIVE right now!"
[MeterBack]
Meter=Shape
Shape=Rectangle 0.5,0.5,300,100 | StrokeWidth 1 | Stroke Color 150,150,150,255 | Fill Color 47,47,47,255
[MeterLoop]
Meter=String
MeasureName=MeasureLoop
X=151
Y=51
StringAlign=CenterCenter
FontSize=20
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
-
- Posts: 134
- Joined: June 30th, 2014, 8:44 am
Re: RainGame - A functional game engine without scripts or plugins | Now with Scrolling!
Well yea, but it's only particularly powerful with measures that return strings. If something returns a number value, you're generally better off parsing it with a calc measure. It can be used with anything, but you can't make a functional array out of a calc measure with a regex for instance, you can't parse entity data from a list of entities, etc. Calc measure formulas are generally significantly more suitable to measures that return numbers than a regex would be.
Though, I'm not a particularly normal use case of rainmeter so what do I know.
EDIT:
Wait, are you telling me regexpsubstitute can take a measure that would normally return a number and make it return a string instead?
Wait... I did not know that. That's bloody amazing.
Oh my god it can. Wait a minute this is awesome.
-
- Developer
- Posts: 22716
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: RainGame - A functional game engine without scripts or plugins | Now with Scrolling!
Yamajac wrote: ↑November 17th, 2019, 12:02 am Well yea, but it's only particularly powerful with measures that return strings. If something returns a number value, you're generally better off parsing it with a calc measure. It can be used with anything, but you can't make a functional array out of a calc measure with a regex for instance, you can't parse entity data from a list of entities, etc. Calc measure formulas are generally significantly more suitable to measures that return numbers than a regex would be.
Though, I'm not a particularly normal use case of rainmeter so what do I know.
EDIT:
Wait, are you telling me regexpsubstitute can take a measure that would normally return a number and make it return a string instead?
Wait... I did not know that. That's bloody amazing.
Oh my god it can. Wait a minute this is awesome.
Pretty much all measures return both a number and a string value. I think maybe all, but I can't swear to every 3rd-party plugin measure. In most cases where a measure is designed to return a number, it simply returns that number as the string value as well. That string value can be manipulated with Substitute, while leaving the number value alone to be used by meters that require a number or a percentage as input.
Measures that return a purely numeric value will return that value as both the number and string values.
Measures that return a non-numeric string value will return 0 as the number value.
Measures that are designed to return distinct number and string values will do so.
String meters will always use the string value of any measure bound it it with MeasureName(n).
Most other meter types will use the number or percentage value of any measure bound it it with MeasureName(n).
String values can be dynamically used just about anywhere, by using the measure value as a [SectionVariable]. That will always represent the string value, which may or may not be the same as the number value.
Number values can be dynamically used just about anywhere, by using the measure as a numeric [SectionVariable:] That will always represent the number value.
Substitute is applied to the string value of a measure at the point and time it is "asked for" by some other entity, like any option value, or bang parameter, or even the Rainmeter log.
-
- Developer
- Posts: 22716
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: RainGame - A functional game engine without scripts or plugins | Now with Scrolling!
Even WebParser...
Test.html:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
[MeasureWebParser]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)<item>(.*)</item>
StringIndex=1
RegExpSubstitute=1
Substitute="^123$":"One-Two-Three"
[MeterBack]
Meter=Shape
Shape=Rectangle 0.5,0.5,300,100 | StrokeWidth 1 | Stroke Color 150,150,150,255 | Fill Color 47,47,47,255
[MeterOuput]
Meter=String
X=151
Y=51
StringAlign=CenterCenter
FontSize=20
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=[MeasureWebParser]#CRLF#[MeasureWebParser:]
Code: Select all
<item>123</item>
You do not have the required permissions to view the files attached to this post.
-
- Posts: 134
- Joined: June 30th, 2014, 8:44 am
Re: RainGame - A functional game engine without scripts or plugins | Now with Scrolling!
I spend a LOT of time in the window showing all the values for measures/variables/what not and I can't believe I never noticed that all measures have a separate number and string value. That's really really cool.jsmorley wrote: ↑November 17th, 2019, 12:33 am Pretty much all measures return both a number and a string value. I think maybe all, but I can't swear to every 3rd-party plugin measure. In most cases where a measure is designed to return a number, it simply returns that number as the string value as well. That string value can be manipulated with Substitute, while leaving the number value alone to be used by meters that require a number or a percentage as input.
Measures that return a purely numeric value will return that value as both the number and string values.
Measures that return a non-numeric string value will return 0 as the number value.
Measures that are designed to return distinct number and string values will do so.
String meters will always use the string value of any measure bound it it with MeasureName(n).
Most other meter types will use the number or percentage value of any measure bound it it with MeasureName(n).
String values can be dynamically used just about anywhere, by using the measure value as a [SectionVariable]. That will always represent the string value, which may or may not be the same as the number value.
Number values can be dynamically used just about anywhere, by using the measure as a numeric [SectionVariable:] That will always represent the number value.
Substitute is applied to the string value of a measure at the point and time it is "asked for" by some other entity, like any option value, or bang parameter, or even the Rainmeter log.
I'm having trouble thinking of practical use cases for this, but that's nifty to know. I think it could be possible to make key, value elements in an array, but I'm kinda already doing that here anyway... Be fewer lines I suppose, but less human readable. So maybe for generated arrays it could be used but then the regex is probably more cpu time than just creating a bunch of variables anyway.. IDK, I'll have to play around with it and see what it can do later I guess.
Definitely knowing that WebParser can have RegExpSubstitute on it will be handy though. That can simplify a bit of my screen editor at least. IDK why I never thought it could before.
-
- Developer
- Posts: 22716
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: RainGame - A functional game engine without scripts or plugins | Now with Scrolling!
It should be noted that RegExpSubstitute / Substitute can only be used on a "child" WebParser measure. This can be a "parent" that is also a "child", but can't be a pure "parent" measure. Basically you use it where you use StringIndex. It will be useless on a pure "parent" measure, as that is never the one that is "asked for" by any other entity, and so the substitution is never done. Remember that substitutions are done when the string value of a measure is "asked for".
Yep:
Nope:
Yep:
Code: Select all
[MeasureWebParser]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)<item>(.*)</item>
[MeasureChild]
Measure=WebParser
URL=[MeasureWebParser]
StringIndex=1
RegExpSubstitute=1
Substitute="^123$":"One-Two-Three"
Nope:
Code: Select all
[MeasureWebParser]
Measure=WebParser
URL=file://#CURRENTPATH#Test.html
RegExp=(?siU)<item>(.*)</item>
RegExpSubstitute=1
Substitute="^123$":"One-Two-Three"
[MeasureChild]
Measure=WebParser
URL=[MeasureWebParser]
StringIndex=1
-
- Posts: 134
- Joined: June 30th, 2014, 8:44 am
Re: RainGame - A functional game engine without scripts or plugins | Now with Scrolling!
Oh, that's less interesting then. Damn.jsmorley wrote: ↑November 17th, 2019, 2:07 am It should be noted that RegExpSubstitute can only be used on a "child" WebParser measure. This can be a "parent" that is also a "child", but can't be a pure "parent" measure. Basically you use it where you use StringIndex. It will be useless on a pure "parent" measure, as that is never the one that is "asked for" by any other entity, and so the substitution is never done.
Yep:Code: Select all
[MeasureWebParser] Measure=WebParser URL=file://#CURRENTPATH#Test.html RegExp=(?siU)<item>(.*)</item> [MeasureChild] Measure=WebParser URL=[MeasureWebParser] StringIndex=1 RegExpSubstitute=1 Substitute="^123$":"One-Two-Three"
Nope:Code: Select all
[MeasureWebParser] Measure=WebParser URL=file://#CURRENTPATH#Test.html RegExp=(?siU)<item>(.*)</item> RegExpSubstitute=1 Substitute="^123$":"One-Two-Three" [MeasureChild] Measure=WebParser URL=[MeasureWebParser] StringIndex=1