It is currently March 28th, 2024, 6:01 pm

[Script] Lua Marquee

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

[Script] Lua Marquee

Post by smurfier »

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
(23.98 KiB) Downloaded 1307 times
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.
Last edited by smurfier on August 5th, 2011, 1:36 am, edited 21 times in total.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Re: PROOF OF CONCEPT: Lua Marquee

Post by Seahorse »

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?
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: PROOF OF CONCEPT: Lua Marquee

Post by smurfier »

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
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Re: PROOF OF CONCEPT: Lua Marquee

Post by Seahorse »

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
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: PROOF OF CONCEPT: Lua Marquee

Post by smurfier »

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.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: PROOF OF CONCEPT: Lua Marquee

Post by smurfier »

I am having no problem using NowPlaying with this method.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Re: PROOF OF CONCEPT: Lua Marquee

Post by Seahorse »

"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.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: PROOF OF CONCEPT: Lua Marquee

Post by smurfier »

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
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Re: PROOF OF CONCEPT: Lua Marquee

Post by Seahorse »

Sorted, thank you sir. 8-)
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: PROOF OF CONCEPT: Lua Marquee

Post by santa_ryan »

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.
Post Reply