KittenPixel

Untitled

Dec 30th, 2023
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1.  
  2. os.pullEvent = os.pullEventRaw
  3.  
  4. local w,h = term.getSize()
  5.  
  6. function printCentered( y,s )
  7. local x = math.floor((w - string.len(s)) / 2)
  8. term.setCursorPos(x,y)
  9. term.clearLine()
  10. term.write( s )
  11. end
  12.  
  13. local nOption = 1
  14.  
  15. local function drawMenu()
  16. term.clear()
  17. term.setCursorPos(1,1)
  18. term.write("Wrench OS Install Menu // ")
  19. term.setCursorPos(1,2)
  20.  
  21. term.setCursorPos(w-11,1)
  22. if nOption == 1 then
  23. term.write("Install")
  24. elseif nOption == 2 then
  25. term.write("Cancel")
  26. end
  27.  
  28. end
  29.  
  30. --GUI
  31. term.clear()
  32. local function drawFrontend()
  33. printCentered( math.floor(h/2) - 3, "")
  34. printCentered( math.floor(h/2) - 2, "Install Menu" )
  35. printCentered( math.floor(h/2) - 1, "")
  36. printCentered( math.floor(h/2) + 0, ((nOption == 1) and "[ Install ]") or "Install" )
  37. printCentered( math.floor(h/2) + 1, ((nOption == 2) and "[ Cancel ]") or "Cancel" )
  38. printCentered( math.floor(h/2) + 4, "")
  39. end
  40.  
  41. --Display
  42. drawMenu()
  43. drawFrontend()
  44.  
  45. while true do
  46. local e,p = os.pullEvent()
  47. if e == "key" then
  48. local key = p
  49. if key == 17 or key == 200 then
  50.  
  51. if nOption > 1 then
  52. nOption = nOption - 1
  53. drawMenu()
  54. drawFrontend()
  55. end
  56. elseif key == 31 or key == 208 then
  57. if nOption < 4 then
  58. nOption = nOption + 1
  59. drawMenu()
  60. drawFrontend()
  61. end
  62. elseif key == 28 then
  63. --End should not be here!!
  64. break
  65. end --End should be here!!
  66. end
  67. end
  68. term.clear()
  69.  
  70. local function getInstallationInformation(tag)
  71. rootPath = "https://raw.githubusercontent.com/znepb-cc/zwm/" .. tag or "zwm"
  72. print("Fetching installation information...")
  73. local inst, err = getFile("/inst/installation.lua")
  74. if not inst then
  75. printError(("Could not fetch installation information for branch %s."):format(tag))
  76. return
  77. else
  78. instData = textutils.unserialize(inst)
  79. end
  80. if not instData then
  81. error("Error parsing installing information")
  82. end
  83. return instData
  84. end
  85.  
  86. --Conditions
  87. if nOption == 1 then
  88. print(("Setup will create %d directories and will install %d files."):format(getInstallationInformation("Master").directories, #getInstallationInformation("Master").files))
  89. write("Confirm? Y/n ")
  90. local ready = read()
  91. if string.lower(ready) == "n" then
  92. print("Installation canceled.")
  93. else
  94. print("Creating directories...")
  95. for i, v in pairs(inst.directories) do
  96. print(("Creating: %s"):format(v))
  97. fs.makeDir(v)
  98. end
  99. term.clear()
  100. --[[hell.run("wget https://raw.githubusercontent.com/KittenPixel-cell/Wrench-OS-Computercraft/main/Startup.lua startup.lua")
  101. shell.run("wget https://raw.githubusercontent.com/KittenPixel-cell/Wrench-OS-Computercraft/main/Boot.lua boot.lua")
  102. shell.run("wget https://raw.githubusercontent.com/KittenPixel-cell/Wrench-OS-Computercraft/main/Wrench/API/GuiScreens.lua Wrench/API/GuiScreens")
  103. shell.run("wget https://raw.githubusercontent.com/KittenPixel-cell/Wrench-OS-Computercraft/main/Wrench/File.lua Wrench/File.lua")
  104. shell.run("wget https://raw.githubusercontent.com/KittenPixel-cell/Wrench-OS-Computercraft/main/Wrench/API/BSOD.lua Wrench/API/BSOD")
  105. shell.run("wget https://raw.githubusercontent.com/KittenPixel-cell/Wrench-OS-Computercraft/main/Wrench/IMGS/Wrench.nfp Wrench/IMGS/Wrench.nfp")
  106. shell.run("wget https://raw.githubusercontent.com/KittenPixel-cell/Wrench-OS-Computercraft/main/Wrench/Desktop.lua Wrench/Desktop.lua")--]]
  107. end
  108.  
  109. else
  110. term.clear()
  111. print("Install Canceled Rebooting...")
  112. os.reboot()
  113. end
  114.  
Advertisement
Add Comment
Please, Sign In to add comment