mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-17 21:55:12 +00:00
Allow passing RGB8 hex values to term.setColour
This commit is contained in:
@@ -243,21 +243,29 @@ public class MonitorPeripheral implements IPeripheral
|
||||
@SuppressWarnings( { "unchecked" } ) // There isn't really a nice way around this :(
|
||||
HashMap<Object, Object> colourTbl = (HashMap<Object, Object>)args[0];
|
||||
dan200.computercraft.core.apis.TermAPI.setColour( terminal, colourTbl );
|
||||
return null;
|
||||
}
|
||||
else if (args.length >= 4 && args[0] instanceof Double && args[1] instanceof Double && args[2] instanceof Double && args[3] instanceof Double)
|
||||
|
||||
if(args.length == 2 && args[0] instanceof Double && args[1] instanceof Double)
|
||||
{
|
||||
int colour = 15 - dan200.computercraft.core.apis.TermAPI.parseColour( args, true );
|
||||
int hex = ((Double)args[1]).intValue();
|
||||
float[] rgb = Palette.decodeRGB8( hex );
|
||||
dan200.computercraft.core.apis.TermAPI.setColour( terminal, colour, rgb[0], rgb[1], rgb[2] );
|
||||
return null;
|
||||
}
|
||||
|
||||
if (args.length >= 4 && args[0] instanceof Double && args[1] instanceof Double && args[2] instanceof Double && args[3] instanceof Double)
|
||||
{
|
||||
int colour = 15 - dan200.computercraft.core.apis.TermAPI.parseColour( args, true );
|
||||
float r = ((Double)args[1]).floatValue();
|
||||
float g = ((Double)args[2]).floatValue();
|
||||
float b = ((Double)args[3]).floatValue();
|
||||
dan200.computercraft.core.apis.TermAPI.setColour( terminal, colour, r, g, b );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new LuaException( "Expected table or number, number, number, number" );
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
throw new LuaException( "Expected table or number, number, number, number" );
|
||||
}
|
||||
case 22:
|
||||
case 23:
|
||||
|
||||
Reference in New Issue
Block a user