diff --git a/src/main/resources/data/computercraft/lua/rom/help/clear.txt b/src/main/resources/data/computercraft/lua/rom/help/clear.txt index 6e3258411..037d3c8a5 100644 --- a/src/main/resources/data/computercraft/lua/rom/help/clear.txt +++ b/src/main/resources/data/computercraft/lua/rom/help/clear.txt @@ -1 +1,6 @@ -clear clears the screen. +clear clears the screen and/or resets the palette. +ex: +"clear" clears the screen, but keeps the palette. +"clear screen" does the same as "clear" +"clear palette" resets the palette, but doesn't clear the screen +"clear all" clears the screen and resets the palette diff --git a/src/main/resources/data/computercraft/lua/rom/programs/clear.lua b/src/main/resources/data/computercraft/lua/rom/programs/clear.lua index d69a29993..cfd8cb9c4 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/clear.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/clear.lua @@ -1,2 +1,33 @@ -term.clear() -term.setCursorPos(1, 1) +local tArgs = { ... } + +local function printUsage() + local programName = arg[0] or fs.getName(shell.getRunningProgram()) + 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 resetPalette() + for i = 0, 15 do + term.setPaletteColour(math.pow(2, i), term.nativePaletteColour(math.pow(2, i))) + end +end + +local sCommand = tArgs[1] or "screen" +if sCommand == "screen" then + clear() +elseif sCommand == "palette" then + resetPalette() +elseif sCommand == "all" then + clear() + resetPalette() +else + printUsage() +end diff --git a/src/main/resources/data/computercraft/lua/rom/startup.lua b/src/main/resources/data/computercraft/lua/rom/startup.lua index 1b3046092..8c347cc33 100644 --- a/src/main/resources/data/computercraft/lua/rom/startup.lua +++ b/src/main/resources/data/computercraft/lua/rom/startup.lua @@ -49,6 +49,7 @@ end shell.setCompletionFunction("rom/programs/alias.lua", completion.build(nil, completion.program)) shell.setCompletionFunction("rom/programs/cd.lua", completion.build(completion.dir)) +shell.setCompletionFunction("rom/programs/clear.lua", completion.build({ completion.choice, { "screen", "palette", "all" } })) shell.setCompletionFunction("rom/programs/copy.lua", completion.build( { completion.dirOrFile, true }, completion.dirOrFile