1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-26 23:42:18 +00:00

Clear gets an option to reset the palette (#582)

Fixes #555.
This commit is contained in:
Merith-TK 2021-04-21 08:32:34 -07:00
parent 624b23c7ac
commit f1ec59df15
4 changed files with 47 additions and 3 deletions

View File

@ -318,3 +318,10 @@ f194f4fa3a17c48ff1a9088d50063f4a675a23b6
Fix epoch documentation to use milliseconds (#580)
```
```
d2a1a00dc43e5b65f6b64111ce76dd3db16c919f
Clear gets an option to reset the palette (#582)
Fixes #555.

View File

@ -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

View File

@ -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

View File

@ -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