PolskiWisnia

Untitled

Jul 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.38 KB | None | 0 0
  1. -- Skroty do komend --
  2. local function s(...) return sleep(...) end
  3. local function w(...) return write(...) end
  4. local function p(...) return print(...) end
  5. local function tw(...) return term.write(...) end
  6. local function scp(...) return term.setCursorPos(...) end
  7. local function sbc(...) return term.setBackgroundColor(...) end
  8. local function stc(...) return term.setTextColor(...) end
  9. local function tc(...) return term.clear(...) end
  10. local function tcl(...) return term.clearLine(...) end
  11. local function r(...) return shell.run(...) end
  12. local function sp(...) return textutils.slowPrint(...) end
  13. local function sw(...) return textutils.slowWrite(...) end
  14. local function fse(...) return fs.exists(...) end
  15. local function pul(...) return paintutils.loadImage(...) end
  16. local function pud(...) return paintutils.drawImage(...) end
  17. local function pfb(...) return paintutils.drawFilledBox(...) end
  18. local function su(...) return os.shutdown(...) end
  19. local function re(...) return os.reboot(...) end
  20. local function pdp(...) return paintutils.drawPixel(...) end
  21. function logobraz()
  22. pfb(1, 1, 51, 5, colors.blue)
  23. pfb(1, 6, 51, 14, colors.lightBlue)
  24. pfb(1, 15, 51, 19, colors.blue)
  25. pfb(15, 7, 17, 9, colors.gray)
  26. scp(1,1)
  27. p("Logowanie MineCore")
  28. scp(1,2)
  29. p("Wybierz uzytkownika, a nastepnie wpisz haslo.")
  30. end
  31. -- Funkcja do otrzymywania rozmiaru folderu/pliku --
  32. function getSize(path)
  33.   local size = 0
  34.   for _, file in ipairs(fs.list(path)) do
  35.     if fs.isDir(fs.combine(path, file)) then
  36.       size = size + getSize(fs.combine(path, file))
  37.     else
  38.       size = size + fs.getSize(fs.combine(path, file))
  39.     end
  40.   end
  41.   return size
  42. end
  43. local data = os.day()
  44. -- Odczytywanie wersji systemu --
  45. function wersja()
  46.  local ver = fs.open("/os/ver/.ver", "r")
  47.  wer = ver.readLine(1)
  48. end
  49. -- Funkcja wyswietlania pulpitu --
  50. function obraz()
  51.  tc()
  52.  pfb(1, 1, 51, 1, colors.brown)
  53.  pfb(2, 2, 50, 17, colors.black)
  54.  pfb(1, 1, 1, 18, colors.brown)
  55.  pfb(1, 18, 51, 18, colors.brown)
  56.  pfb(51, 1, 51, 18, colors.brown)
  57.  pfb(1, 19, 5, 19, colors.green)
  58.  pfb(6, 19, 49, 19, colors.blue)
  59.  pdp(50, 19, colors.red)
  60.  pdp(51, 19, colors.orange)
  61.  sbc(colors.green)
  62.  stc(colors.white)
  63.  scp(1,19)
  64.  w("Start")
  65.  sbc(colors.brown)
  66.  stc(colors.white)
  67.  scp(1,1)
  68.  p("Informacje")
  69.  time = os.time()
  70.  time = textutils.formatTime(time, true)
  71.  sbc(colors.blue)
  72.  stc(colors.white)
  73.  scp(45,19)
  74.  write(time)
  75.  scp(30,19)
  76.  w("Dzien: ", data)
  77. end
  78. -- Odczytywanie danych do logowania --
  79. function pliki()
  80.  local u = fs.open("/os/.log1", "r")
  81.  user = u.readLine(1)
  82.  u.close()
  83.  local h = fs.open("/os/.log2", "r")
  84.  pass = h.readLine(1)
  85.  h.close()
  86. end
  87. -- Logowanie --
  88. function log()
  89.  sbc(colors.lightBlue)
  90.  stc(colors.white)
  91.  scp(18,7)
  92.  p(user)
  93.  scp(18,8)
  94.  w("")
  95.  haslo = read()
  96.  if haslo == pass then ok = 1 else scp(18,9) stc(colors.red) p("Bledne haslo") s(2) re() end
  97. end
  98. -- Menu Start
  99. function start()
  100.  pfb(1, 15, 10, 18, colors.white)
  101.  pfb(1, 14, 10, 14, colors.blue)
  102.  scp(1,14)
  103.  stc(colors.white)
  104.  p("Start")
  105.  stc(colors.black)
  106.  sbc(colors.white)
  107.  scp(1,15)
  108.  p("Ustawienia")
  109.  scp(1,16)
  110.  p("Programy")
  111.  scp(1,17)
  112.  p("CraftOS")
  113.  scp(1,18)
  114.  p("/run")
  115.  point2()
  116. end
  117. function pc()
  118.  pfb(2, 2, 50, 26, colors.white)
  119.  pfb(4, 4, 8, 8, colors.blue)
  120.  if fs.exists("/disk/") and fs.exists("/disk/minecore/") then pfb(12, 4, 16, 8, colors.brown) stc(colors.black) sbc(colors.white)
  121.  scp(12,9) p("MineCore Disk") minecore = 1
  122.  elseif fs.exists("/disk/") then pfb(12, 4, 16, 8, colors.brown) stc(colors.black) sbc(colors.white) scp(12,9) p("Dyskietka")
  123.  end
  124.  stc(colors.black)
  125.  sbc(colors.white)
  126.  scp(2,2)
  127.  p("Ten komputer")
  128.  scp(4,9)
  129.  p("CC PC")
  130.  local event, click, x, y = os.pullEvent("mouse_click")
  131. -- Zakladka informacje --
  132. function info()
  133.  pfb(1, 2, 20, 6, colors.gray)
  134.  stc(colors.white)
  135.  sbc(colors.lightGray)
  136.  scp(1,2)
  137.  p("MineCore May Update")
  138.  p("Wolne miejsce:")
  139.  p(fs.getFreeSpace("/")/1024, "KB")
  140.  p("Kompilacja: 1102D")
  141.  p("17.07.2019")
  142.  local event, click, x, y = os.pullEvent("mouse_click")
  143. end
  144. -- Wykrywanie wcisniecia --
  145. function point()
  146.  local event, click, x, y = os.pullEvent("mouse_click")
  147.  if x>0 and x<6 and y == 19 then start() end
  148.  if x == 50 and y == 19 then su() end
  149.  if x == 51 and y == 19 then re() end
  150.  if x>0 and x<11 and y == 1 then info() end
  151.  if x == 51 and y == 1 then pc()
  152. end
  153. -- to co wyzej, ale jeszcze raz --
  154. function point2()
  155.  local event, click, x, y = os.pullEvent("mouse_click")
  156.  if x>0 and x<9 and y == 16 then programy() end
  157.  if x>0 and x<9 and y == 17 then error("Opuszczono MineUI 4.1") end
  158.  if x>0 and x<11 and y == 15 then set() end
  159.  if x>0 and x<9 and y == 18 then scp(2,2)
  160.  stc(colors.white)
  161.  sbc(colors.black)
  162.  w("Wpisz nazwe pliku: ")
  163.  plik = read()
  164.  if fs.exists(plik) then r(plik) else error("Brak oczekiwanego pliku.") end
  165. end
  166. end
  167. -- Menu Programy --
  168. function programy()
  169.  pfb(11, 14, 19, 16, colors.white)
  170.  scp(12,14)
  171.  p(">2048")
  172.  scp(12,15)
  173.  p("LuaIDE")
  174.  scp(12,16)
  175.  p("Snake")
  176.  local event, click, x, y = os.pullEvent("mouse_click")
  177.  if x>10 and x<20 and y == 14 then r("/os/.2048") end
  178.  if x>10 and x<20 and y == 15 then scp(2,2) sbc(colors.black) stc(colors.white) w("Wpisz nazwe pliku: ") plik = read() r("edit", plik) end
  179.  if x>10 and x<20 and y == 16 then r("worm") end
  180. end
  181. -- Komenda run --
  182.  
  183. -- Ustawienia --
  184. function set()
  185.  tc()
  186.  pfb(1, 1, 51, 1, colors.blue)
  187.  pfb(1, 2, 51, 19, colors.white)
  188.  scp(1,1)
  189.  sbc(colors.blue)
  190.  stc(colors.white)
  191.  p("Ustawienia")
  192.  sbc(colors.white)
  193.  stc(colors.black)
  194.  scp(1,2)
  195.  p("MineCore Hybrid OS")
  196.  p("Wolne miejsce na dysku:")
  197.  wolne = math.ceil(fs.getFreeSpace("/")/1024)
  198.  p(wolne, "KB")
  199.  zajete = getSize("/os/")
  200.  lacznie = fs.getFreeSpace("/") + zajete
  201.  print(math.ceil(zajete/1024), "KB uzyte z ", lacznie, "KB")
  202.  p("Nazwa komputera: ")
  203.  p(os.getComputerLabel())
  204.  p("Zmien nazwe komputera")
  205.  local ver = fs.open("/os/ver/.ver", "r")
  206.  wer = ver.readLine(1)
  207.  p("Wersja: ", wer)
  208.  p("Nazwa uzytkownika:", user)
  209.  p("Aktualizuj system")
  210.  p("Zainstaluj wersje testowa")
  211.  local event, click, x, y = os.pullEvent("mouse_click")
  212.  if x>0 and x<20 and y == 8 then scp(1,8) sbc(colors.white) stc(colors.black) w("Wpisz nowa nazwe: ") nazwa = read() os.setComputerLabel(nazwa) end
  213.  if x>0 and x<20 and y == 11 then r("/os/.update") end
  214.  if x>0 and x<20 and y == 12 then r("/os/.tupdate") end
  215. end
  216. -- Kolejnosc funkcji --
  217. logobraz()
  218. pliki()
  219. log()
  220. while true do
  221. obraz()
  222. point()
  223. end
Add Comment
Please, Sign In to add comment