Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ComputerCraft Operating System
- -- Initialize the operating system
- local os = {}
- -- Function to start the OS
- function os.start()
- print("Welcome to the ComputerCraft OS!")
- os.run()
- end
- -- Function to run the main loop
- function os.run()
- while true do
- print("Type 'help' for a list of commands.")
- local input = read()
- os.execute(input)
- end
- end
- -- Function to execute commands
- function os.execute(command)
- if command == "help" then
- print("Available commands: help, exit, clear")
- elseif command == "exit" then
- print("Shutting down...")
- os.shutdown()
- elseif command == "clear" then
- term.clear()
- term.setCursorPos(1, 1)
- else
- print("Command not recognized.")
- end
- end
- -- Function to shutdown the OS
- function os.shutdown()
- os.run = function() end -- Prevents the loop from continuing
- end
- -- Start the operating system
- os.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement