Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Minif OS run Tool
- --Functions and Variables
- local start = 0
- local function drawWindow()
- paintutils.drawFilledBox(3,3,osScreenSizeX-2,osScreenSizeY-2,colors.white)
- paintutils.drawBox(3,3,osScreenSizeX-2,5,colors.lightGray)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(4,4)
- term.write("Open File")
- end
- local function drawFile()
- paintutils.drawFilledBox(3,6,osScreenSizeX-2,osScreenSizeY-2,colors.white)
- term.setCursorPos(osScreenSizeX-8,osScreenSizeY-3)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.red)
- term.write("Close")
- term.setBackgroundColor(colors.white)
- end
- local function runThing(file)
- if fs.isDir(file) then
- drawWindow()
- osListFiles(file.."/")
- else
- shell.run('"'..file..'"')
- return
- end
- end
- function osListFiles(location)
- local run = true
- local start = 0
- local list = fs.list(location)
- drawFile()
- while run == true do
- for i, file in ipairs(list) do
- if i>osScreenSizeY-4-7+start then
- term.setCursorPos(4,osScreenSizeY-3)
- term.write("Next>")
- osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
- if osPX>=3 and osPX<=(osScreenSizeX-2) and osPY>=7 and osPY<=(osScreenSizeY-5) then
- for e, file in ipairs(list) do
- if e == osPY + start-6 then
- if run then
- runThing(location..file)
- run = false
- end
- end
- end
- return
- else
- if osPY == osScreenSizeY-3 and osPX >= osScreenSizeX-8 and osPX <= osScreenSizeX-3 then
- run = false
- return
- else
- drawFile()
- start = i-1
- end
- end
- end
- term.setCursorPos(4,i+6-start)
- if fs.isDir(location..file) then
- term.setTextColor(colors.green)
- else
- term.setTextColor(colors.black)
- end
- print(i.." "..file)
- end
- if run then
- osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
- if osPX>=3 and osPX<=(osScreenSizeX-2) and osPY>=7 and osPY<=(osScreenSizeY-4) then
- for e, file in ipairs(list) do
- if e == osPY + start-6 then
- if run then
- runThing(location..file)
- run = false
- end
- end
- end
- return
- else
- if osPY == osScreenSizeY-3 and osPX >= osScreenSizeX-8 and osPX <= osScreenSizeX-3 then
- run = false
- return
- else
- return
- end
- end
- end
- end
- end
- --Execution
- drawWindow()
- osListFiles("/apps/")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement