Advertisement
DOGGYWOOF

windows like GUI

Jan 5th, 2024 (edited)
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. -- Sample code for a Windows 11-like taskbar and start menu in ComputerCraft
  2.  
  3. local function drawHeader()
  4. term.setBackgroundColor(colors.blue)
  5. term.setTextColor(colors.white)
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. print(" Windows 11")
  9. end
  10.  
  11. local function drawTaskbar()
  12. term.setBackgroundColor(colors.black)
  13. term.setTextColor(colors.white)
  14. term.setCursorPos(1, 18)
  15. term.clearLine()
  16. print("Start")
  17. term.setCursorPos(10, 18)
  18. print("Apps")
  19. term.setCursorPos(20, 18)
  20. print("Settings")
  21. -- Add more taskbar icons as needed
  22. end
  23.  
  24. local function drawStartMenu()
  25. term.setBackgroundColor(colors.gray)
  26. term.setTextColor(colors.black)
  27. term.setCursorPos(1, 2)
  28. print("===========")
  29. print("= Programs =")
  30. print("===========")
  31. -- List programs or options in the start menu
  32. end
  33.  
  34. -- Main function to display GUI elements
  35. local function displayWindows11GUI()
  36. drawHeader()
  37. drawTaskbar()
  38. -- Example usage of opening the start menu
  39. -- This is simplified, and a more complex logic might be needed to handle interactions
  40. local openStartMenu = false
  41. while true do
  42. if openStartMenu then
  43. drawStartMenu()
  44. -- Logic to handle interactions in the start menu
  45. -- For example: listen for mouse clicks or key presses to close the start menu
  46. -- This would require more advanced handling within ComputerCraft
  47. break -- Exiting the loop for simplicity
  48. else
  49. local event, key = os.pullEvent("key")
  50. if key == keys.enter then
  51. openStartMenu = true
  52. end
  53. end
  54. end
  55. end
  56.  
  57. -- Example usage
  58. displayWindows11GUI()
  59.  
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement