Advertisement
DOGGYWOOF

recovery GUI

Jan 3rd, 2024 (edited)
3
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. -- Enhanced recovery menu GUI in ComputerCraft
  2.  
  3. local function drawButton(x, y, width, label, backgroundColor, textColor)
  4. paintutils.drawFilledBox(x, y, x + width - 1, y + 3, backgroundColor)
  5. term.setCursorPos(x + math.floor((width - #label) / 2), y + 1)
  6. term.setTextColor(textColor)
  7. print(label)
  8. end
  9.  
  10. local function drawMenu()
  11. term.setBackgroundColor(colors.black)
  12. term.clear()
  13.  
  14. -- Draw the menu
  15. drawButton(10, 5, 20, "Recover Data", colors.blue, colors.white)
  16. drawButton(10, 9, 20, "Restore System", colors.green, colors.white)
  17. -- Add more buttons as needed
  18. end
  19.  
  20. local function handleClick(x, y)
  21. if x >= 10 and x <= 29 then
  22. if y == 5 then
  23. term.clear()
  24. print("Initiating data recovery...")
  25. -- Add your data recovery logic here
  26. elseif y == 9 then
  27. term.clear()
  28. print("Initiating system restoration...")
  29. -- Add your system restoration logic here
  30. -- Add more conditions for additional buttons
  31. end
  32. end
  33. end
  34.  
  35. local function handleInput()
  36. while true do
  37. local event, button, x, y = os.pullEvent("mouse_click")
  38.  
  39. if event == "mouse_click" then
  40. handleClick(x, y)
  41. break
  42. end
  43. end
  44. end
  45.  
  46. local function main()
  47. drawMenu()
  48. handleInput()
  49. end
  50.  
  51. main()
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement