Advertisement
DOGGYWOOF

Admin shell

Mar 29th, 2024 (edited)
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. -- Function to draw navigation bar
  2. function drawNavBar()
  3. local screenWidth, screenHeight = term.getSize()
  4. local navBarWidth = 20
  5. local navBarStart = math.floor((screenWidth - navBarWidth) / 2)
  6.  
  7. -- Save current cursor position
  8. local oldX, oldY = term.getCursorPos()
  9.  
  10. -- Draw Recents button
  11. term.setCursorPos(navBarStart + 4, screenHeight)
  12. term.setBackgroundColor(colors.black)
  13. term.setTextColor(colors.white)
  14. term.write(" lll ")
  15.  
  16. -- Draw Home button
  17. term.setCursorPos(navBarStart + 9, screenHeight)
  18. term.setBackgroundColor(colors.black)
  19. term.setTextColor(colors.white)
  20. term.write(" () ")
  21.  
  22. -- Draw Back button
  23. term.setCursorPos(navBarStart + 14, screenHeight)
  24. term.setBackgroundColor(colors.black)
  25. term.setTextColor(colors.white)
  26. term.write(" < ")
  27.  
  28. -- Restore cursor position
  29. term.setCursorPos(oldX, oldY)
  30. end
  31.  
  32. --Alternative shell from CraftOS shell
  33.  
  34. termutils = {}
  35.  
  36. termutils.clear = function()
  37. term.clear()
  38. term.setCursorPos(1,1)
  39. end
  40.  
  41. termutils.clearColor = function()
  42. term.setTextColor(colors.white)
  43. term.setBackgroundColor(colors.black)
  44. end
  45.  
  46. function input()
  47. termutils.clearColor()
  48. drawNavBar() -- Draw the navigation bar
  49. term.setTextColor(colors.blue)
  50. local dir = shell.dir().."/"..">"
  51. write(dir)
  52. termutils.clearColor()
  53. command = io.read()
  54.  
  55. -- Detect mouse click events
  56. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  57. if yPos == term.getHeight() then
  58. if xPos >= navBarStart + 4 and xPos <= navBarStart + 6 then
  59. -- Execute recents command
  60. shell.run("/disk/os/recents")
  61. elseif xPos >= navBarStart + 9 and xPos <= navBarStart + 11 then
  62. -- Execute home command
  63. shell.run("/disk/os/gui")
  64. end
  65. end
  66. end
  67.  
  68. termutils.clear()
  69. print("Dogdroid Admin Shell V12.0")
  70. while true do
  71. input()
  72. shell.run(command)
  73. end
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement