1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-12 11:10:29 +00:00

Add term.nativePaletteColo(u)r

This commit is contained in:
Lignum 2017-09-04 16:19:38 +02:00 committed by SquidDev
parent fb59da2b06
commit 070fd1f2ff
2 changed files with 25 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.core.computer.IComputerEnvironment; import dan200.computercraft.core.computer.IComputerEnvironment;
import dan200.computercraft.core.terminal.Terminal; import dan200.computercraft.core.terminal.Terminal;
import dan200.computercraft.shared.util.Colour;
import dan200.computercraft.shared.util.Palette; import dan200.computercraft.shared.util.Palette;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
@ -65,6 +66,8 @@ public class TermAPI implements ILuaAPI
"setPaletteColor", "setPaletteColor",
"getPaletteColour", "getPaletteColour",
"getPaletteColor", "getPaletteColor",
"nativePaletteColour",
"nativePaletteColor",
"getCursorBlink", "getCursorBlink",
}; };
} }
@ -289,6 +292,19 @@ public class TermAPI implements ILuaAPI
return null; return null;
} }
case 23: case 23:
case 24:
{
// nativePaletteColour/nativePaletteColor
int colour = 15 - parseColour( args );
Colour c = Colour.fromInt( colour );
float[] rgb = c.getRGB();
Object[] rgbObj = new Object[rgb.length];
for( int i = 0; i < rgbObj.length; ++i ) rgbObj[i] = rgb[i];
return rgbObj;
}
case 25:
// getCursorBlink // getCursorBlink
return new Object[] { m_terminal.getCursorBlink() }; return new Object[] { m_terminal.getCursorBlink() };
default: default:

View File

@ -42,11 +42,16 @@ term.native = function()
return native return native
end end
-- Some methods shouldn't go through redirects, so we move them to the main
-- term API.
for _, method in ipairs { "nativePaletteColor", "nativePaletteColour"} do
term[method] = native[method]
native[method] = nil
end
for k,v in pairs( native ) do for k,v in pairs( native ) do
if type( k ) == "string" and type( v ) == "function" then if type( k ) == "string" and type( v ) == "function" and term[k] == nil then
if term[k] == nil then term[k] = wrap( k )
term[k] = wrap( k )
end
end end
end end