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

SKIN:Bang not working

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

Re: SKIN:Bang not working

Post by FlightlessAz »

balala wrote: October 13th, 2021, 12:06 pm 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:

I suppose you got it working well. Am I right?
I already tried running the skin with the SKIN:Bang('[!UpdateMeter ScrollingText][!UpdateMeter ScrollingText2][!UpdateMeter ScrollingText3]') command, but to no avail it didn't work as well. And nope, what I was referring to the last sentence was that simply there was some weird names for some of the variables in my command, for example, i have a variable named 'Bruh' which equates to the string 'bruh moment,' thought I'd just give you a heads up about that :rolmfao:

Unfortuately, the code still doesn't work :(
FlightlessAz
Posts: 24
Joined: September 14th, 2021, 10:27 am

Re: SKIN:Bang not working

Post by FlightlessAz »

SilverAzide wrote: October 13th, 2021, 12:07 pm 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
The idea here is that a measure in the .ini reads the cperiod() in the lua script to display in a meter, so updating the said meter before returning the cperiod() string would be kind of useless. Nonetheless, I tried to do your suggestion, but to no avail, it still doesn't work.

I'm starting to think this is some sort of file encoding problem, since There's this timer skin that uses SKIN:Bang successfully with no problems. :Whistle
FlightlessAz
Posts: 24
Joined: September 14th, 2021, 10:27 am

Re: SKIN:Bang not working

Post by FlightlessAz »

SilverAzide wrote: October 13th, 2021, 12:07 pm 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
Ah, but following your suggestion, the 'file not valid' error doesn't appear in the about section anymore. But then again, doing it this way won't update the meter even when the cperiod() returns a different string.
FlightlessAz
Posts: 24
Joined: September 14th, 2021, 10:27 am

Re: SKIN:Bang not working

Post by FlightlessAz »

I'd also like to add that when exectuing print(SKIN:Bang('[!UpdateMeter ScrollingText]')), the log returns 'Script: scrolling-text-test.lua:150: attempt to index global 'SKIN' (a nil value)'.
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'd like to add that in killall-q's "T-minus timer" lua script, he chains SKIN:Bang commands like this with no problem at all. If you want, I can link you to his timer skin.
User avatar
balala
Rainmeter Sage
Posts: 13528
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: SKIN:Bang not working

Post by balala »

I see a few mistakes and weird things in the code of the .lua script file.
First you should move the Update() function to the end of the whole code, because it has to return the value of the cperiod() function, which now is located after the Update() function. The reason why should you do this move, is the same as what SilverAzide has described about the return cperiod() command, which should be the last in the Update() function (regardless if his idea is right or not). Right now the cperiod() function is the last one in the code, accordingly the Update() function, which precedes the cperiod() function has nothing to return (at least on the first update cycle). I'd move it as described above.
Secondly the SKIN:Bang command should have the following form:

Code: Select all

SKIN:Bang('!UpdateMeter', 'ScrollingText')
SKIN:Bang('!UpdateMeter', 'ScrollingText2')
SKIN:Bang('!UpdateMeter', 'ScrollingText3')
(note the commas between the '!UpdateMeter' and the 'ScrollingTextX' parameters)
If these don't fixes the issues, please post again the exact code of both, the .ini and the .lua files, because you probably updated them both and additionally the posted code of the .lua file doesn't even match your other replies here.
FlightlessAz
Posts: 24
Joined: September 14th, 2021, 10:27 am

Re: SKIN:Bang not working

Post by FlightlessAz »

balala wrote: October 13th, 2021, 4:01 pm I see a few mistakes and weird things in the code of the .lua script file.
First you should move the Update() function to the end of the whole code, because it has to return the value of the cperiod() function, which now is located after the Update() function. The reason why should you do this move, is the same as what SilverAzide has described about the return cperiod() command, which should be the last in the Update() function (regardless if his idea is right or not). Right now the cperiod() function is the last one in the code, accordingly the Update() function, which precedes the cperiod() function has nothing to return (at least on the first update cycle). I'd move it as described above.
Secondly the SKIN:Bang command should have the following form:

