1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-12 18:30:29 +00:00

Merge pull request #415 from Wilma456/palletecheck

Add valid check to term.setPaletteColor/getPaletteColor
This commit is contained in:
Daniel Ratcliffe 2017-09-10 00:12:46 +01:00 committed by GitHub
commit 51644e32ed

View File

@ -288,6 +288,10 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
function window.setPaletteColour( colour, r, g, b )
if type( colour ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( colour ) .. ")", 2 ) end
if tHex[colour] == nil then
error( "Invalid color (got " .. colour .. ")" , 2 )
end
local tCol
if type(r) == "number" and g == nil and b == nil then
tCol = { colours.rgb8( r ) }
@ -311,6 +315,10 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
window.setPaletteColor = window.setPaletteColour
function window.getPaletteColour( colour )
if type( colour ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( colour ) .. ")", 2 ) end
if tHex[colour] == nil then
error( "Invalid color (got " .. colour .. ")" , 2 )
end
local tCol = tPalette[ colour ]
return tCol[1], tCol[2], tCol[3]
end