It is currently December 7th, 2021, 12:50 pm

SKIN:Bang not working

Help with creating, editing & fixing problems with skins
FlightlessAz
Posts: 24
Joined: September 14th, 2021, 10:27 am

SKIN:Bang not working

Post by FlightlessAz »

Hey guys! For some reason, when I enter into my lua script a "SKIN:Bang" command, it doesn't seem to work, and the script returns 0 or null for its value. looking in the about section to check what the error message says, it says "Script: File not valid" and "Script: scrolling-text-test.lua:26: 'end' expected (to close 'function' at line 24) near 'SKIN'." this is the part of the code that doesn't work in my lua script:

Code: Select all

function Update()
	return cperiod()
	SKIN:Bang('[!UpdateMeter ScrollingText][!UpdateMeter ScrollingText2][!UpdateMeter ScrollingText3]') end
	end
end
"function Update()" is line 24 in my lua script, the SKIN:Bang line is line 26. cperiod() is just a function which I programmed to give a value based on parameters. I know this isn't the problematic part because when I remove the "SKIN:Bang" line, the program works again like nothing went wrong.

Any help would be appreciated. Thanks!
User avatar
balala
Rainmeter Sage
Posts: 13530
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: SKIN:Bang not working

Post by balala »

FlightlessAz wrote: October 13th, 2021, 7:10 am For some reason, when I enter into my lua script a "SKIN:Bang" command, it doesn't seem to work, and the script returns 0 or null for its value. looking in the about section to check what the error message says, it says "Script: File not valid" and "Script: scrolling-text-test.lua:26: 'end' expected (to close 'function' at line 24) near 'SKIN'." this is the part of the code that doesn't work in my lua script:
There are too many end commands. Only one single is needed, the one closing the Update() function. The other two have to be removed. Remove them and try again. Have this fixed the error?

Code: Select all

function Update()
	return cperiod()
	SKIN:Bang('[!UpdateMeter ScrollingText][!UpdateMeter ScrollingText2][!UpdateMeter ScrollingText3]')
end
The not posted parts of the code might require something else, but from the posted part this is what I see.
FlightlessAz
Posts: 24
Joined: September 14th, 2021, 10:27 am

Re: SKIN:Bang not working

Post by FlightlessAz »

balala wrote: October 13th, 2021, 7:50 am There are too many end commands. Only one single is needed, the one closing the Update() function. The other two have to be removed. Remove them and try again. Have this fixed the error?

Code: Select all

function Update()
	return cperiod()
	SKIN:Bang('[!UpdateMeter ScrollingText][!UpdateMeter ScrollingText2][!UpdateMeter ScrollingText3]')
end
The not posted parts of the code might require something else, but from the posted part this is what I see.
I did as you asked but it still doesn't work. I believe the SKIN:Bang line is the only thing causing the problem, but if necessary, I can post the entirety of my .ini and .lua file.
User avatar
Active Colors
Moderator
Posts: 919
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: SKIN:Bang not working

Post by Active Colors »

Try this:

Code: Select all

function Update()
	return cperiod()
	SKIN:Bang('!UpdateMeter' 'ScrollingText'])
	SKIN:Bang('!UpdateMeter' 'ScrollingText2'])
	SKIN:Bang('!UpdateMeter' 'ScrollingText3'])
end
FlightlessAz
Posts: 24
Joined: September 14th, 2021, 10:27 am

Re: SKIN:Bang not working

Post by FlightlessAz »

Active Colors wrote: October 13th, 2021, 9:07 am Try this:

Code: Select all

function Update()
	return cperiod()
	SKIN:Bang('!UpdateMeter' 'ScrollingText'])
	SKIN:Bang('!UpdateMeter' 'ScrollingText2'])
	SKIN:Bang('!UpdateMeter' 'ScrollingText3'])
