Jump to content

DCS World OpenBeta/Scripts/Common/utils.lua -> Error in 'makeColor' function?


Go to solution Solved by scoobie,

Recommended Posts

Posted

This is what's there right now:

function makeColor(R, G, B)
	return R * 256 * 256 + G * 256 + B
end

 

Surely this is what it's supposed to be:

function makeColor(R, G, B)
	return R * 256 + G * 256 + B * 256
end

?

Posted (edited)

Actually isn't it completely redundant?

function makeColor(R, G, B)
	return R * 256 * 256 + G * 256 + B
end

COLOR = {
	WHITE 		= makeColor(255, 255, 255),
	LIGHT_GRAY 	= makeColor(200, 200, 200),
	DARK_GRAY 	= makeColor(74, 74, 74),
	RED 		= makeColor(125, 75, 0),
	BLUE 		= makeColor(0, 75, 125),
	BLACK 		= makeColor(0, 0, 0)
}

 

The whole point of that function is to turn a floating point number into a valid RGB value. But you're providing actual RGB non float integer values. So what's the point of it at all? 

 

 

Edited by Elphaba
  • Solution
Posted

I'm not sure what you mean. They're just throwing each basic colour (values 0..255) onto its appropriate byte in a number (B lowest, G next, R highest), like this (apostrophes separate bytes for clarity, each character is a bit):


RRRRRRRR'GGGGGGGG'BBBBBBBB


However... this is not a normal language, but this Lua thing, so the little code can as well launch a space probe to the orbit or do laundry for aunt Helen, no one knows 😉

 

  • Like 1

i7-8700K 32GB 3060Ti 27"@1080p TM Hawg HOTAS TPR TIR5 SD-XL 2xSD+ HC Bravo button/pot box

Posted
11 hours ago, Elphaba said:

Surely this is what it's supposed to be

You don't assume if the code is right not knowing the rest of the program.

🖥️ Win10  i7-10700KF  32GB  RTX4070S   🥽 Quest 3   🕹️ T16000M  VPC CDT-VMAX  TFRP   ✈️ FC3  F-14A/B  F-15E   ⚙️ CA   🚢 SC   🌐 NTTR  PG  Syria

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...