daandecomputer

Daanos Computercraft Installer (User Friendly)

May 22nd, 2018
2,867
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. term.clear()
  2. print("DaanOs Installation")
  3. print("Format Disk?")
  4. local menuOptions = {"Yes", "No"}
  5. local termX, termY = term.getSize()
  6. local selected = 1
  7. function centerText(text, termY)
  8. term.setCursorPos(termX/2-#text/2,termY)
  9. term.write("Format Disk?")
  10. term.write(text)
  11. return true
  12. end
  13. function start()
  14. while true do
  15. term.clear()
  16. for i,v in ipairs(menuOptions) do
  17. if i == selected then
  18. centerText(":"..v..":", i)
  19. else
  20. centerText(v,i)
  21. end
  22. end
  23. local id, key = os.pullEvent()
  24. if key == 208 and selected < #menuOptions then
  25. selected = selected + 1
  26. elseif key == 200 and selected > 1 then
  27. selected = selected - 1
  28. end
  29. local id, key = os.pullEvent()
  30. if key == 28 then
  31. return selected
  32. end
  33. end
  34. end
  35. x = start()
  36. print()
  37. if selected == 1 then
  38. textutils.slowPrint("Setting up installer....",20)
  39. term.setBackgroundColor(colors.yellow)
  40. term.clear()
  41. term.setCursorPos(1,1)
  42. textutils.slowPrint("Daanos Installer Set up!",20)
  43. term.clear()
  44. print("Formatting Disk...")
  45. for _,file in ipairs(fs.list("/")) do
  46. shell.run("pastebin get iRCLtA1B install2")
  47. if not fs.isReadOnly(file) then
  48. shell.run("pastebin get iRCLtA1B install2")
  49. fs.delete(file)
  50. end
  51. end
  52. shell.run("pastebin get iRCLtA1B install2")
  53. shell.run("install2")
  54. end
  55. if selected == 2 then
  56. os.reboot()
  57. end
Add Comment
Please, Sign In to add comment