mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 21:52:59 +00:00 
			
		
		
		
	Add valid check to term.setPaletteColor/getPaletteColor
This commit is contained in:
		 Wilma456 (Jakob0815)
					Wilma456 (Jakob0815)
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							579f7443a8
						
					
				
				
					commit
					30b55d966b
				
			| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user