end
Hello, I tried it and it still didn't fix it. Same error popping up in the debug window. I tried deleting two of the skin:bang lines as well, but to no avail.
FlightlessAz
Posts: 24
Joined: September 14th, 2021, 10:27 am

Re: SKIN:Bang not working

Post by FlightlessAz »

Here is both of the .ini and .lua code. This help in identifying the problem:

scrolling-text-test.ini:

Code: Select all

;font length = 52

[Rainmeter]
Update=#Update#
;BackgroundMode=2
AccurateText=1
SolidColor=200, 200, 200, 50
DynamicWindowSize=1
SkinWidth=838

[Variables]
Update=15
OriginalX=931
Y1=60
Bruh=Bruh Moment
BreakTime="休み時間"
Lunch=昼食時間
StaticText=Hello. Have a Nice Day
CurrentSubj=#StaticText#
ClassEnd=授業が終わりました。お疲れ様でした!
Leength=[MeterLength:W]
FontColor=255,0,0,255
SpeedMultiplier=3

[mScript]
Measure=Script
ScriptFile=scrolling-text-test.lua

;[DisplayPeriod]
;MeasureName=mScript
;AntiAlias=1
;DynamicVariables=1
;Meter=String
;FontColor=50,50,255,255
;FontFace=KH Dot Hibiya 32
;FontWeight=900
;Fontsize=75
;StringAlign=LeftCenter
;Meter=Image
;SolidColor=80,80,80,0
;Y=70

[TimeZZ]
DynamicVariables=1
;Measure=Calc
;Formula=50600
Measure=Time
Format=%w%H%M

[PeriodDetermine]
DynamicVariables=1
Measure=Calc
Formula=TimeZZ

[TotalMove]
DynamicVariables=1
Measure=Calc
Formula=(([MeterLength:W]+156)*3)
;Formula=3000

[MeterLength]
DynamicVariables=1
MeasureName=mScript
FontSize=75
FontFace=KH Dot Hibiya 32
FontWeight=900
FontColor=0,0,0,0
Meter=String

[MeasureMove]
DynamicVariables=1
Measure=Calc
Formula=#OriginalX#-((((Counter)*#SpeedMultiplier#))%[TotalMove])
AverageSize=1

[MeasureMove2]
DynamicVariables=1
Measure=Calc
Formula=#OriginalX#-((((((Counter)*#SpeedMultiplier#))%[TotalMove])+[MeterLength:W]+156)%[TotalMove])

[MeasureMove3]
DynamicVariables=1
Measure=Calc
Formula=#OriginalX#-((((((Counter)*#SpeedMultiplier#))%[TotalMove])+([MeterLength:W]*2)+312)%[TotalMove])
;Formula=0

