Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- function list(directory)
- local a
- local b = {}
- a = fs.list(directory)
- for i=1, #a do
- if a[i] == "Admin1" then
- b[i] = "true"
- elseif a[i] == "User1" then
- b[i] = "true"
- elseif a[i] == "User2" then
- b[i] = "true"
- elseif fs.isDir(a[i]) then
- b[i] = "true"
- else
- b[i] = "false"
- end
- end
- return a, b
- end
- -- 3023's Set Text -- Var.
- function drawFolderIcon(x, y, text)
- paintutils.drawPixel(x, y, colors.yellow)
- paintutils.drawPixel(x, y-1, colors.yellow)
- paintutils.drawPixel(x-1, y, colors.yellow)
- paintutils.drawPixel(x-1, y-1, colors.yellow)
- term.setCursorPos(x-1, y+1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.write(text)
- local Out = {}
- Out[1] = {}
- Out[1].x = x
- Out[1].y = y
- Out[1].Name = text
- return Out
- end
- function drawProgramIcon(x, y, text)
- paintutils.drawPixel(x, y, colors.gray)
- paintutils.drawPixel(x-1, y, colors.gray)
- paintutils.drawPixel(x, y-1, colors.blue)
- paintutils.drawPixel(x-1, y-1, colors.blue)
- term.setCursorPos(x-1, y+1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.write(text)
- local Out = {}
- Out[1] = {}
- Out[1].x = x
- Out[1].y = y
- Out[1].Name = text
- return Out
- end
- function drawBackIcon(x, y)
- paintutils.drawPixel(x, y, colors.blue)
- paintutils.drawPixel(x-1, y, colors.blue)
- paintutils.drawPixel(x, y-1, colors.blue)
- paintutils.drawPixel(x-1, y-1, colors.blue)
- term.setCursorPos(x-1, y+1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.write(text)
- local Out = {}
- Out[1] = {}
- Out[1].x = x
- Out[1].y = y
- Out[1].Name = text
- return Out
- end
- function bufferBackground()
- term.clear()
- paintutils.drawLine(1, 1, 51, 1, colors.lightBlue)
- paintutils.drawFilledBox(1, 2, 100, 100, colors.white)
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(1, 1)
- end
- function drawFileList(y, directory)
- local xPos = 1
- local yPos = 1
- local a = 1
- local b = {}
- local z = 0
- local s = 1
- local list2 = {}
- local bigList = {}
- b, c = list(directory)
- for i=1, #b do
- if b[s] == "rom" then
- elseif c[s] == "false" then
- if a % 5 == 0 then
- z = z + 1
- a = 1
- end
- list2 = drawProgramIcon(y+(z*10), a*4, b[s])
- bigList[s] = {}
- bigList[s].x = list2[1].x
- bigList[s].y = list2[1].y
- bigList[s].Name = list2[1].Name
- if bigList[s].Name:len() >= 7 then
- bigList[s].Name = string.sub(bigList[s].Name, 1, 6).."..."
- end
- else
- if a % 5 == 0 then
- z = z + 1
- a = 1
- end
- list2 = drawFolderIcon(y+(z*10), a*4, b[s])
- bigList[s] = {}
- bigList[s].x = list2[1].x
- bigList[s].y = list2[1].y
- bigList[s].Name = list2[1].Name
- if bigList[s].Name:len() >= 7 then
- bigList[s].Name = string.sub(bigList[s].Name, 1, 6).."..."
- end
- end
- a=a+1
- s=s+1
- end
- return bigList, c
- end
- function clickIcon(list, x, y, button, directory, list2)
- if button == 1 then
- for i=1, #list do
- if x == list[i].x or x == list[i].x - 1 then
- if y == list[i].y or y == list[i].y - 1 then
- if list2[i] == "true" then
- Update(directory.."/"..list[i].Name)
- elseif list2[i] == "false" then
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(1, 1)
- term.clear()
- shell.run(directory.."/"..string.lower(list[i].Name))
- error()
- end
- end
- end
- end
- end
- end
- local G = ""
- function Update(Name)
- local XYList = {}
- bufferBackground()
- XYList, c = drawFileList(3, Name)
- while true do
- event, button, xPos, yPos = os.pullEvent()
- if event == "mouse_click" then
- clickIcon(XYList, xPos, yPos, button, Name, c)
- elseif event == "key" and button == keys.left then
- if Name ~= "" then
- G = Name
- Update(fs.getDir(Name))
- end
- elseif event == "key" and button == keys.right then
- Update(G)
- end
- end
- end
- Update("")
- if tArgs[1] == "Admin" then
- Update("Users/Admin1")
- end
- if tArgs[1] == "User1" then
- Update("Users/User1")
- end
- if tArgs[1] == "User2" then
- Update("Users/User2")
- end
Advertisement
Add Comment
Please, Sign In to add comment