XoXFaby

XoXOS

Oct 30th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.68 KB | None | 0 0
  1. ttable = {}
  2.  
  3. function ttable.copy(t1)
  4. local t2 = {}
  5. for k,v in pairs(t1) do t2[k] = v end
  6. return t2
  7. end
  8.  
  9. startupprog = "none"
  10. notifytext = ""
  11.  
  12. function saveconfig()
  13. conff = fs.open("XoXOSC", "w")
  14. conff.writeLine(startupprog)
  15. conff.close()
  16. notifytext = "Saved."
  17. end
  18.  
  19. menuIndex = 1
  20. menu = {}
  21. menu1 = {}
  22. menu2 = {}
  23. menu3 = {}
  24. menu4 = {}
  25. menu5 = {}
  26.  
  27.  
  28. menu1.esc = function() end
  29. menu1[1] = { txt = "Programs" , exec = function() menu = ttable.copy( menu2 ) ; menuIndex = 1 end }
  30. menu1[2] = { txt = "Games" , exec = function() menu = ttable.copy( menu3 ) ; menuIndex = 1 end}
  31. menu1[3] = { txt = "Options", exec = function() menu = ttable.copy( menu4 ) ; menuIndex = 1 end}
  32.  
  33.  
  34. menu2.esc = function() menu = ttable.copy( menu1 ) ; menuIndex = 1 end
  35. menu2[1] = { prog = "door", txt = "Door", exec = function() shell.run("door") end}
  36. menu2[2] = { prog = "calc", txt = "Calculator", exec = function() shell.run("calc") end}
  37.  
  38.  
  39. menu3.esc = function() menu = ttable.copy( menu1 ) ; menuIndex = 1 end
  40. menu3[1] = { txt = "Text Minecraft", exec = function() shell.run("adventure") end}
  41.  
  42.  
  43. menu4.esc = function() menu = ttable.copy( menu1 ) ; menuIndex = 1 end
  44. menu4[1] =  { txt = "Startup Program", exec = function() menu = ttable.copy( menu5 ) ; menuIndex = 1 end}
  45. menu4[#menu4 + 1] = { txt = "Save" , exec = saveconfig }
  46.  
  47.  
  48. menu5 = ttable.copy(menu2)
  49. table.insert(menu5, 1, { txt = "None", prog = "none"  })
  50. menu5.esc = function() menu = ttable.copy( menu4 ) ; menuIndex = 1 end
  51. for k, v in ipairs(menu5) do
  52. v.exec = function() startupprog = menu5[menuIndex].prog end
  53. end
  54.  
  55. if fs.exists("XoXOSC") then
  56. conff = fs.open("XoXOSC" , "r" )
  57. startupprog = conff.readLine()
  58. conff.close()
  59. end
  60.  
  61. if startupprog ~= "none" then
  62. shell.run(startupprog)
  63. end
  64.  
  65.  
  66.  
  67. menu = ttable.copy( menu1 )
  68. term.clear()
  69. term.setCursorPos(1,1)
  70.  
  71.  
  72. while true do
  73.  
  74. term.clear()
  75. term.setCursorPos(1,1)
  76. for k,v in ipairs(menu) do
  77. print("   ")
  78. if menuIndex == k then
  79. print( ">> " .. v.txt .. " <<")
  80. else
  81. print( "   " .. v.txt)
  82. end
  83. end
  84.  
  85. term.setCursorPos(1,17)
  86. print(notifytext)
  87.  
  88. conf = fs.open("XoXOSDev", "w")
  89. conf.writeLine("Nope.")
  90. conf.close()
  91.  
  92. local event, param1 = os.pullEvent("key")
  93. notifytext = ""
  94. if param1 == 200 then
  95. menuIndex = menuIndex - 1
  96. if menuIndex < 1 then menuIndex = #menu end
  97. elseif param1 == 208 then
  98. menuIndex = menuIndex + 1
  99. if menuIndex > #menu then menuIndex = 1 end
  100. elseif param1 == 30 then
  101. menu2[1].exec()
  102. elseif param1 == 28 or param1 == 205 then
  103. menu[menuIndex].exec()
  104. elseif param1 == 14 or param1 == 203 then
  105. menu.esc()
  106. elseif param1 == 60 then
  107. conf = fs.open("XoXOSDev", "w")
  108. conf.writeLine("Let's go")
  109. conf.close()
  110. return
  111. end
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. end
Advertisement
Add Comment
Please, Sign In to add comment