[Motor]
Measure=Calc
Formula=(Counter%2)
IfBelowValue=1
IfBelowAction=!Execute [!MoveMeter [MeasureMove] #Y1# ScrollingText]
IfEqualValue=1
IfEqualAction=!Execute [!MoveMeter [MeasureMove] #Y1# ScrollingText]
DynamicVariables=1

[Motor2]
Measure=Calc
Formula=(Counter%2)
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterMoveMeter [MeasureMove2] #Y1# ScrollingText2]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterMoveMeter [MeasureMove2] #Y1# ScrollingText2]
DynamicVariables=1

[Motor3]
Measure=Calc
Formula=(Counter%2)
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterMoveMeter [MeasureMove3] #Y1# ScrollingText3]
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterMoveMeter [MeasureMove3] #Y1# ScrollingText3]
DynamicVariables=1

[MeterBackground]
Meter=Image
X=0
Y=0
W=673
H=120
SolidColor=80,80,80,0

[ScrollingText]
DynamicVariables=1
AntiAlias=1
Meter=String
X=0
Y=60
FontColor=#FontColor#
FontFace=KH Dot Hibiya 32
FontWeight=900
Fontsize=75
StringAlign=LeftCenter
MeasureName=mScript
AverageSize=100

[ScrollingText2]
AntiAlias=1
DynamicVariables=1
Meter=String
X=0
Y=60
W=500
FontColor=#FontColor#
FontFace=KH Dot Hibiya 32
FontWeight=900
Fontsize=75
StringAlign=LeftCenter
MeasureName=mScript

[ScrollingText3]
AntiAlias=1
DynamicVariables=1
Meter=String
X=0
Y=60
W=500
FontColor=#FontColor#
FontFace=KH Dot Hibiya 32
FontWeight=900
Fontsize=75
StringAlign=LeftCenter
;Text=#CurrentSubj#
MeasureName=mScript
Meter=Image
X=0
Y=0
W=673
H=120
SolidColor=80,80,80,0
scrolling-text-test.lua:

Code: Select all

function tomin(h,m)
	return ((h*60) + m)
end

function initialize()
end

wday = os.date('%a')
--wday = 'Fri'
timemin = os.date('%H')*60 + os.date('%M')
--timemin = tomin(16,0)
Subj = {'Physical Education and Health 1', 'Oral Communication in Context', 'Earth Science and Life Science', 'General Mathematics', 'Introduction to Innovating Technology Solutions',	'Personality Development'}
Break = 'Break Time'
Lunch = 'Lunch Break'
goodwork = 'お疲れ様でした!'
x = 6
Mperiod = {timemin >= tomin(7,30) and timemin < tomin(8,30), timemin >= tomin(8,30) and timemin < tomin(9,0), timemin >= tomin(9,0) and timemin < tomin(12,0), timemin >= tomin(13,0) and timemin < tomin(16,0), timemin >= tomin(16,0) and timemin < tomin(17,30), timemin >= tomin(17,30) and timemin < tomin(17,35)}
Tperiod = {timemin >= tomin(7,30) and timemin < tomin(12,0), timemin >= tomin(13,0) and timemin < tomin(17,30), timemin >= tomin(17,30) and timemin < tomin(17,35)}
Wperiod = {timemin >= tomin(7,30) and timemin < tomin(8,45), timemin >= tomin(8,45) and timemin < tomin(9,0), timemin >= tomin(9,0) and timemin < tomin(12,0), timemin >= tomin(13,0) and timemin < tomin(16,0), timemin >= tomin(16,0) and timemin < tomin(16,30), timemin >= tomin(16,30) and timemin < tomin(18,30), timemin >= tomin(18,30) and timemin < tomin(18,35)}
THperiod = {timemin >= tomin(7,30) and timemin < tomin(12,0), timemin >= tomin(13,0) and timemin < tomin(17,30), timemin >= tomin(17,30) and timemin < tomin(17,35)}
Fperiod = {timemin >= tomin(7,30) and timemin < tomin(9,0), timemin >= tomin(9,0) and timemin < tomin(12,0), timemin >= tomin(13,0) and timemin < tomin(16,0), timemin >= tomin(16,0) and timemin < tomin(16,5)}

function Update()
	return cperiod()
end

function mon()
	if Mperiod[1] then
		return Subj[1]
	elseif Mperiod[2] then
		return Break
	elseif Mperiod [3] then
		return Subj[2]
	elseif Mperiod [4] then
		return Subj[3]
	elseif Mperiod[5] then
		return Subj[4]
	elseif Mperiod[6] then
		return goodwork
	else
		return false
	end
end

function tue()
	if Tperiod[1] then
		return Subj[5]
	elseif Tperiod[2] then
		return Subj[6]
	elseif Tperiod[3] then
		return goodwork
	else
		return false
	end
end

function wed()
	if Wperiod[1] then
		return Subj[1]
	elseif Wperiod[2] then
		return Break
	elseif Wperiod [3] then
		return Subj[2]
	elseif Wperiod [4] then
		return Subj[3]
	elseif Wperiod[5] then
		return Break
	elseif Wperiod[6] then
		return Subj[4]
	elseif Wperiod[7] then
		return goodwork
	else
		return false
	end
end

function thu()
	if THperiod[1] then
		return Subj[5]
	elseif THperiod[2] then
		return Subj[6]
	elseif THperiod[3] then
		return goodwork
	else
		return false
	end
end

function fri()
	if Fperiod[1] then
		return Subj[4]
	elseif Fperiod [2] then
		return Subj[2]
	elseif Fperiod [3] then
		return Subj[3]
	elseif Fperiod [4] then
		return goodwork
	else
		return false
	end
end

function schchk()
	if wday == 'Sun' or wday == 'Sat' then
		return false
	elseif timemin >= tomin(0,0) and timemin < tomin(7,30) then
		return false
	elseif wday == 'Mon' or wday == 'Tue' or wday == 'Thu'then
		if timemin >= tomin(17,30) then
			return false
		else
			return true
		end
	elseif wday == 'Wed' then
		if timemin >= tomin(18,30) then
			return false
		else
			return true
		end
	else
		if timemin >= tomin(16,00) then
			return false
		else
			return true
		end
	end
end

function cperiod()
	if schchk() == true then
		if wday == 'Mon' then
			return mon()
		elseif wday == 'Tue' then
			return tue()
		elseif wday == 'Wed' then
			return wed()
		elseif wday == 'Thu' then
			return thu()
		else
			return fri()
		end
	else
		return 'No Class!'
	end
end	
there's some wacky naming going on in the code, and the code itself is kind of unfinished and unoptimized imo, but for me it just works out fine, so pardon me in advance.
User avatar
balala
Rainmeter Sage
Posts: 13530
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: SKIN:Bang not working

Post by balala »

Active Colors wrote: October 13th, 2021, 9:07 am Try this:

Code: Select all

function Update()
	return cperiod()
	SKIN:Bang('!UpdateMeter' 'ScrollingText'])
	SKIN:Bang('!UpdateMeter' 'ScrollingText2'])
	SKIN:Bang('!UpdateMeter' 'ScrollingText3'])
