Advertisement
DOGGYWOOF

PIN lock for Doggy OS pocket

Mar 10th, 2024 (edited)
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. local buttons = {
  2. { name = "Command", x = 2, y = 3, width = 15, height = 1, color = colors.gray, command = "/disk/os/home.lua" },
  3. { name = "Programs", x = 2, y = 5, width = 15, height = 1, color = colors.gray, command = "/disk/os/programs" },
  4. { name = "All Programs", x = 2, y = 9, width = 15, height = 1, color = colors.gray, command = "showAllPrograms" },
  5. { name = "Power Menu", x = 2, y = 11, width = 15, height = 1, color = colors.gray, command = "showPowerMenu" }
  6. }
  7.  
  8. local function drawAllPrograms()
  9. term.setBackgroundColor(colors.gray)
  10. term.setTextColor(colors.white)
  11. term.clear()
  12. term.setCursorPos(1, 1)
  13. term.write("All Programs:")
  14.  
  15. local programPath = "/disk/packages/"
  16. local programs = fs.list(programPath)
  17.  
  18. local y = 3
  19. for _, program in ipairs(programs) do
  20. term.setCursorPos(2, y)
  21. term.clearLine()
  22. term.write(" " .. program .. " ")
  23. y = y + 1
  24. end
  25. end
  26.  
  27. -- ... (rest of the code remains unchanged)
  28.  
  29. local function handleButtonClick(command)
  30. if command == "showAllPrograms" then
  31. drawAllPrograms()
  32. os.pullEvent("key") -- Wait for a key press to return to the homescreen
  33. else
  34. launchApp(command)
  35. end
  36. end
  37.  
  38. -- ... (rest of the code remains unchanged)
  39.  
  40. local function homescreen()
  41. while true do
  42. drawHomescreen()
  43. local event, _, x, y = os.pullEvent("mouse_click")
  44.  
  45. if event == "mouse_click" then
  46. local appCommand = handleAppClick(x, y)
  47. if appCommand then
  48. handleButtonClick(appCommand)
  49. return -- Terminate the program after launching the app or showing power menu
  50. end
  51. end
  52. end
  53. end
  54.  
  55. homescreen()
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement