Guest User

Code.

a guest
Jun 17th, 2015
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.19 KB | None | 0 0
  1. local tArgs = { ... }
  2.  
  3.  
  4.  
  5. function list(directory)
  6.   local a
  7.   local b = {}
  8.   a = fs.list(directory)
  9.   for i=1, #a do
  10.     if a[i] == "Admin1" then
  11.     b[i] = "true"
  12.     elseif a[i] == "User1" then
  13.     b[i] = "true"
  14.     elseif a[i] == "User2" then
  15.     b[i] = "true"
  16.     elseif fs.isDir(a[i]) then
  17.         b[i] = "true"
  18.     else
  19.      b[i] = "false"
  20.      end
  21.   end
  22.   return a, b
  23. end
  24.  -- 3023's Set Text -- Var.
  25.  
  26.  
  27. function drawFolderIcon(x, y, text)
  28.   paintutils.drawPixel(x, y, colors.yellow)
  29.   paintutils.drawPixel(x, y-1, colors.yellow)
  30.   paintutils.drawPixel(x-1, y, colors.yellow)
  31.   paintutils.drawPixel(x-1, y-1, colors.yellow)
  32.   term.setCursorPos(x-1, y+1)
  33.   term.setBackgroundColor(colors.white)
  34.   term.setTextColor(colors.black)
  35.   term.write(text)
  36.   local Out = {}
  37.   Out[1] = {}
  38.   Out[1].x = x
  39.   Out[1].y = y
  40.   Out[1].Name = text
  41.   return Out
  42. end
  43.  
  44.  
  45.  
  46. function drawProgramIcon(x, y, text)
  47.   paintutils.drawPixel(x, y, colors.gray)
  48.   paintutils.drawPixel(x-1, y, colors.gray)
  49.   paintutils.drawPixel(x, y-1, colors.blue)
  50.   paintutils.drawPixel(x-1, y-1, colors.blue)
  51.   term.setCursorPos(x-1, y+1)
  52.   term.setBackgroundColor(colors.white)
  53.   term.setTextColor(colors.black)
  54.   term.write(text)
  55.     local Out = {}
  56.     Out[1] = {}
  57.     Out[1].x = x
  58.     Out[1].y = y
  59.     Out[1].Name = text
  60.     return Out
  61. end
  62.  
  63. function drawBackIcon(x, y)
  64.   paintutils.drawPixel(x, y, colors.blue)
  65.   paintutils.drawPixel(x-1, y, colors.blue)
  66.   paintutils.drawPixel(x, y-1, colors.blue)
  67.   paintutils.drawPixel(x-1, y-1, colors.blue)
  68.   term.setCursorPos(x-1, y+1)
  69.   term.setBackgroundColor(colors.white)
  70.   term.setTextColor(colors.black)
  71.   term.write(text)
  72.     local Out = {}
  73.     Out[1] = {}
  74.     Out[1].x = x
  75.     Out[1].y = y
  76.     Out[1].Name = text
  77.     return Out
  78. end
  79.  
  80. function bufferBackground()
  81. term.clear()
  82. paintutils.drawLine(1, 1, 51, 1, colors.lightBlue)
  83. paintutils.drawFilledBox(1, 2, 100, 100, colors.white)
  84. term.setBackgroundColor(colors.lightBlue)
  85. term.setTextColor(colors.black)
  86. term.setCursorPos(1, 1)
  87. end
  88.  
  89.  
  90.  
  91. function drawFileList(y, directory)
  92.     local xPos = 1
  93.     local yPos = 1
  94.     local a = 1
  95.     local b = {}
  96.     local z = 0
  97.     local s = 1
  98.     local list2 = {}
  99.     local bigList = {}
  100.     b, c = list(directory)
  101.     for i=1, #b do
  102.         if b[s] == "rom" then
  103.  
  104.         elseif c[s] == "false" then
  105.    if a % 5 == 0 then
  106.      z = z + 1
  107.      a = 1
  108.    end
  109.             list2 = drawProgramIcon(y+(z*10), a*4, b[s])
  110.             bigList[s] = {}
  111.             bigList[s].x = list2[1].x
  112.             bigList[s].y = list2[1].y
  113.             bigList[s].Name = list2[1].Name
  114.             if bigList[s].Name:len() >=  7 then
  115.             bigList[s].Name = string.sub(bigList[s].Name, 1, 6).."..."
  116.             end
  117.         else   
  118.    if a % 5 == 0 then
  119.      z = z + 1
  120.      a = 1
  121.    end
  122.             list2 = drawFolderIcon(y+(z*10), a*4, b[s])
  123.             bigList[s] = {}
  124.             bigList[s].x = list2[1].x
  125.             bigList[s].y = list2[1].y
  126.             bigList[s].Name = list2[1].Name
  127.             if bigList[s].Name:len() >=  7 then
  128.             bigList[s].Name = string.sub(bigList[s].Name, 1, 6).."..."
  129.             end
  130.         end
  131.     a=a+1
  132.     s=s+1      
  133.     end
  134.     return bigList, c
  135. end
  136.  
  137.  
  138.  
  139. function clickIcon(list, x, y, button, directory, list2)
  140.     if button == 1 then
  141.         for i=1, #list do
  142.             if x == list[i].x or x == list[i].x - 1 then
  143.                 if y == list[i].y or y == list[i].y - 1 then
  144.                     if  list2[i] == "true" then
  145.                         Update(directory.."/"..list[i].Name)
  146.                     elseif list2[i] == "false" then
  147.                         term.setBackgroundColor(colors.black)
  148.                         term.setTextColor(colors.white)
  149.                         term.setCursorPos(1, 1)
  150.                         term.clear()
  151.                         shell.run(directory.."/"..string.lower(list[i].Name))
  152.                         error()
  153.                     end
  154.                 end
  155.             end
  156.         end
  157.     end
  158. end
  159.  
  160.  
  161. local G = ""
  162. function Update(Name)
  163. local XYList = {}
  164. bufferBackground()
  165. XYList, c = drawFileList(3, Name)
  166. while true do
  167.     event, button, xPos, yPos = os.pullEvent()
  168.         if event == "mouse_click" then
  169.             clickIcon(XYList, xPos, yPos, button, Name, c)
  170.         elseif event == "key" and button == keys.left then
  171.         if Name ~= "" then
  172.             G = Name
  173.             Update(fs.getDir(Name))
  174.         end
  175.         elseif event == "key" and button == keys.right then
  176.             Update(G)
  177.         end
  178.     end
  179. end
  180. Update("")
  181. if tArgs[1] == "Admin" then
  182. Update("Users/Admin1")
  183. end
  184. if tArgs[1] == "User1" then
  185. Update("Users/User1")
  186. end
  187. if tArgs[1] == "User2" then
  188. Update("Users/User2")
  189. end
Advertisement
Add Comment
Please, Sign In to add comment