Advertisement
Guest User

Startup.lua

a guest
Apr 24th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. w,h=term.getSize()
  2. tGames=fs.list("Apps/Games/Content")
  3. for i=1,#tGames do
  4. if tGames[i] then
  5. end
  6. end
  7. function drawGames()
  8. local nIcon=1
  9. tIcons={}
  10. Draw.clear(1)
  11. term.setTextColor(2^15)
  12. term.setCursorPos(w/2-2,h)
  13. term.write("Back")
  14. Draw.setStatusColor(128)
  15. Draw.isStatusVisible(true)
  16. Draw.status()
  17. for n=1,2 do
  18. for i=1,2 do
  19. if tGames[(n-1)*2+i] then
  20. if fs.exists("Apps/Games/Content/"..tGames[(n-1)*2+i].."/icon") then
  21. tIcon=Draw.loadIcon("Apps/Games/Content/"..tGames[(n-1)*2+i].."/icon")
  22. else
  23. tIcon=Draw.loadIcon("System/Images/default")
  24. end
  25. Draw.icon(tIcon,math.ceil(w/2)*(i-1)+3+(i-1)*4,n*8-4)
  26. tIcons[nIcon]={}
  27. tIcons[nIcon][1]=math.ceil(w/2)*(i-1)+4
  28. tIcons[nIcon][2]=math.ceil(w/2)*(i-1)+11
  29. tIcons[nIcon][3]=n*8-4
  30. tIcons[nIcon][4]=n*8-1
  31. tIcons[nIcon][5]=tGames[(n-1)*2+i]
  32. nIcon=nIcon+1
  33. term.setTextColor(2^15)
  34. sName=nil
  35. if #tGames[(n-1)*2+i]>12 then sName=tGames[(n-1)*2+i]:sub(1,9).."..." else sName=tGames[(n-1)*2+i] end
  36. term.setCursorPos(math.ceil(w/2)*(i-1)+(12/#sName)*i+i-1,n*8-1)
  37. term.setBackgroundColor(1)
  38. term.write(sName)
  39. term.setBackgroundColor(32768)
  40. term.setTextColor(1)
  41. end
  42. end
  43. end
  44. end
  45. nStatusTimer=os.startTimer(60/72)
  46. drawGames()
  47. local games=true
  48. while games do
  49. tEvent={os.pullEventRaw()}
  50. if tEvent[1]=="mouse_click" then
  51. x,y=tEvent[3],tEvent[4]
  52. if oldx==x and oldy==y then
  53. for i=1,#tIcons do
  54. if x>=w/2-2 and x<=w/2+2 and y==h then games=false shell.run("System/Desktop.lua") end
  55. if x>=tIcons[i][1] and x<=tIcons[i][2] and y>=tIcons[i][3] and y<=tIcons[i][4] then shell.run("Apps/Games/Content/"..tIcons[i][5].."/Startup.lua") end
  56. drawGames()
  57. end
  58. end
  59. oldx,oldy=x,y
  60. end
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement