Miki_Tellurium

notepad-setup

Jan 2nd, 2023
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.91 KB | Gaming | 0 0
  1. -- Setup program for notepad v1.0.0
  2. -- You don't need to run this file more than once unless
  3. -- you want to reset notepad
  4. term.setBackgroundColor(colors.black)
  5. term.setTextColor(colors.white)
  6. term.clear()
  7. -- Download all the required files from pastebin
  8. local function install()
  9.     term.clear()
  10.     term.setCursorPos(1, 1)
  11.     print("Welcome to notepad setup! Press ENTER to install notepad or Q to quit.")
  12.     while true do
  13.         local event, key = os.pullEvent("key")
  14.         if event == "key" and keys.getName(key) == "enter" then
  15.             if fs.find("notepad.settings") then
  16.                 fs.delete("notepad.settings")
  17.             end
  18.             print("Downloading required APIs...")
  19.             sleep(0.3)
  20.             shell.run("pastebin get V33yuuVi button.lua")
  21.             sleep(0.25)
  22.             shell.run("pastebin get VwX6sfh9 text.lua")
  23.             sleep(0.25)
  24.             shell.run("pastebin get tcCFbCKC notepadsettings.lua")
  25.             sleep(0.25)
  26.             print("Done!")
  27.             sleep(0.5)
  28.             print("Downloading program files...")
  29.             sleep(0.3)
  30.             shell.run("pastebin get ApnY4GZt notepad.lua")
  31.             sleep(0.25)
  32.             shell.run("pastebin get TmjSVSRZ memos.lua")
  33.             sleep(0.25)
  34.             shell.run("pastebin get 1yQRqBVa settingsapp.lua")
  35.             sleep(0.25)
  36.             shell.run("pastebin get VsEazWKR startup.lua")
  37.             sleep(0.25)
  38.             print("Done!")
  39.             sleep(0.5)
  40.             print()
  41.             term.setTextColor(colors.lightBlue)
  42.             print("Installation completed succesfully! Press any key to reboot the computer.")
  43.             while true do
  44.                 local event = os.pullEvent("key")
  45.                 if event == "key" then
  46.                     os.reboot()
  47.                 end
  48.             end
  49.         elseif event == "key" and keys.getName(key) == "q" then
  50.             os.reboot()
  51.         end
  52.     end
  53. end
  54. -- Delete files if they already exist
  55. local function deleteFiles()
  56.     if fs.exists("notepad.lua") then
  57.         fs.delete("notepad.lua")
  58.     end
  59.     if fs.exists("startup.lua") then
  60.         fs.delete("startup.lua")
  61.     end
  62.     if fs.exists("memos.lua") then
  63.         fs.delete("memos.lua")
  64.     end
  65.     if fs.exists("notepadsettings.lua") then
  66.         fs.delete("notepadsettings.lua")
  67.     end
  68.     if fs.exists("settingsapp.lua") then
  69.         fs.delete("settingsapp.lua")
  70.     end
  71.     if fs.exists("button.lua") then
  72.         fs.delete("button.lua")
  73.     end
  74.     if fs.exists("text.lua") then
  75.         fs.delete("text.lua")
  76.     end
  77.     if fs.exists("notepad.settings") then
  78.         fs.delete("notepad.settings")
  79.     end
  80. end
  81. -- Reinstall the program if it's already installed
  82. local function reInstall()
  83.     term.clear()
  84.     term.setCursorPos(1, 1)
  85.     print("Installation detected! Do you want to reinstall notepad?")
  86.     term.setTextColor(colors.orange)
  87.     print("WARNING! All settings will be resetted!")
  88.     term.setTextColor(colors.white)
  89.     print("Press ENTER to continue or Q to quit.")
  90.     while true do
  91.         local event, key = os.pullEvent("key")
  92.         if event == "key" and keys.getName(key) == "enter" then
  93.             deleteFiles()
  94.             install()
  95.         elseif event == "key" and keys.getName(key) == "q" then
  96.             os.reboot()
  97.         end
  98.     end
  99. end
  100. -- Check if the program is already installed
  101. local function isAlreadyInstalled()
  102.     if fs.exists("notepad.lua") or
  103.             fs.exists("settingsapp.lua") or
  104.             fs.exists("notepadsettings.lua") then
  105.         return true
  106.     end
  107.     return false
  108. end
  109. -- Check if this is a pocket computer
  110. if not pocket then
  111.     term.setCursorPos(1, 1)
  112.     term.setTextColor(colors.orange)
  113.     print("Notepad is not compatible with this computer! It can only be installed in pocket computers!")
  114.     return
  115. end
  116.  
  117. if isAlreadyInstalled() then
  118.     reInstall()
  119. else
  120.     install()
  121. end
  122.  
  123.  
Advertisement
Add Comment
Please, Sign In to add comment