Advertisement
XDjackieXD

Programmliste

Apr 14th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 KB | None | 0 0
  1. local FileList = fs.list(".modderOS/programme/liste/")
  2. local xx,yy = term.getSize()
  3. local quit = 0
  4. menu_items = {}
  5. local select = 0
  6.  
  7.  
  8. function reset()
  9.         local x,y = term.getSize()
  10.         term.setBackgroundColor(colors.blue)
  11.         term.clear()
  12.         term.setCursorPos(1, 1)
  13.         paintutils.drawLine(1, 1, x, 1, colors.lightGray)
  14.         term.setCursorPos(1, 1)
  15.         print("Programmliste")
  16.     local x1 = x-6
  17.     term.setCursorPos(x1,1)
  18.     print("Zurück")
  19.     term.setBackgroundColour(colors.blue)
  20.     menu_items = {}
  21.     for _, file in ipairs(FileList) do
  22.       table.insert(menu_items, file)
  23.     end
  24.     for i=1, #menu_items, 1 do
  25.         if i <= 17 then
  26.              local ii = i+1
  27.              term.setCursorPos(1,ii)
  28.         elseif i >= 18 and i <= 34 then
  29.              local ii = i-16
  30.              term.setCursorPos(18,ii)
  31.         elseif i >= 35 and i <= 51 then
  32.         local ii = i-33
  33.              term.setCursorPos(35,ii)
  34.         end
  35.         print(menu_items[i])
  36.     end
  37. end
  38.  
  39. reset()
  40.  
  41. while quit == 0 do
  42.  
  43.  local event, button, x, y = os.pullEvent("mouse_click")
  44.     if event == "mouse_click" then
  45.                         if y == 1 and x > xx-7 and x < xx then
  46.                 quit = 1
  47.                         end
  48.             for iy=2,18,1 do
  49.                             if y == iy and x <= 17 then
  50.                     select = iy-1
  51.                             end
  52.             end
  53.             for iy=2,18,1 do
  54.                             if y == iy and x <= 34 and x >= 18 then
  55.                     select = iy+16
  56.                             end
  57.             end
  58.             for iy=2,18,1 do
  59.                             if y == iy and x >= 35 then
  60.                     select = iy+33
  61.                             end
  62.             end
  63.  
  64.     end
  65. if select ~= 0 and select <= #menu_items then
  66.  term.setBackgroundColor(colors.blue)
  67.  term.setCursorPos(1, 1)
  68.  term.clear()
  69.  shell.run(".modderOS/programme/"..menu_items[select])
  70.  reset()
  71.  select = 0
  72. end
  73. end
  74.  
  75. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement