Advertisement
DOGGYWOOF

Untitled

Feb 1st, 2025 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. local term = term
  2. local w, h = term.getSize()
  3.  
  4. -- Function to draw a window box
  5. local function drawBox(x, y, width, height, title)
  6. paintutils.drawFilledBox(x, y, x + width - 1, y + height - 1, colors.gray)
  7. paintutils.drawLine(x, y, x + width - 1, y, colors.lightGray)
  8.  
  9. term.setCursorPos(x + 2, y)
  10. term.setBackgroundColor(colors.lightGray)
  11. term.setTextColor(colors.black)
  12. term.clearLine()
  13. term.write(title)
  14.  
  15. term.setBackgroundColor(colors.gray)
  16. term.setTextColor(colors.white)
  17. end
  18.  
  19. -- Function to center text
  20. local function drawCenteredText(y, text)
  21. local x = math.floor((w - #text) / 2)
  22. term.setCursorPos(x, y)
  23. term.write(text)
  24. end
  25.  
  26. -- Function to show a message box
  27. local function showMessageBox(title, message)
  28. term.setBackgroundColor(colors.black)
  29. term.clear()
  30. drawBox(10, 5, w - 20, 6, title)
  31. drawCenteredText(7, message)
  32. drawCenteredText(9, "Press Enter to continue...")
  33. io.read()
  34. end
  35.  
  36. -- Function to display a loading bar
  37. local function showLoadingBar(message, totalSteps)
  38. local barWidth = w - 10
  39. drawBox(5, h / 2 - 2, barWidth, 5, "System Recovery")
  40.  
  41. for step = 1, totalSteps do
  42. term.setCursorPos(7, h / 2)
  43. term.write(message)
  44. term.setCursorPos(7, h / 2 + 1)
  45. term.write("[")
  46.  
  47. for i = 1, barWidth - 8 do
  48. if i <= (step / totalSteps) * (barWidth - 8) then
  49. term.write("=")
  50. else
  51. term.write(" ")
  52. end
  53. end
  54.  
  55. term.write("] " .. math.floor((step / totalSteps) * 100) .. "%")
  56. sleep(0.1)
  57. end
  58. end
  59.  
  60. -- Full System Recovery
  61. local function fullSystemRecovery()
  62. showLoadingBar("Recovering system...", 50)
  63. showMessageBox("Recovery Complete", "Doggy OS has been restored successfully.")
  64. end
  65.  
  66. -- Factory Reset (Wipes all except /disk/users/)
  67. local function wipeDataAndResetFactoryDefaults()
  68. showMessageBox("Warning", "This will erase all data except /disk/users/")
  69. showLoadingBar("Resetting to factory defaults...", 50)
  70. showMessageBox("Factory Reset Complete", "The system is now reset and ready for setup.")
  71. shell.run("/disk/setup")
  72. end
  73.  
  74. -- Recovery Menu
  75. local function recoveryMenu()
  76. while true do
  77. term.setBackgroundColor(colors.black)
  78. term.clear()
  79. drawBox(5, 3, w - 10, 8, "Recovery Options")
  80.  
  81. drawCenteredText(5, "1. Full System Recovery")
  82. drawCenteredText(6, "2. Factory Reset")
  83. drawCenteredText(7, "3. Exit")
  84.  
  85. term.setCursorPos(5, 10)
  86. local choice = tonumber(io.read())
  87. if choice == 1 then
  88. fullSystemRecovery()
  89. elseif choice == 2 then
  90. wipeDataAndResetFactoryDefaults()
  91. elseif choice == 3 then
  92. break
  93. else
  94. showMessageBox("Error", "Invalid choice. Please try again.")
  95. end
  96. end
  97. end
  98.  
  99. -- Power Menu (Reboot / Shutdown)
  100. local function powerMenu()
  101. term.setBackgroundColor(colors.black)
  102. term.clear()
  103. drawBox(5, 3, w - 10, 6, "Power Options")
  104.  
  105. drawCenteredText(5, "1. Reboot System")
  106. drawCenteredText(6, "2. Shutdown System")
  107.  
  108. term.setCursorPos(5, 8)
  109. local choice = tonumber(io.read())
  110. if choice == 1 then
  111. os.reboot()
  112. elseif choice == 2 then
  113. os.shutdown()
  114. else
  115. showMessageBox("Error", "Invalid choice.")
  116. end
  117. end
  118.  
  119. -- Main Menu
  120. local function mainMenu()
  121. while true do
  122. term.setBackgroundColor(colors.black)
  123. term.clear()
  124. drawBox(5, 3, w - 10, 8, "Doggy OS Recovery")
  125.  
  126. drawCenteredText(5, "1. Recovery Options")
  127. drawCenteredText(6, "2. Power Options")
  128. drawCenteredText(7, "3. Exit")
  129.  
  130. term.setCursorPos(5, 10)
  131. local choice = tonumber(io.read())
  132. if choice == 1 then
  133. recoveryMenu()
  134. elseif choice == 2 then
  135. powerMenu()
  136. elseif choice == 3 then
  137. break
  138. else
  139. showMessageBox("Error", "Invalid choice. Please try again.")
  140. end
  141. end
  142. end
  143.  
  144. mainMenu()
  145.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement