Advertisement
roblox7384

Untitled

Dec 18th, 2024
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. # ComputerCraft Operating System
  2.  
  3. -- Initialize the operating system
  4. local os = {}
  5.  
  6. -- Function to start the OS
  7. function os.start()
  8. print("Welcome to the ComputerCraft OS!")
  9. os.run()
  10. end
  11.  
  12. -- Function to run the main loop
  13. function os.run()
  14. while true do
  15. print("Type 'help' for a list of commands.")
  16. local input = read()
  17. os.execute(input)
  18. end
  19. end
  20.  
  21. -- Function to execute commands
  22. function os.execute(command)
  23. if command == "help" then
  24. print("Available commands: help, exit, clear")
  25. elseif command == "exit" then
  26. print("Shutting down...")
  27. os.shutdown()
  28. elseif command == "clear" then
  29. term.clear()
  30. term.setCursorPos(1, 1)
  31. else
  32. print("Command not recognized.")
  33. end
  34. end
  35.  
  36. -- Function to shutdown the OS
  37. function os.shutdown()
  38. os.run = function() end -- Prevents the loop from continuing
  39. end
  40.  
  41. -- Start the operating system
  42. os.start()
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement