This repository has been archived on 2024-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
FREAX/bin/clear
2022-07-18 19:33:40 +02:00

44 lines
891 B
Text

local tArgs = { ... }
local function printUsage()
local programName = "clear"
print("Usages:")
print(programName)
print(programName .. " screen")
print(programName .. " palette")
print(programName .. " all")
end
local function clear()
term.clear()
term.setCursorPos(1, 1)
end
local function clearPixels()
if term.getGraphicsMode then
term.setGraphicsMode(1)
term.clear()
term.setGraphicsMode(0)
end
end
local function resetPalette()
for i = 0, 15 do
term.setPaletteColour(2^i, term.nativePaletteColour(2^i))
end
end
local sCommand = tArgs[1] or "screen"
if sCommand == "screen" then
clear()
elseif sCommand == "palette" then
resetPalette()
elseif sCommand == "graphics" then
clearPixels()
elseif sCommand == "all" then
clear()
clearPixels()
resetPalette()
else
printUsage()
end