I have spent a good 45 minutes trying to solve this puzzle, but to no avail. Here I have a few simple if-then-else statements, which ought to work as intended. However, try as I might, the 'isHwinfoAvailable == 1' if-then-else ALWAYS executes the code in the else section, even when isHwinfoAvailable is 1 (as proven by the !Log command in the else section).
So what is going on!?
(This code is for a CPU Meter settings skin. The ToggleCoreTemps function toggles the core temperatures on and off by calling a !CommandMeasure bang in the CPU Meter skin itself. That part itself works fine, the only part that isn't working is the 'isHwinfoAvailable == 1' if-then-else statement that the !CommandMeasure is contained in. It always executes the code in the else section, even when the condition should be true).
Code: Select all
function Initialize()
cpuSettingsPath = SKIN:GetVariable('cpuSettingsPath')
cpuMeterPath = SKIN:GetVariable('cpuMeterPath')
cpuMeterConfig = SKIN:GetVariable('cpuMeterConfig')
end
function ToggleCoreTemps(currentValue)
local isHwinfoAvailable = SKIN:GetVariable('isHwinfoAvailable')
local cpuCores = SKIN:GetVariable('cpuCores')
if currentValue == 0 then
SKIN:Bang('!SetVariable', 'showCoreTemps', '1')
SKIN:Bang('!WriteKeyValue', 'Variables', 'showCoreTemps', '1', cpuSettingsPath)
if isHwinfoAvailable == 1 then
SKIN:Bang('!CommandMeasure', 'MeasureCpuConfigScript', 'ToggleTemps(' .. cpuCores .. ', true)', cpuMeterConfig)
else
SKIN:Bang('!Log', isHwinfoAvailable .. ' | Cannot display core temperatures, for HWiNFO is not running!', 'Error')
SKIN:Bang('!ShowMeter', 'CoreTempsErrorImage')
end
else
SKIN:Bang('!SetVariable', 'showCoreTemps', '0')
SKIN:Bang('!WriteKeyValue', 'Variables', 'showCoreTemps', '0', cpuSettingsPath)
SKIN:Bang('!CommandMeasure', 'MeasureCpuConfigScript', 'ToggleTemps(' .. cpuCores .. ', false)', cpuMeterConfig)
SKIN:Bang('!HideMeter', 'CoreTempsErrorImage')
end
SKIN:Bang('!UpdateMeterGroup', 'ShowCoreTemps')
SKIN:Bang('!Redraw')
end