neat !
Integer number from Lua calculation needed
- Keith Baxter
- Posts: 4684
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Integer number from Lua calculation needed
Hi,jph wrote: ↑Tue Nov 22, 2022 12:12 pmThat should never be an issue as the 'brightness' multiplier per colour would presumably be <= 1Keith Baxter wrote: ↑Tue Nov 22, 2022 11:25 am
Using math.floor( ) will create errors as values will be outside of 0..255 scope.
You can use var_cap() for this.
Keith
That isn't a problem.
Sorry that is incorrect. He is looking for values 0 to 255. This could be for brightness on a color 8 digit hex or the changing of the color hex pair.
The 4th pair is opacity.
AM uses opacity() but that is not precise to actual color hex. Using 8 digit hex gives exact control on all R,G,B and opacity.
I think the OP wants, is to control opacity of instruments/panels using color hex codes from a decimal 0 ->1 dataref
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
- Keith Baxter
- Posts: 4684
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Integer number from Lua calculation needed
Hi,
Try 0,0,0,1 or 1,1,1,0 also just for fun 0,0,0,0.5
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
Re: Integer number from Lua calculation needed
That should in theory work as well.
- Keith Baxter
- Posts: 4684
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Integer number from Lua calculation needed
Hi,
Yes and color hex code also works in all AM functions. Whilst 8 digit color hex code is not mentioned in the API like other many features it is a very useful feature.
Normal opaque black hex- “#000000”
Fully transparent – “#00000000”
Fully opaque – “#000000FF”
50% transparent – “#0000007F”
Keith
Last edited by Keith Baxter on Tue Nov 22, 2022 1:45 pm, edited 1 time in total.
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
Re: Integer number from Lua calculation needed
Yes, therefore if you multiply a value of 255 or less by 1 or less then you will never get a value of > 255Keith Baxter wrote: ↑Tue Nov 22, 2022 12:32 pmHi,jph wrote: ↑Tue Nov 22, 2022 12:12 pmThat should never be an issue as the 'brightness' multiplier per colour would presumably be <= 1Keith Baxter wrote: ↑Tue Nov 22, 2022 11:25 am
Using math.floor( ) will create errors as values will be outside of 0..255 scope.
You can use var_cap() for this.
Keith
That isn't a problem.
Sorry that is incorrect. He is looking for values 0 to 255. This could be for brightness on a color 8 digit hex or the changing of the color hex pair.
The 4th pair is opacity.
AM uses opacity() but that is not precise to actual color hex. Using 8 digit hex gives exact control on all R,G,B and opacity.
I think the OP wants, is to control opacity of instruments/panels using color hex codes from a decimal 0 ->1 dataref
Keith
The <= 1 part is obviously not an integer..... hence it is NOT
(the above is incorrect in this case) which is exactly what I said. tum te tum te tum.Using math.floor( ) will create errors as values will be outside of 0..255 scope.
Joe. CISSP, MSc.
- Keith Baxter
- Posts: 4684
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Integer number from Lua calculation needed
Joe,
I fully understand the issue and know the resolve. I have no appetite to argue with you.
Keith
EDIT: @Corjan Any chance of a hex converter ?
I fully understand the issue and know the resolve. I have no appetite to argue with you.
Keith
EDIT: @Corjan Any chance of a hex converter ?
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
Re: Integer number from Lua calculation needed
Not arguing old chap, just pointing out the error of your ways.
Which way do you want to convert hex ?
hex to dec
You can use tonumber already as in
Which way do you want to convert hex ?
hex to dec
You can use tonumber already as in
Code: Select all
x =(tonumber("0xFF"))
print (x)
-- or
print(tonumber("0xFF"))
-- or
y =(tonumber("FF",16))
print (y)
--or
print(tonumber("FF",16))
Joe. CISSP, MSc.
- Keith Baxter
- Posts: 4684
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Integer number from Lua calculation needed
Hi,
The crux of the OP question is to create a Hex value ( dataref or some other source) from a decimal 0 ->1 value without a nil returned.
Just to be clear for all hex color is RGBA
Keith
The crux of the OP question is to create a Hex value ( dataref or some other source) from a decimal 0 ->1 value without a nil returned.
Just to be clear for all hex color is RGBA
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
Re: Integer number from Lua calculation needed
The issue was not stopping a nil but rather a way to stop the calculation that feeds into the hex conversion from returning a float because the conversion only accepts an integer.Keith Baxter wrote: ↑Tue Nov 22, 2022 1:56 pm Hi,
The crux of the OP question is to create a Hex value ( dataref or some other source) from a decimal 0 ->1 value without a nil returned.
Keith
Additionally math.floor() and var_round() or var_format() do not produce the same. Try 4.7 in them and you’ll see the difference. Just wanted to clear that up so someone doesn’t read that later and think you’ll get the same result from those.Keith Baxter wrote: ↑Tue Nov 22, 2022 7:45 am math.floor() and var_round() or var_format() produce the same. math.cell() is different.
Air Manager panels at https://www.experimentalsimavionics.com
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D
Youtube Channel https://www.youtube.com/channel/UC8ZqXX ... kfZMq5BKig
Air Manager API Tutorial Video Series https://youtube.com/playlist?list=PLNr0 ... baT4gJKg5D