in an instrument script I want to control the brightness of a text color. For that I have the variable gColorPrint.
From time to time I see this error in the logfile:
"error in dataref callback: logic.lua:266: bad argument #2 to 'format' (number has no integer representation)"
It happens in this line in my lua instrument script:
gColorPrint = string.format("#%02X%02X%02XFF",
toint(255*brightness_lines),
toint(255*brightness_lines),
toint(255*brightness_lines))
toint() is a function I found on the web that should make sure that only integer numbers are returned.:
Code: Select all
function toint(n)
-- needed because math.floor() returns floats
local s = tostring(n)
local i, j = s:find('%.')
if i then
return tonumber(s:sub(1, i-1))
else
return n
end
end
Before I have tried without toint() which also did not work in all situations.
Thank you for any help
Detlef