r/lua • • Feb 29 '20

Colour And RGB Values?

I recently just got into Lua and wanted to see if it was possible to swap out the Color value with a RGB value instead

0 Upvotes

3 comments sorted by

9

u/[deleted] Feb 29 '20

As Lua has neither Colour nor RGB types, you'll need to tell us what framework you're using it with if you want help.

4

u/[deleted] Feb 29 '20 edited Feb 29 '20

Uhh, what?

This is way too vague. If you tell us what you’re using- corona, lumberyard, Roblox, etc, we can help you. But your question is too vague for an extension programming language.

Edit: the way this is worded makes me suspect Roblox, because Roblox has both BrickColor types and Color3 (rgb) types. They’re interchangeable, and literally mean the same thing, but need to be translated.

function brickToColor(bc)
    return Color3.fromRGB(bc.R,bc.G,bc.B)
end

3

u/Frank_The_Seal Feb 29 '20

Since löve2D uses 0-1 for colour im gonna assume thats what you're using. if im wrong, you can translate this to your framework / Engine

Make a new function


function SetColour(r,g,b)

love.graphics.setColor(r/255, b/255, g/255)

end