end
Unfortunately the closing brackets have been left there. Should be removed.
But additionally it's right, I focused on the end commands, and skipped the wrong form of the SKIN:Bang command.
User avatar
balala
Rainmeter Sage
Posts: 13530
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: SKIN:Bang not working

Post by balala »

FlightlessAz wrote: October 13th, 2021, 9:56 am scrolling-text-test.lua:
The posted .lua code doesn't contain the SKIN:Bang('[!UpdateMeter ScrollingText][!UpdateMeter ScrollingText2][!UpdateMeter ScrollingText3]') command, nor a similar one. However based on the last sentence:
FlightlessAz wrote: October 13th, 2021, 9:56 am there's some wacky naming going on in the code, and the code itself is kind of unfinished and unoptimized imo, but for me it just works out fine, so pardon me in advance.
I suppose you got it working well. Am I right?
User avatar
SilverAzide
Rainmeter Sage
Posts: 1674
Joined: March 23rd, 2015, 5:26 pm

Re: SKIN:Bang not working

Post by SilverAzide »

Guys...

The return cperiod() line has to be last. Otherwise the function is returning before any of the SKIN:Bangs get executed.

Code: Select all

function Update()
	SKIN:Bang('!UpdateMeter' 'ScrollingText'])
	SKIN:Bang('!UpdateMeter' 'ScrollingText2'])
	SKIN:Bang('!UpdateMeter' 'ScrollingText3'])
	return cperiod()
end
Gadgets Wiki GitHub More Gadgets...
FlightlessAz
Posts: 24
Joined: September 14th, 2021, 10:27 am

Re: SKIN:Bang not working

Post by FlightlessAz »

balala wrote: October 13th, 2021, 12:02 pm Unfortunately the closing brackets have been left there. Should be removed.
But additionally it's right, I focused on the end commands, and skipped the wrong form of the SKIN:Bang command.
I tried this line that you are referring, without the closing bracket, but it still didn't work.