local function hexa(dec)
local B,K,OUT,I,D = 16,"0123456789ABCDEF","",0
if dec == 0 then
OUT = "00"
elseif dec > 0 and dec < 16 then
D = dec + 1
OUT = "0"..string.sub(K,D,D)
elseif dec > 16 and dec < 256 then
V1 = math.modf(dec/B)+1
V2 = (dec-V1*16)
OUT = string.sub(K,V1,V1)..string.sub(K,V2,V2)
end
return OUT
end
this program convert a lower number in 256, and i use this in a formule
local function rod(x,y,n)
lvl = br.getControlRodLevel(n)
rouge = math.floor((100-lvl)*255/100)
vert = math.floor(lvl*255/100)
color = "#"..hexa(rouge)..hexa(vert).."00"
setColor(color,0x0000FF)
gpu.set(x,y,"█"..string.format("%3s",lvl).."█")
setColor(0x0, 0xFFFFFF)
end
if i print color, i obtain a value "#00FF00" to change color, but the format is not valid. There is a function to change format of this value ?
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Hello
I realizes a program to convert decimal in hexa.
this program convert a lower number in 256, and i use this in a formule
if i print color, i obtain a value "#00FF00" to change color, but the format is not valid. There is a function to change format of this value ?
thank you.
Link to post
Share on other sites