I have a skin that shows some "buttons" on a display screen in a broadcast studio. I have variables stored in a text file, and am using web parser to constantly scan the file, and depending on the variable in it, change the value and colour of the button on the screen.
As this needs to be fairly rapidly updated, it seems to sometimes crash Web Parser, which stops all skins updating without a force refresh. I understand this is not the best use of Web Parser, so I attempted to adapt a Lua script to do this for me. I'm no coder, so butchered up something based on a Lyrics script I found on the forum.
What I ended up with, kind of works for a bit, but then crashes Rainmeter completely. As this doesnt show anything up in the rainmeter log, I'm not sure where I have gone wrong, and why it's crashing. I have pasted in the files below, please go easy on me for the bad code
File 1: Variables file that is updated via AutoIT script UDP commands:
Code: Select all
[Pathfinder Config]
Service=SVC3,
Studio=ON,
Delay=OFF,
Sat=OFF,
Audio=OFF,
Clip=OFF,
Hotline=OFF,
Caller=OFF,
Mic=OFF,
Security=OFF,
Meeting=OFF,
Code: Select all
[Metadata]
Name=Alarm Display
[Rainmeter]
Update=500
AccurateText=1
DynamicWindowSize=1
W=170
H=100
[Variables]
@include=#@#\Variables.inc
BoxColourOFF=192,192,192,100
BoxColourON=0,234,102,255
BoxColourALARM=247,13,18,[MeasureBlinkString]
BoxColourCALLER=0,152,234,[MeasureBlinkString]
FontSize=20
WIDTH=(#SCREENAREAWIDTH#-14)
HEIGHT=#SCREENAREAHEIGHT#
;WIDTH=1360
;Height=800
[MeasureReadPathfinderInfo]
Measure=Script
ScriptFile=#CURRENTPATH#Pathfinder.lua
FileToRead=#configpath#
DynamicVariables=1
; Measures - Definitions of Data
[BoxSize]
Measure=Calc
Formula=#WIDTH#*0.125
DynamicVariables=1
[BoxHeight]
Measure=Calc
Formula=#HEIGHT#*0.12
DynamicVariables=1
[MeasureBlinkString]
Measure=Calc
Formula=MeasureBlinkString = 0 ? 255 : 0
UpdateDivider=2
; Meter Section - Display of Data from Measures. These are updated by Pathfinder Lua Script
[StudioBackground]
Meter=Image
SolidColor=#BoxColourOFF#
W=[BoxSize]
H=100
X=0
Y=100
[StudioText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=([BoxSize]/2)
Y=130
[DelayBackground]
Meter=Image
SolidColor=#BoxColourOFF#
W=[BoxSize]
H=100
X=([BoxSize]+2)
Y=100
[DelayText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=([BoxSize]*1.51)
Y=130
[SatBackground]
Meter=Image
SolidColor=#BoxColourOFF#
W=[BoxSize]
H=100
X=(([BoxSize]+2)*2)
Y=100
[SatText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=([BoxSize]*2.52)
Y=130
[AudioBackground0]
Meter=Image
SolidColor=#BoxColourOFF#
W=[BoxSize]
H=100
X=(([BoxSize]+2)*3)
Y=100
[AudioBackground]
Meter=Image
W=[BoxSize]
H=100
X=(([BoxSize]+2)*3)
Y=100
[AudioText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=([BoxSize]*3.52)
Y=130
[ClipBackground0]
Meter=Image
SolidColor=#BoxColourOFF#
W=[BoxSize]
H=100
X=(([BoxSize]+2)*4)
Y=100
[ClipBackground]
Meter=Image
W=[BoxSize]
H=100
X=(([BoxSize]+2)*4)
Y=100
[ClipText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=([BoxSize]*4.53)
Y=130
[HotlineBackground0]
Meter=Image
SolidColor=#BoxColourOFF#
W=[BoxSize]
H=100
X=(([BoxSize]+2)*5)
Y=100
[HotlineBackground]
Meter=Image
W=[BoxSize]
H=100
X=(([BoxSize]+2)*5)
Y=100
[HotlineText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=([BoxSize]*5.54)
Y=130
[CallerBackground0]
Meter=Image
SolidColor=#BoxColourOFF#
W=[BoxSize]
H=100
X=(([BoxSize]+2)*6)
Y=100
[CallerBackground]
Meter=Image
W=[BoxSize]
H=100
X=(([BoxSize]+2)*6)
Y=100
[CallerText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=([BoxSize]*6.57)
Y=130
[MicBackground0]
Meter=Image
SolidColor=#BoxColourOFF#
W=[BoxSize]
H=100
X=(([BoxSize]+2)*7)
Y=100
[MicBackground]
Meter=Image
W=[BoxSize]
H=100
X=(([BoxSize]+2)*7)
Y=100
[MicText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=([BoxSize]*7.58)
Y=130
[MeetingAlarmBackground]
Meter=Image
W=#SCREENAREAWIDTH#
H=100
X=0
Y=0
[MeetingAlarmText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=(#SCREENAREAWIDTH#/2)
Y=15
[SecurityAlarmBackground]
Meter=Image
W=#SCREENAREAWIDTH#
H=100
X=0
Y=0
[SecurityAlarmText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=(#SCREENAREAWIDTH#/2)
Y=15
[AudioAlarmBackground]
Meter=Image
W=#SCREENAREAWIDTH#
H=100
X=0
Y=0
[AudioAlarmText]
Meter=String
FontSize=#FontSize#
FontColor=#FontColor#
FontFace=#DataFont#
AntiAlias=1
StringStyle=Bold
StringAlign=Center
X=(#SCREENAREAWIDTH#/2)
Y=15
Code: Select all
function Initialize()
end
function Update()
sFileToRead = SELF:GetOption('FileToRead')
hReadingFile = io.open(sFileToRead)
if not hReadingFile then
print('LuaTextFile: unable to open file at ' .. sFileToRead)
return
end
sAllText = hReadingFile:read('*all')
sAllText = string.gsub(sAllText, '\t', ' ')
sService = string.match(sAllText, 'Service=(.-),')
sStudio = string.match(sAllText, 'Studio=(.-),')
Meter = SKIN:GetMeter('StudioBackground')
if sStudio == 'ON' then
SKIN:Bang('!SetOption', 'StudioBackground', 'SolidColor', '#BoxColourON#')
else
SKIN:Bang('!SetOption', 'StudioBackground', 'SolidColor', '#BoxColourOFF#')
end
Meter = SKIN:GetMeter('StudioText')
if sStudio == 'ON' then
SKIN:Bang('!SetOption', 'StudioText', 'Text', 'STUDIO ON')
else
SKIN:Bang('!SetOption', 'StudioText', 'Text', 'STUDIO OFF')
end
sDelay = string.match(sAllText, 'Delay=(.-),')
Meter = SKIN:GetMeter('DelayBackground')
if sDelay == 'ON' then
SKIN:Bang('!SetOption', 'DelayBackground', 'SolidColor', '#BoxColourON#')
else
SKIN:Bang('!SetOption', 'DelayBackground', 'SolidColor', '#BoxColourOFF#')
end
Meter = SKIN:GetMeter('DelayText')
if sDelay == 'ON' then
SKIN:Bang('!SetOption', 'DelayText', 'Text', 'DELAY ON')
else
SKIN:Bang('!SetOption', 'DelayText', 'Text', 'DELAY OFF')
end
sSat = string.match(sAllText, 'Sat=(.-),')
Meter = SKIN:GetMeter('SatBackground')
if sSat == 'ON' then
SKIN:Bang('!SetOption', 'SatBackground', 'SolidColor', '#BoxColourON#')
else
SKIN:Bang('!SetOption', 'SatBackground', 'SolidColor', '#BoxColourOFF#')
end
Meter = SKIN:GetMeter('SatText')
if sSat == 'ON' then
SKIN:Bang('!SetOption', 'SatText', 'Text', 'Sat ON')
else
SKIN:Bang('!SetOption', 'SatText', 'Text', 'Sat OFF')
end
sAudio = string.match(sAllText, 'Audio=(.-),')
Meter = SKIN:GetMeter('AudioBackground')
if sAudio == 'ON' then
SKIN:Bang('!SetOption', 'AudioBackground', 'SolidColor', '#BoxColourALARM#')
SKIN:Bang('!SetOption', 'AudioAlarmBackground', 'SolidColor', '#BoxColourALARM#')
else
SKIN:Bang('!SetOption', 'AudioBackground', 'SolidColor', '#BoxColourOFF#')
SKIN:Bang('!SetOption', 'AudioBackground', 'SolidColor', '#BoxColourON#')
SKIN:Bang('!SetOption', 'AudioAlarmBackground', 'SolidColor', '0,0,0,0')
end
Meter = SKIN:GetMeter('AudioText')
if sAudio == 'ON' then
SKIN:Bang('!SetOption', 'AudioText', 'Text', 'AUDIO FAIL')
else
SKIN:Bang('!SetOption', 'AudioText', 'Text', 'AUDIO OK')
end
Meter = SKIN:GetMeter('AudioAlarmText')
if sAudio == 'ON' then
SKIN:Bang('!SetOption', 'AudioAlarmText', 'Text', "AUDIO FAIL! #CRLF# Please Check Console Levels Immediately!")
SKIN:Bang('!SetOption', 'AudioAlarmText', 'FontColor', '255,255,255,[MeasureBlinkString]')
else
SKIN:Bang('!SetOption', 'AudioAlarmText', 'Text', "")
end
sClip = string.match(sAllText, 'Clip=(.-),')
Meter = SKIN:GetMeter('ClipBackground')
if sClip == 'ON' then
SKIN:Bang('!SetOption', 'ClipBackground', 'SolidColor', '#BoxColourALARM#')
else
SKIN:Bang('!SetOption', 'ClipBackground', 'SolidColor', '#BoxColourOFF#')
end
Meter = SKIN:GetMeter('ClipText')
if sClip == 'ON' then
SKIN:Bang('!SetOption', 'ClipText', 'Text', 'TOO LOUD!')
else
SKIN:Bang('!SetOption', 'ClipText', 'Text', 'LEVELS OK')
end
sHotline = string.match(sAllText, 'Hotline=(.-),')
Meter = SKIN:GetMeter('HotlineBackground')
if sHotline == 'ON' then
SKIN:Bang('!SetOption', 'HotlineBackground', 'SolidColor', '#BoxColourALARM#')
else
SKIN:Bang('!SetOption', 'HotlineBackground', 'SolidColor', '#BoxColourOFF#')
end
Meter = SKIN:GetMeter('HotlineText')
if sHotline == 'ON' then
SKIN:Bang('!SetOption', 'HotlineText', 'Text', 'HOTLINE!')
else
SKIN:Bang('!SetOption', 'HotlineText', 'Text', 'HOTLINE!')
end
sCaller = string.match(sAllText, 'Caller=(.-),')
Meter = SKIN:GetMeter('CallerBackground')
if sCaller == 'ON' then
SKIN:Bang('!SetOption', 'CallerBackground', 'SolidColor', '#BoxColourCALLER#')
else
SKIN:Bang('!SetOption', 'CallerBackground', 'SolidColor', '#BoxColourOFF#')
end
Meter = SKIN:GetMeter('CallerText')
if sCaller == 'ON' then
SKIN:Bang('!SetOption', 'CallerText', 'Text', 'CALLER!')
else
SKIN:Bang('!SetOption', 'CallerText', 'Text', 'NO CALLS')
end
sMic = string.match(sAllText, 'Mic=(.-),')
Meter = SKIN:GetMeter('MicBackground')
if sMic == 'ON' then
SKIN:Bang('!SetOption', 'MicBackground', 'SolidColor', '#BoxColourALARM#')
else
SKIN:Bang('!SetOption', 'MicBackground', 'SolidColor', '#BoxColourOFF#')
end
Meter = SKIN:GetMeter('MicText')
if sMic == 'ON' then
SKIN:Bang('!SetOption', 'MicText', 'Text', "MIC'S ON")
else
SKIN:Bang('!SetOption', 'MicText', 'Text', "MIC'S OFF")
end
sSecurity = string.match(sAllText, 'Security=(.-),')
Meter = SKIN:GetMeter('SecurityBackground')
if sSecurity == 'ON' then
SKIN:Bang('!SetOption', 'SecurityAlarmBackground', 'SolidColor', '#BoxColourALARM#')
else
SKIN:Bang('!SetOption', 'SecurityAlarmBackground', 'SolidColor', '0,0,0,0')
end
Meter = SKIN:GetMeter('SecurityAlarmText')
if sSecurity == 'ON' then
SKIN:Bang('!SetOption', 'SecurityAlarmText', 'FontColor', '255,255,255,[MeasureBlinkString]')
SKIN:Bang('!SetOption', 'SecurityAlarmText', 'Text', "SECURITY SYSTEM ARMING! #CRLF# Please swipe card at nearest reader immediately to remain in building.")
else
SKIN:Bang('!SetOption', 'SecurityAlarmText', 'Text', "")
end
sMeeting = string.match(sAllText, 'Meeting=(.-),')
Meter = SKIN:GetMeter('MeetingBackground')
if sMeeting == 'ON' then
SKIN:Bang('!SetOption', 'MeetingAlarmBackground', 'SolidColor', '#BoxColourALARM#')
else
SKIN:Bang('!SetOption', 'MeetingAlarmBackground', 'SolidColor', '0,0,0,0')
end
Meter = SKIN:GetMeter('MeetingAlarmText')
if sMeeting == 'ON' then
SKIN:Bang('!SetOption', 'MeetingAlarmText', 'FontColor', '255,255,255,[MeasureBlinkString]')
SKIN:Bang('!SetOption', 'MeetingAlarmText', 'Text', "ALL STAFF MEETING ON NOW! #CRLF# Please head to the staff cafe for an all staff meeting.")
else
SKIN:Bang('!SetOption', 'MeetingAlarmText', 'Text', "")
end
io.close(hReadingFile)
return tostring(sService)
end
Even better, if there's a way to take strings via UDP and push them straight into Rainmeter rather than via the text file, that would be awesome.
Thanks
Matt