T1061

[OC]PrettyDisks

Apr 14th, 2017
130
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. computer = require("computer")
  2. fs = require("filesystem")
  3. print("Подготовка к установке prettydisks...")
  4. pddata = [[event = require("event")
  5. fs = require("filesystem")
  6. computer = require("computer")
  7. local bootaddress = computer.getBootAddress()
  8. local tmpaddress = computer.tmpAddress()
  9. diskIndexes = "QWERTYUIOPSDFGHJKLXCVBNM"
  10. di = {}
  11. disks = {}
  12. for k=1,#diskIndexes do
  13.   di[k] = string.sub(diskIndexes,k,k)..":"
  14. end
  15. table.sort(di)
  16. function onFilesystemAdd(_,address,type)
  17.   if type =="filesystem" then
  18.     for v,k in ipairs(di) do
  19.       for k,address2 in pairs(disks) do
  20.         if address2 == address then
  21.           return
  22.         end
  23.       end
  24.       if not disks[k] and disks[k] ~= address then
  25.         if bootaddress ==address then k = "A:" elseif tmpaddress == address then k = "Z:" end
  26.         fs.mount(address,k)
  27.         disks[k] = address
  28.       end
  29.     end
  30.   end
  31. end
  32. function onFilesystemRemove(_,address,type)
  33.   if type == "filesystem" then
  34.     for n,s in pairs(disks) do
  35.       if s==address then
  36.       fs.umount(n)
  37.       disks[n] = nil
  38.       end
  39.     end
  40.   end
  41. end
  42. function computer.getDL()
  43.   return disks
  44. end
  45. event.listen("component_added",onFilesystemAdd)
  46. event.listen("component_removed",onFilesystemRemove)]]
  47. getDLdata = [[computer = require("computer")
  48. print("Пишутся метки и адреса дисков... Заметьте, что загрузочный диск всегда будет \"A:\", а временная всегда \"Z:\"")
  49. for n,s in pairs(computer.getDL()) do
  50.   print(n,s)
  51. end
  52. print("Готово.")]]
  53. print("Подготовка окончена. Устанавливается...")
  54. do
  55.   local file = fs.open("boot/prettydisks.lua", "w")
  56.   file:write(pddata)
  57.   file:close()
  58. end
  59. do
  60.   local file = fs.open("bin/getDL.lua","w")
  61.   file:write(getDLdata)
  62.   file:close()
  63. end
  64. print("Установка окончена! Перезагружаем комп!")
  65. os.sleep(5)
  66. computer.shutdown(true)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×