Code: Select all

SKIN:Bang('!UpdateMeter', 'ScrollingText')
SKIN:Bang('!UpdateMeter', 'ScrollingText2')
SKIN:Bang('!UpdateMeter', 'ScrollingText3')
(note the commas between the '!UpdateMeter' and the 'ScrollingTextX' parameters)
If these don't fixes the issues, please post again the exact code of both, the .ini and the .lua files, because you probably updated them both and additionally the posted code of the .lua file doesn't even match your other replies here.
Again, I don't think the location of the Update() function and cperiod()'s location inside it is the main problem here, since with this order, the script works just fine if the SKIN:Bang line isn't there, but nonetheless, I tried your suggestion: putting Update() at the end of the code and putting cperiod() in the last line of Update() after the SKIN:Bang. Unfortunately, the code still doesn't work.

I uploaded the files itself, one folder with the Update() at the beginning without the SKIN:Bang lines and another with the Update() at the end of the code with the SKIN:Bang lines, hoping that you might find something about the file formatting itself rather than the code, that I am oblivious about.

https://www.mediafire.com/file/aut3xdoghgwpldp/Skin_Code.zip/file
User avatar
death.crafter
Rainmeter Sage
Posts: 1206
Joined: April 24th, 2021, 8:13 pm

Re: SKIN:Bang not working

Post by death.crafter »

O.O
FlightlessAz wrote: October 13th, 2021, 1:53 pm Ah, but following your suggestion, the 'file not valid' error doesn't appear in the about section anymore. But then again, doing it this way won't update the meter even when the cperiod() returns a different string.
What stops you from doing this?

Code: Select all

function Update()
    return cperiod()
end

Code: Select all

[MeasureScript]
Measure=Script
ScriptFile=blah
OnUpdateAction=whatever you want to bang
from the Realm of Death
User avatar
death.crafter
Rainmeter Sage
Posts: 1206
Joined: April 24th, 2021, 8:13 pm

Re: SKIN:Bang not working

Post by death.crafter »

balala wrote: October 13th, 2021, 4:01 pm First you should move the Update() function to the end of the whole code, because it has to return the value of the cperiod() function, which now is located after the Update() function. The reason why should you do this move, is the same as what SilverAzide has described about the return cperiod() command, which should be the last in the Update() function (regardless if his idea is right or not). Right now the cperiod() function is the last one in the code, accordingly the Update() function, which precedes the cperiod() function has nothing to return (at least on the first update cycle). I'd move it as described above.
Lua doesn't really care where a function is defined. So that isn't a problem here. The problem is that the OP is returning before his work is done. Once return is used, function stops there and returns whatever is in parameter.
balala wrote: October 13th, 2021, 4:01 pm Secondly the SKIN:Bang command should have the following form:

Code: Select all

SKIN:Bang('!UpdateMeter', 'ScrollingText')
SKIN:Bang('!UpdateMeter', 'ScrollingText2')
SKIN:Bang('!UpdateMeter', 'ScrollingText3')
Actually no. You can use usual bangs too. And in my opinion, this is not quite efficient to break up a statement if you could write it in one line.

However, the above syntax is quite useful if you are trying to use lua values as parameters to the bang.

Also to the OP.

Have you considered using inline variables as value to the string meter you are using?

If you use an inline variable e.g. [&YourLuaScript:cperiod()], then you can skip the return part in Update.

Also, if you feel like cperiod is a quite heavy function, then you should not use it as a section variable and use what I described in the previous post.
from the Realm of Death
FlightlessAz
Posts: 24
Joined: September 14th, 2021, 10:27 am

Re: SKIN:Bang not working

Post by FlightlessAz »

death.crafter wrote: October 14th, 2021, 9:28 am O.O

What stops you from doing this?

Code: Select all

function Update()
    return cperiod()
end

Code: Select all

[MeasureScript]
Measure=Script
ScriptFile=blah
OnUpdateAction=whatever you want to bang
Hello, I tried doing this, but the meter doesn't update at all, even when the cperiod value is supposed to change. It only shows the change visually on the meter when you manually refresh the skin.