Z1maV1

install

Oct 16th, 2022 (edited)
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2.  
  3. local w,h = term.getSize()
  4.  
  5. local hasDisk
  6. local id
  7.  
  8. term.clear()
  9.  
  10. function printCentered( y,s )
  11.     local x = math.floor((w - string.len(s)) / 2)
  12.     term.setCursorPos(x,y)
  13.     term.clearLine()
  14.     term.write( s )
  15. end
  16.  
  17. printCentered( math.floor(h/2) - 2, "Insert Disk")
  18. printCentered( math.floor(h/2) - 0, "Press ENTER to exit")
  19.  
  20. local function DiskCheck(  )
  21.     while true do
  22.         if disk.hasData("left") or disk.hasData("right") or disk.hasData("top") or disk.hasData("back") or disk.hasData("bottom") or disk.hasData("front") then
  23.             hasDisk = true
  24.             break
  25.         end
  26.  
  27.         sleep(0)
  28.     end
  29. end
  30.  
  31. local function MayExit(  )
  32.     while true do
  33.         local event, key = os.pullEvent("key")
  34.         if event == "key" and hasDisk ~= true then
  35.             if keys.getName(key) == "enter" then
  36.                 break
  37.             end
  38.         end
  39.         sleep(0)
  40.     end
  41.     shell.run("/bin/main")
  42. end
  43.  
  44. local function Install(  )
  45.     if fs.exists("/disk/install.lua") then
  46.         id = multishell.launch({}, "/disk/install.lua")
  47.         multishell.setTitle(id, "Installation")
  48.         while true do
  49.             if multishell.getCount() <= 1 then
  50.                 shell.run("main")
  51.             end
  52.             sleep(0)
  53.         end
  54.     else
  55.         shell.run("BSOD", "\"[DO:0001] No or corrupted file\"")
  56.     end
  57. end
  58.  
  59. parallel.waitForAny(DiskCheck, MayExit)
  60. Install()
  61.  
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment