kennyist wrote:I'm trying to make a level script, So a meter gets a new level text depending on what "XP" you have from a Calc measure.
Code: Select all
PROPERTIES =
{
}
function Initialize()
Level = SKIN:GetMeasure("Level1")
end -- function Initialize
function Update()
XpSystem = SKIN:GetValue("XpSytem")
if Xpsystem > 50 then
SKIN:Bang('!SetOption "Level" "Text" "Level 1"')
end
if Xpsystem < 50 then
SKIN:Bang('!SetOption "Level" "Text" "Level 2"')
end
if Xpsystem < 100 then
SKIN:Bang('!SetOption "Level" "Text" "Level 3"')
end
end -- function Update
You have the right idea, but there are a couple of problems that are easily solved.
Code: Select all
function Initialize()
msXP = SKIN:GetMeasure('XpSystem')
end -- function Initialize
function Update()
valXP = msXP:GetValue()
if valXP < 50 then
SKIN:Bang('!SetOption Level1 Text \"Level 1\"')
elseif valXP < 100 then
SKIN:Bang('!SetOption Level1 Text \"Level 2\"')
else
SKIN:Bang('!SetOption Level1 Text \"Level 3\"')
end
end -- function Update
In Initialize() you want to get a handle to the measure you are going to get the value for later on each Update(). The measure in the skin that returns a value in this case is [XpSystem], so you want to set up a variable that is a handle to that measure. That is what I did with
msXP = SKIN:GetMeasure('XpSystem').
Now on each Update(), you will retrieve the current value of that measure and put that in a variable that you can test. That is what
valXP = msXP:GetValue() does. So now valXP will contain the number returned by the measure [XpSystem] in the skin.
Now you can do your testing and set the "Text" option of the meter in the skin. The meter in question is [Level1], so you just use
SKIN:Bang('!SetOption Level1 Text \"Level 1\"') to set it. Note that you don't need quotes around each parameter to the bang, only when you are sending a value with "white space", in which case you send the quotes to Rainmeter, but need to "escape" them with the "\" char so they are not seen as quotes by the Lua, but only by Rainmeter.
Note: Don't use the PROPERTIES function at all anymore. It has been deprecated and is no longer needed.