Does anyone know a better way?
Thanks
Code: Select all
spd_txt = txt_add(" ", "font:digital-7-mono.ttf;size:28px; color: #e5f0ff; halign: right;", 51, 26, 52, 30)
function mcp_spd_chg(spd_mach, is_mach)
if spd_mach < 1 then
txt_set(spd_txt,string.format( ".%02f", spd_mach * 100 ))
else
-- txt_set(spd_txt,string.format("%03.0f", spd_mach))
spd = string.format("%03.0f", spd_mach)
if speed_1 then
remove(speed_1)
end
if speed_2 then
remove(speed_2)
end
if speed_3 then
remove(speed_3)
end
speed_1 = img_add(digits[string.sub(spd, 1, 1)],51,25,28,35)
speed_2 = img_add(digits[string.sub(spd, 2, 2)],72,25,28,35)
speed_3 = img_add(digits[string.sub(spd, 3, 3)],93,25,28,35)
end
end
digits = {
["0"] = "7SEG/7SEG_0.png",
["1"] = "7SEG/7SEG_1.png",
["2"] = "7SEG/7SEG_2.png",
["3"] = "7SEG/7SEG_3.png",
["4"] = "7SEG/7SEG_4.png",
["5"] = "7SEG/7SEG_5.png",
["6"] = "7SEG/7SEG_6.png",
["7"] = "7SEG/7SEG_7.png",
["8"] = "7SEG/7SEG_8.png",
["9"] = "7SEG/7SEG_9.png",
}