Advertisement
minif

run

Jan 23rd, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. --Minif OS run Tool
  2.  
  3. --Functions and Variables
  4. local start = 0
  5. local function drawWindow()
  6. paintutils.drawFilledBox(3,3,osScreenSizeX-2,osScreenSizeY-2,colors.white)
  7. paintutils.drawBox(3,3,osScreenSizeX-2,5,colors.lightGray)
  8. term.setBackgroundColor(colors.white)
  9. term.setTextColor(colors.black)
  10. term.setCursorPos(4,4)
  11. term.write("Open File")
  12. end
  13.  
  14. local function drawFile()
  15. paintutils.drawFilledBox(3,6,osScreenSizeX-2,osScreenSizeY-2,colors.white)
  16. term.setCursorPos(osScreenSizeX-8,osScreenSizeY-3)
  17. term.setTextColor(colors.black)
  18. term.setBackgroundColor(colors.red)
  19. term.write("Close")
  20. term.setBackgroundColor(colors.white)
  21. end
  22.  
  23.  
  24. local function runThing(file)
  25. if fs.isDir(file) then
  26. drawWindow()
  27. osListFiles(file.."/")
  28. else
  29. shell.run('"'..file..'"')
  30. return
  31. end
  32. end
  33.  
  34. function osListFiles(location)
  35. local run = true
  36. local start = 0
  37. local list = fs.list(location)
  38. drawFile()
  39. while run == true do
  40. for i, file in ipairs(list) do
  41. if i>osScreenSizeY-4-7+start then
  42. term.setCursorPos(4,osScreenSizeY-3)
  43. term.write("Next>")
  44. osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
  45. if osPX>=3 and osPX<=(osScreenSizeX-2) and osPY>=7 and osPY<=(osScreenSizeY-5) then
  46. for e, file in ipairs(list) do
  47. if e == osPY + start-6 then
  48. if run then
  49. runThing(location..file)
  50. run = false
  51. end
  52. end
  53. end
  54. return
  55. else
  56. if osPY == osScreenSizeY-3 and osPX >= osScreenSizeX-8 and osPX <= osScreenSizeX-3 then
  57. run = false
  58. return
  59. else
  60. drawFile()
  61. start = i-1
  62. end
  63. end
  64. end
  65. term.setCursorPos(4,i+6-start)
  66. if fs.isDir(location..file) then
  67. term.setTextColor(colors.green)
  68. else
  69. term.setTextColor(colors.black)
  70. end
  71. print(i.." "..file)
  72. end
  73. if run then
  74. osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
  75. if osPX>=3 and osPX<=(osScreenSizeX-2) and osPY>=7 and osPY<=(osScreenSizeY-4) then
  76. for e, file in ipairs(list) do
  77. if e == osPY + start-6 then
  78. if run then
  79. runThing(location..file)
  80. run = false
  81. end
  82. end
  83. end
  84. return
  85. else
  86. if osPY == osScreenSizeY-3 and osPX >= osScreenSizeX-8 and osPX <= osScreenSizeX-3 then
  87. run = false
  88. return
  89. else
  90. return
  91. end
  92. end
  93. end
  94. end
  95. end
  96.  
  97. --Execution
  98.  
  99. drawWindow()
  100. osListFiles("/apps/")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement