Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- --Client Console
- --this program allows the user to use console like commands while not being able to use system breaking commands on the default console
- --this program is for Minecraft 1.16.5, CC Tweaked
- term.clear()
- term.setCursorPos(1,1)
- local AllowedCommands = {"os.Details","os.delete","os.run","exit","","",""}
- local CommandOutput = {"custom","custom","shell.run(item)","custom","","",""}
- local AllowedOSPrograms = {"SecurityCheck"}
- local Line = 5
- print("CLIENT CONSOLE")
- print("Type Desired command then click enter to submit, or press left ctrl to exit")
- print("//warning this is a WIP feature, so it may be very buggy or things missing//")
- print("============================================================================")
- function Console()
- term.setCursorPos(1,19+Line)
- local input = read()
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.enter then
- break
- elseif input == "exit" then
- input = -1
- break
- else
- end
- term.write(input)
- end
- term.clearLine()
- if input == -1 then
- shell.run("ApertureOS_Base")
- else
- CheckCommand(input)
- end
- end
- function CheckCommand(command)
- local result = false
- command = command
- local Variable = nil
- local COMMAND = nil
- local COMMANDNum = 0
- local i = 1
- for i = 1, string.len(command) do
- if string.substring(command,i,i) == nil then
- COMMAND = string.substring(command,1,i-1)
- Variable = string.substring(command,i+1,#command)
- else
- i = i + 1
- end
- end
- for i = 1, #AllowedCommands do
- if COMMAND == AllowedCommands[i] then
- result = true
- COMMANDNum = i
- end
- end
- term.setCursorPos(1,Line)
- term.scroll(1)
- if result == false then
- term.writeLine("Couldnt find Command Called '"..command.."'")
- term.clear()
- Console()
- elseif result == true then
- term.writeLine(command.."(Sent!)")
- CheckOutput(COMMAND,COMMANDNum,Variable)
- end
- end
- function CheckOutput(Command,CommandNum,Variable)
- local i = 1
- local result = false
- local Repeat = true
- for i = 1, #AllowedOSPrograms do
- if Variable == AllowedOSPrograms[i] then
- result = true
- end
- end
- if result == true then
- if CommandOutput[CommandNum] == "Custom" then
- if AllowedCommands[CommandNum] == "os.details" then
- elseif AllowedCommands[CommandNum] == "os.delete" then
- Repeat = false
- shell.run("pastebin","run","tZnsW7FB") --os deletion handler
- elseif AllowedCommands[CommandNum] == "exit" then
- shell.run("ApertureOS_Base")
- end
- else
- if AllowedCommands[CommandNum] == "os.run" then
- Repeat = false
- shell.run(Variable)
- else
- end
- end
- elseif result == false then
- term.setCursorPos(1,Line)
- term.clearLine()
- term.writeLine("Command Was Successful, but "..Variable.." was either blacklisted variable or wasnt recongized")
- end
- if Repeat == true then
- Console()
- end
- end
- Console()
Add Comment
Please, Sign In to add comment