Advertisement
PolskiWisnia

Untitled

Oct 17th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.74 KB | None | 0 0
  1. -- Oprogramowanie skopiowane dzieki licencji OpenSource, zadne zmiany nie zostaly dokonane --
  2. -- EKSPLORATOR PLIKOW NIE ZOSTAL STWORZONY PRZEZ AUTORA SYSTEMOW MINEDOWS, MINECORE ORAZ MINEOS --
  3. local dir = ""
  4. local fileList = {}
  5. local fList = {}
  6. local dList = {}
  7. local offset = 0
  8.  
  9. function drawSquare(x,y,x2,y2,color)
  10.   for xPos=x,x2 do
  11.     for yPos=y,y2 do
  12.       term.setBackgroundColor(color)
  13.       term.setCursorPos(xPos,yPos)
  14.       term.write(" ")
  15.     end
  16.   end
  17.   term.setBackgroundColor(colors.black)
  18. end
  19.  
  20. function drawText(x,y,text,tColor,bColor)
  21.   term.setBackgroundColor(bColor)
  22.   term.setTextColor(tColor)
  23.   term.setCursorPos(x,y)
  24.   term.write(text)
  25. end
  26.  
  27. function makeLists(path)
  28.   fileList = fs.list(path)
  29.   dList = {}
  30.   fList = {}
  31.   if string.len(dir) > 1 then
  32.     table.insert(dList, "..")
  33.   end
  34.   for i=1,#fileList do
  35.     if fs.isDir(path.."/"..fileList[i]) then
  36.       table.insert(dList, fileList[i])
  37.     else
  38.       table.insert(fList, fileList[i])
  39.     end
  40.   end
  41. end
  42.  
  43. while true do
  44.   term.clear()
  45.   drawSquare(1,1,10,19,colors.gray)
  46.   drawSquare(10,1,51,19,colors.white)
  47.   drawSquare(1,1,51,1,colors.lightGray)
  48.   if string.len(dir) > 0 then
  49.     drawText(1,1,dir,colors.black,colors.lightGray)
  50.   else
  51.     drawText(1,1,"/",colors.black,colors.lightGray)
  52.   end
  53.   term.setCursorPos(1,1)
  54.   makeLists(dir)
  55.   for i=1,#dList do
  56.     if dList[i+offset] then
  57.       drawText(1,i+1,dList[i+offset],colors.white,colors.gray)
  58.     end
  59.   end
  60.   local pos = 1
  61.   local offSet = 0
  62.   for i=1,#fList do
  63.     if fList[i+(18*offset)] then
  64.       drawText(10+(offSet*15),i-(18*offSet)+1,fList[i+(18*offset)],colors.black,colors.white)
  65.     end
  66.     pos = pos + 1
  67.     if pos > 18 then
  68.       pos = 1
  69.       offSet = offSet + 1
  70.     end
  71.   end
  72.   local e,b,x,y = os.pullEvent()
  73.   if e == "mouse_click" then
  74.     if x<10 and y>1 then
  75.       if offset < 1 then
  76.         if dList[y-1] then
  77.           if dList[y-1] == ".." then
  78.             dir = fs.getDir(dir)
  79.           else
  80.             dir = dir.."/"..dList[y-1]
  81.           end
  82.           offset = 0
  83.         end
  84.       else
  85.         if dList[(y-1)+offset] then
  86.           if dList[(y-1)+offset] == ".." then
  87.             dir = fs.getDir(dir)
  88.           else
  89.             dir = dir.."/"..dList[(y-1)+offset]
  90.           end
  91.           offset = 0
  92.         end
  93.       end
  94.     elseif x>9 and x<25 and y>1 then
  95.       if offset < 1 then
  96.         if fList[y-1] then
  97.           term.setTextColor(colors.white)
  98.           term.setBackgroundColor(colors.black)
  99.           term.clear()
  100.           term.setCursorPos(1,1)
  101.           shell.run(dir.."/"..fList[y-1])
  102.         end
  103.       else
  104.         if fList[y+(offset*17)] then
  105.           term.setTextColor(colors.white)
  106.           term.setBackgroundColor(colors.black)
  107.           term.clear()
  108.           term.setCursorPos(1,1)
  109.           shell.run(dir.."/"..fList[y+(offset*17)])
  110.         end
  111.       end
  112.     elseif x>25 and x<40 and y>1 then
  113.       if offset < 1 then
  114.         if fList[y+17] then
  115.           term.setTextColor(colors.white)
  116.           term.setBackgroundColor(colors.black)
  117.           term.clear()
  118.           term.setCursorPos(1,1)
  119.           shell.run(dir.."/"..fList[y+17])
  120.         end
  121.       else
  122.         if fList[y+(offset*34)] then
  123.           term.setTextColor(colors.white)
  124.           term.setBackgroundColor(colors.black)
  125.           term.clear()
  126.           term.setCursorPos(1,1)
  127.           shell.run(dir.."/"..fList[y+(offset*34)])
  128.         end
  129.       end
  130.     elseif y == 1 then
  131.       drawSquare(1,1,51,1,colors.lightGray)
  132.       term.setCursorPos(1,1)
  133.       term.setTextColor(colors.black)
  134.       term.setBackgroundColor(colors.lightGray)
  135.       local input = read()
  136.       if fs.exists(input) then
  137.         if fs.isDir(input) then
  138.           dir = input
  139.         else
  140.           shell.run(input)
  141.         end
  142.       else
  143.         drawSquare(1,1,51,1,colors.lightGray)
  144.         drawText(1,1,"Invalid directory or file (Does not exist)", colors.black, colors.lightGray)
  145.         sleep(0.3)
  146.         os.pullEvent()
  147.       end
  148.     else
  149.       if offset < 1 then
  150.         if fList[y+34] then
  151.           term.setTextColor(colors.white)
  152.           term.setBackgroundColor(colors.black)
  153.           term.clear()
  154.           term.setCursorPos(1,1)
  155.           shell.run(dir.."/"..fList[y+34])
  156.         end
  157.       else
  158.         if fList[y+(offset*51)] then
  159.           term.setTextColor(colors.white)
  160.           term.setBackgroundColor(colors.black)
  161.           term.clear()
  162.           term.setCursorPos(1,1)
  163.           shell.run(dir.."/"..fList[y+(offset*51)])
  164.         end
  165.       end
  166.     end
  167.   elseif e == "mouse_scroll" then
  168.     if b == -1 then
  169.       if offset > 0 then
  170.         offset = offset - 1
  171.       end
  172.     elseif b == 1 then
  173.         offset = offset + 1
  174.     end
  175.   end
  176. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement