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:
parent
fb59da2b06
commit
070fd1f2ff
@ -11,6 +11,7 @@ import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.core.computer.IComputerEnvironment;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
@ -65,6 +66,8 @@ public class TermAPI implements ILuaAPI
|
||||
"setPaletteColor",
|
||||
"getPaletteColour",
|
||||
"getPaletteColor",
|
||||
"nativePaletteColour",
|
||||
"nativePaletteColor",
|
||||
"getCursorBlink",
|
||||
};
|
||||
}
|
||||
@ -289,6 +292,19 @@ public class TermAPI implements ILuaAPI
|
||||
return null;
|
||||
}
|
||||
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
|
||||
return new Object[] { m_terminal.getCursorBlink() };
|
||||
default:
|
||||
|
@ -42,11 +42,16 @@ term.native = function()
|
||||
return native
|
||||
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
|
||||
if type( k ) == "string" and type( v ) == "function" then
|
||||
if term[k] == nil then
|
||||
term[k] = wrap( k )
|
||||
end
|
||||
if type( k ) == "string" and type( v ) == "function" and term[k] == nil then
|
||||
term[k] = wrap( k )
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user