It is currently September 16th, 2019, 11:30 pm

[Script] Lua Marquee

Discuss the use of Lua in Script measures.
User avatar
smurfier
Moderator
Posts: 1937
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

[Script] Lua Marquee

smurfier » July 23rd, 2011, 10:51 pm

I have written a Lua script that will marquee a single line of text.

*** Rainmeter 2.5 or higher required ***

Inputs:
  • Text*
    • Predefined Text.
  • MeasureName
    • The name of a measure.
  • Variable
    • The name of a variable.
Options:
  • Width*
    • The width of the marquee. This number represents characters, not pixels.
      Defaults to 10
  • Delimiter*
    • The delimiter between items. Quotes or Apostrophes must be used around spaces, and escaped with / if you want them included in the delimiter. Only used when using multiple measures.
      Defaults to ' '
  • ForceScroll*
    • When set to 1, forces a string that is shorter than Width to scroll.
  • Pause
    • Used to set the default state of the Pause variable. 0 for paused, 1 for scrolling.
  • Position
    • When set to LEFT, the string starts on the left side of the marquee.
*These options are compatible with DynamicVariables.

Notes
  • To use multiple inputs of the same type, simply use a pipe delimiter between names. This does no apply to the Text input.
    • Example: MeasureName=Measure1|OtherMeasure
  • More than one type of input may be used and are displayed in the following order:
    • Measures, Variables, Text.
  • If no input is specified or if no information is retireved, "Input Error!" is displayed.
  • If the length of the text is less than the specified width, the text will not scroll.
Actions:
  • Reset the Timer
    • !CommandMeasure "MeasureLua" "Timer=0;"
  • Pause
    • !CommandMeasure "MeasureLua" "Pause=0;"
  • UnPause
    • !CommandMeasure "MeasureLua" "Pause=1;"
  • Toggle Pause
    • !CommandMeasure "MeasureLua" "Pause=1-Pause"
Tricks:
  • Have the text scroll only on mouseover.
    • On the Marquee measure set Pause=0 and Position=Left.
    • On the meter in question set:
      MouseOverAction=!CommandMeasure Lua Pause=1
      MouseLeaveAction=!CommandMeasure Lua Pause,Timer=0,0
Since the width of the marquee is defined in characters instead of pixels it is best to use a MonoSpace font.
My choice of font is Monospace Typewriter.
LuaMarquee_6.2.rmskin
Changelog:
EDIT:
Updated to take values from one of three different fields.

EDIT2:
Updated to make the string fill the defined width. Also fixed one line of code

EDIT3:
Update to make use of multiple measures and allow for definition of delimiters.

EDIT4:
Updated so that the text scrolls from left to right without repeating the text. Also added ScrollMode=2 to prevent the text from scrolling when it is smaller than the defined width.

EDIT5: (v5.0)
Updated to add AutoRefresh. Also some small code revisions.

11/30/2011: (v5.3)
Updated to remove NumOfMeasures and general updates to the script.

12/1/2011: (v5.4)
Updated to allow multiple Variables and added support for the use of multiple input types. Minor code optimizations. Removed TogglePause function.

12/2/2011: (v5.5)
Removed ScrollMode, AutoReset, and StartPosition. Minor code optimizations.

12/26/2011:
v5.6- Minor code optimizations.
v5.7- Added ForceScroll.

3/11/2012: (v6.0)
-Updated to use current Rainmeter standards.
-Added Pause option for setting default state.

9/8/2012: (v6.0)
-Fixed bug typo.

5/20/2013: (v6.2)
-Fixed several issues.
You do not have the required permissions to view the files attached to this post.
Last edited by smurfier on August 5th, 2011, 1:36 am, edited 21 times in total.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
Seahorse
Posts: 1220
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: PROOF OF CONCEPT: Lua Marquee

Seahorse » July 24th, 2011, 5:36 am

Works a here, just want to understand the syntax of multiple measures, i.e. 3 is it:

Code: Select all

MeasureName = FirstMeasurename""SecondtMeasurename""ThirdMeasurename"";

NumOfMeasures = 3;
with

Code: Select all

MeasureName=MeasureLua
in all three string meters?
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
smurfier
Moderator
Posts: 1937
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: PROOF OF CONCEPT: Lua Marquee

smurfier » July 24th, 2011, 5:49 am

Three Measures, one marquee:

Code: Select all

[Measure1]

[Measure2]

[Measure3]

[MeasureLua]
MeasureName=Measure
NumOfMeasures=3
Three Measures, Three Marquees

Code: Select all

[Measure1]

[MeasureLua1]
MeasureName=Measure1
TableName=LuaMarq1

[Measure2]

[MeasureLua2]
MeasureName=Measure2
TableName=LuaMarq2

[Measure3]

[MeasureLua3]
MeasureName=Measure3
TableName=LuaMarq3
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
Seahorse
Posts: 1220
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: PROOF OF CONCEPT: Lua Marquee

Seahorse » July 24th, 2011, 6:16 am

I figure this can be shoe-horned into my media player skin and ditch the tooltips for long song names.

Initially I thought I had to edit the:

Code: Select all

[url]PROPERTIES =
{
Text = "";
MeasureName = "";
Variable = "";
Width = 0;
NumOfMeasures = 1;
Delimiter = "  ";
}[/url]
of the lua script with 3 measure names and change the NumofMeasures to 3. I think I am not understanding your reply :confused: Currently I get "the [MeterTrack] cannot be bound with [MeasureLua1]!" etc using this in the copy of the skin:

