Advertisement
Marlingaming

Handbook Skeleton system

Jun 14th, 2023 (edited)
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. --this is the skeleton program for E-Handbook
  2. local Page = {}
  3.  
  4.  
  5. local CPage = "home.txt"
  6.  
  7. local function Clean()
  8. term.clear()
  9. term.setCursorPos(1,1)
  10. end
  11.  
  12. local function Options(Y,OPTs)
  13. term.setCursorPos(1,Y)
  14. local n = 1
  15. while true do
  16. for i = 1, #OPTs do
  17. term.setCursorPos(1,Y+(i-1))
  18. term.clearLine()
  19. if n == i then term.write(">> "..i.." - "..OPTs[i].. "<<") else term.write(i.." - "..OPTs[i]) end
  20. end
  21. local a, b = os.pullEvent("key")
  22. if b == keys.w or b == keys.up then if n == 1 then n = #OPTs else n = n - 1 end end
  23. if b == keys.s or b == keys.down then if n == #OPTs then n = 1 else n = n + 1 end end
  24. if b == keys.enter then break end
  25. end
  26. return n
  27. end
  28.  
  29. local function Single_Prompt(text)
  30. Clean()
  31. print(text)
  32. print("y/n")
  33. local a, b
  34. repeat a,b = os.pullEvent("key") until b == keys.y or b == keys.n
  35. local A
  36. if b == keys.y then A = true elseif b == keys.n then A = false end
  37. return A
  38. end
  39.  
  40. local function LoadImage(file,x,y)
  41. if fs.exists(file) then
  42.  
  43.  
  44. else
  45. term.setCursorPos(x,y)
  46. term.write("Error: Image not found")
  47. end
  48. end
  49.  
  50. local function PageSystem(pg,action,entity,arg)
  51. --Page Format
  52. --(Title),(colors),{Entities},(ReturnButton)
  53. --Colors = {Text,Background}
  54. --Entity Format: {id,text,type,{events},w,h,x,y,files}
  55. if action == "interact" then
  56.  
  57. elseif action == "load" then
  58. local file = fs.open(pg,"r")
  59. Page = textutils.unserialize(file.readAll())
  60. file.close()
  61. for i = 1, #Page[3] do
  62. end
  63. elseif action == "edit" then
  64.  
  65. end
  66. end
  67.  
  68. function SettingsMenu()
  69. Clean()
  70. print("System")
  71. local List = Options(3,{"[Menu]","reboot normal","check updates","details"})
  72. if List == 1 then Menu() elseif List == 2 then os.queueEvent("admin","N_restart") elseif List == 3 os.queueEvent("admin","network","updates") elseif List == 4 then end
  73. end
  74.  
  75. function ScheduleMenu()
  76.  
  77. end
  78.  
  79. function ReportMenu()
  80.  
  81. end
  82.  
  83. function EvidenceMenu()
  84.  
  85. end
  86.  
  87.  
  88. function Menu()
  89. Clean()
  90. print("Student E-Handbook")
  91. print("[Skeleton mode]")
  92. print("hello <STUDENT>!")
  93. local List = Options(5,{"Schedule","Report Cards", "Evidence","System"})
  94. if List == 1 then ScheduleMenu() elseif List == 2 then ReportMenu() elseif List == 3 then EvidenceMenu() elseif List == 4 then SettingsMenu() end
  95. end
  96.  
  97. Menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement