PROPERTIES =
{
}
function Initialize()
Artist = SKIN:GetMeasure("MeasureArtist")
ShutUp = 0
end
function Update()
Title = Artist:GetStringValue()
if ShutUp == 0 and Title == "Advert:Radionomy"
then
SKIN:Bang("!PluginBang "mPlayer SetVolume 0"")
ShutUp = 1
elseif ShutUp == 1 and not Title == "Advert:Radionomy"
then
SKIN:Bang("!PluginBang "mPlayer SetVolume 100"")
ShutUp = 0
end
return Title
end
The error I get is : 19: ')' expected near 'mPlayer'.
When I remove the quotes between mPlayer SetVolume 0 and mPlayer SetVolume 100, I have no error but the bang doesn't work (and I have a notice in the log, something like "Undefined command").
This tells Lua that the quotes around "mPlayer SetVolume 0" are meant to be part of the parameter, rather than closing the first parameter and opening a new one.
Alternatively, since Lua allows you to use double quotes and single quotes interchangeably, you can also do it like this:
In this case, since you open the parameter with a single quote, it can only be closed with a single quote; the double quotes in your !PluginBang syntax won't interfere. :)
1) !PluginBang was depreciated. Please use !CommandMeasure.
2) You need to mix " and ' in lua or escape the additional quotes with \.
3) You can use ~= for not equal.
PROPERTIES =
{
}
function Initialize()
Artist = SKIN:GetMeasure("MeasureArtist")
ShutUp = 0
end
function Update()
Title = Artist:GetStringValue()
if ShutUp == 0 and Title == "Advert:Radionomy" then
SKIN:Bang('!CommandMeasure "mPlayer" "SetVolume 0"')
ShutUp = 1
elseif ShutUp == 1 and Title ~= "Advert:Radionomy" then
SKIN:Bang('!CommandMeasure "mPlayer" "SetVolume 100"')
ShutUp = 0
end
return Title
end
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 . . .
EDIT:
@smurfier: Thank you as well! I take your advices. Is there a real difference between "and not ==" and "and ~=" ? Or it's just for a better look?
There really isn't a difference, I just find it simpler. If you're going to compare something then inverse it, why not just use the inverse comparison?
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 . . .
Skymil wrote:Is there a real difference between "and not ==" and "and ~=" ? Or it's just for a better look?
I'm not 100% sure, but I think and not [Variable] == 'Value' would work even when [Variable] hasn't been declared, whereas and [Variable] ~= 'Value' would break the script in that case. I'm I'm right, then and not would actually be a slightly more stable way to formulate the condition. Which makes me think that I'm probably wrong. ;)
smurfier wrote:1) !PluginBang was depreciated. Please use !CommandMeasure.
I'm not sure of this, either. I think !CommandMeasure is meant for commanding Script measures, but I don't have any recollection of its replacing !PluginBang in other cases.
There really isn't a difference, I just find it simpler. If you're going to compare something then inverse it, why not just use the inverse comparison?
Ok. You're right. But, heh, maybe I prefer to have a tortured mind :P Thank you again for your quick answers.
I'm not 100% sure, but I think and not [Variable] == 'Value' would work even when [Variable] hasn't been declared, whereas and [Variable] ~= 'Value' would break the script in that case. I'm I'm right, then and not would actually be a slightly more stable way to formulate the condition. Which makes me think that I'm probably wrong.
Oh if it's the case, it's very strange.
Last edited by Skymil on August 29th, 2011, 5:11 pm, edited 1 time in total.
Added !CommandMeasure bang.
This replaces !PluginBang, which is being depreciated and should not be used in new skins. The reason for this change is that !CommandMeasure can be used to both send a bang to a plugin as !PluginBang did before, but can also be used to send a bang to any measure that can accept it. As of now, only the Measure=Script (Lua) measures can make use of this, but this may change over time.
The syntax is slightly different from !PluginBang as it is:
!CommandMeasure "MeasureName" "Arguments"
instead of:
!PluginBang "MeasureName Arguments'
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 . . .
This was partially my fault. We have indeed "depreciated" !PluginBang, but other than the release notes, this was not well documented. I have changed the entry for !PluginBang in the manual to reflect this, and have changed every manual entry and example skin for all plugins to reflect the new approach.