Code: Select all

[MeasureLua1]
MeasureName=MeasurePlayer
TableName=LuaMarq1

[MeasureLua2]
MeasureName=MeasureArtist
TableName=LuaMarq2

[MeasureLua3]
MeasureName=MeasureAlbum
TableName=LuaMarq3
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
smurfier
Moderator
Posts: 1937
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: PROOF OF CONCEPT: Lua Marquee

smurfier » July 24th, 2011, 8:23 am

Seahorse wrote: of the lua script with 3 measure names and change the NumofMeasures to 3. I think I am not understanding your reply :confused: Currently I get "the [MeterTrack] cannot be bound with [MeasureLua1]!" etc using this in the copy of the skin:

Code: Select all

[MeasureLua1]
MeasureName=MeasurePlayer
TableName=LuaMarq1

[MeasureLua2]
MeasureName=MeasureArtist
TableName=LuaMarq2

[MeasureLua3]
MeasureName=MeasureAlbum
TableName=LuaMarq3
I'll take a look in the morning. It's working perfectly for me with WebParser.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
smurfier
Moderator
Posts: 1937
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: PROOF OF CONCEPT: Lua Marquee

smurfier » July 24th, 2011, 8:47 am

I am having no problem using NowPlaying with this method.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
Seahorse
Posts: 1220
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: PROOF OF CONCEPT: Lua Marquee

Seahorse » July 24th, 2011, 9:25 am

"the [MeterTrack] cannot be bound with [MeasureLua1]" error is because I have measures in the string meters, which I think I don't need at all a lua forces the text in there somehow I seem to recall. So that's that one removed.

So just so I am clear on this, as I am no doubt misunderstanding something :oops:
  • I need to make no change to the lua script as this is 3 measure/meters?
  • Then the three string meters listed above just need to be added to the skin and we should be ok having ditched the Text=%1 in all three instances as the lua script pumps it into them
This is the third of the three, but Rainmeter's "About" shows no value for any of them, so I'm edging forward, but still not quite there.

Code: Select all

[MeasureAlbum]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=[MeasurePlayer]
PlayerType=ALBUM
Substitute="":"N\A"

[MeasureLua3]
Measure=Script
MeasureName=MeasureAlbum
ScriptFile=Marquee.lua
Width=200
TableName=LuaMarq3

[MeterAlbum]
Meter=STRING
MeasureName=MeasureLua3
X=R
Y=r
W=150
H=16
MeterStyle=StringStyle



Last edited by Seahorse on July 24th, 2011, 12:02 pm, edited 1 time in total.
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
smurfier
Moderator
Posts: 1937
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: PROOF OF CONCEPT: Lua Marquee

smurfier » July 24th, 2011, 3:18 pm

Here is my working code with NowPlaying.

Code: Select all

[Rainmeter]
Author=Smurfier
Update=1000
DynamicWindowSize=1

[MeasureMediaPlayer]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=iTunes

[MeasureMedia1]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=[MeasureMediaPlayer]
PlayerType=TITLE

[MeasureMedia2]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=[MeasureMediaPlayer]
PlayerType=ALBUM

[MeasureMedia3]
Measure=Plugin
Plugin=NowPlaying.dll
PlayerName=[MeasureMediaPlayer]
PlayerType=ARTIST

[MeasureLua]
Measure=Script
ScriptFile=Marquee.lua
Width=100
MeasureName=MeasureMedia
NumOfMeasures=3
Delimiter=" | "

[StringMeter]
Meter=String
MeasureName=MeasureLua
FontColor=255,255,255,255
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
Seahorse
Posts: 1220
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: PROOF OF CONCEPT: Lua Marquee

Seahorse » July 24th, 2011, 3:40 pm

Sorted, thank you sir. 8-)
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
santa_ryan
Posts: 417
Joined: June 22nd, 2010, 4:11 am

Re: PROOF OF CONCEPT: Lua Marquee

santa_ryan » July 25th, 2011, 10:45 am

Error:
Script: ...nts\Rainmeter\Skins\TotalControl\PlayIt!\Marquee.lua:77: attempt to call method 'GetVariable' (a nil value)
Fix:

Code: Select all

function Update()
   if PROPERTIES.Text ~= "" then
      Text = PROPERTIES.Text..PROPERTIES.Delimiter
   elseif PROPERTIES.MeasureName ~= "" then
      if iMeasureCount > 1 then
      Text = tMeasures[1]:GetStringValue()..PROPERTIES.Delimiter
         for i=2, iMeasureCount do
         Text = Text..tMeasures[i]:GetStringValue()..PROPERTIES.Delimiter
         end
      else
         Text = Measure:GetStringValue()..PROPERTIES.Delimiter
      end
   else
      Text = SKIN:ReplaceVariables("#"..PROPERTIES.Variable.."#")..PROPERTIES.Delimiter
   end
Quick Explanation:
On line 42, you have

Code: Select all

SKIN:GetVariable(PROPERTIES.Variable)


and you should be using

Code: Select all

SKIN:ReplaceVariables("#"..PROPERTIES.Variable.."#")
Maybe I'm just doing something wrong, but I know I fixed the error using the above fix.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.