Guest User

menu

a guest
Dec 27th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.19 KB | None | 0 0
  1. function CUI(m)
  2. n = 1
  3. l = #m
  4. while true do
  5. term.clear()
  6. term.setCursorPos(1,1)
  7. term.setTextColor(colors.green)
  8. print("Devil Inc. Softwares")
  9. term.setTextColor(colors.white)
  10. term.setCursorPos(1,2)
  11. for i=1, l, 1 do
  12. if i==n then print(">"..m[i].."<") else print(" ",m[i]) end
  13. end
  14. a, b = os.pullEventRaw()
  15. if a =="key" then
  16. if b == 200 and n>1 then n=n-1 end
  17. if b == 208 and n<l then n=n+1 end
  18. if b == 28 then break end
  19. end
  20. end
  21. term.clear() term.setCursorPos(1,1)
  22. return n
  23. end
  24.  
  25.  
  26. --[[Password]]--
  27. function password()
  28.  
  29. term.clear()
  30. term.setCursorPos(1,1)
  31. term.write("Admin Enter Password: ")
  32. password = read("*")
  33. if password == "placeholder" then
  34.  print("Correct")
  35.   else
  36.  print("Incorrect") sleep(2)
  37.  os.reboot()
  38. end
  39. end
  40. --[Yes/No Options]]--
  41. function yN()
  42. local n=1
  43. while true do
  44. local x,y=term.getCursorPos()
  45. term.clearLine()
  46. if n == 1 then write(">Yes< No") else write(" Yes >No<") end
  47. term.setCursorPos(x,y)
  48. a, b=os.pullEvent()
  49. while a ~="key" do a,b =os.pullEvent() end
  50. if b == 203 and n==2 then n=1 end
  51. if b == 205 and n==1 then n=2 end
  52. if b == 28 then print("") break end
  53. end
  54. if n==1 then return true end
  55. if n==2 then return true end
  56. return false
  57. end
  58.  
  59. --[[print Online]]--
  60. function online(var)
  61.  
  62.  if n==1 then term.setTextColor(colors.lime) print(var.." Online") sleep(2) os.reboot() end
  63.  if n==2 then term.setTextColor(colors.red) print(var.." Offline") sleep(2) os.reboot() end
  64.  if n==3 then os.reboot() end
  65. end
  66. --[[Print On]]--
  67. function on(var)
  68.  
  69.  if n==1 then term.setTextColor(colors.lime) print(var.." On") sleep(2) os.reboot() end
  70.  if n==2 then term.setTextColor(colors.red) print(var.." Off") sleep(2) os.reboot() end
  71.  if n==3 then os.reboot() end
  72. end
  73.  
  74. --[[Write function]]--
  75. function writeState(filename, state)
  76.     file = fs.open(filename, "w")
  77.     file.write(state)
  78.     file.close()
  79. end
  80. --[[Read Function]]--
  81.  
  82. function readState(filename)
  83.      if not fs.exists(filename) then
  84.         writeState(stateFile, "_state")
  85.         return
  86.      end
  87.      file = fs.open(filename, "r")
  88.      state = file.readLine()
  89.      file.close()
  90. end
  91. --[[Tables]]--
  92.  
  93. local n = 1
  94. local options={
  95. "Lights",
  96. "Doors",
  97. "Shields",
  98. "Options:Admins Only",
  99. "Buildcraft Machines",
  100. "Industrial Machines",
  101. "Forestry Machines",
  102. }
  103. local lights={
  104. "On",
  105. "Off",
  106. "Back"
  107. }
  108. local doors={
  109. "Open",
  110. "Close",
  111. "Back"
  112. }
  113. local shields={
  114. "On",
  115. "Off",
  116. "Back"
  117. }
  118. local buildcraftmachines ={
  119. "Pumps",
  120. "Refinery",
  121. "Back"
  122. }
  123. local industrialcraftmachines ={
  124. "Nuclear Reactor",
  125. "Power Production",
  126. "Back"
  127. }
  128. local forestrymachines ={
  129. "Peat Farm",
  130. "Tree Farm",
  131. "Rubber Tree Farm",
  132. "Cactus Farm",
  133. "Pumpkin Farm",
  134. "Reed Farm",
  135. "Still",
  136. "Bio Generator",
  137. "Back"
  138. }
  139.  
  140. local subbuildcraft ={
  141. "On",
  142. "Off",
  143. "Back"
  144. }
  145.  
  146. local subindustrialcraft ={
  147. "On",
  148. "Off",
  149. "Back",
  150. }
  151.  
  152. local subforestry ={
  153. "On",
  154. "Off",
  155. "Back"
  156. }
  157. --[[Executed Commands]]--
  158.  
  159. readState("stateFile")
  160.  
  161. local n=CUI(options)
  162. --[[Lights]]--
  163. if n == 1 then local n=CUI(lights)
  164.    on("Lights")
  165.  
  166. --[[Doors]]--
  167. elseif n == 2 then local n=CUI(doors)
  168.   if n == 1 then term.setTextColor(colors.lime) print("Doors Open") redstone.setOutput("right", true) state = "on" writeState(stateFile, state) sleep(2) os.reboot() end
  169.   if n == 2 then term.setTextColor(colors.red) print("Doors Close") sleep(2) os.reboot() end
  170.   if n == 3 then os.reboot() end
  171.  
  172. --[[Shields]]--
  173. elseif n == 3 then local n =CUI(shields)
  174.    online("Shields")
  175.  
  176. --[[Password]]--
  177. elseif n == 4 then password()  
  178.  
  179. --[[Buildcraft Pumps]]--
  180. elseif n == 5 then local n=CUI(buildcraftmachines)
  181.        if n == 1 then local n=CUI(subbuildcraft)
  182.        online("Pumps")
  183.  
  184. --[[Buildcraft Refinery]]--
  185.   elseif n == 2 then local n=CUI(subbuildcraft)
  186.        online("Refinery")
  187.   elseif n == 3 then os.reboot() end
  188.  
  189. --[[Industrialcraft Nuclear Reactor]]--
  190. elseif n == 6 then local n=CUI(industrialcraftmachines)
  191.   if n == 1 then local n=CUI(subindustrialcraft)
  192.    online("Nuclear Reactor")
  193.  
  194. --[[Power Production]]--
  195.   elseif n == 2 then local n=CUI(subindustrialcraft) end
  196.    online("Power Production")
  197.   elseif n == 3 then os.reboot()
  198.  
  199. --[[Peat Farm]]--
  200. elseif n == 7 then local n=CUI(forestrymachines)
  201.   if n == 1 then local n=CUI(subforestry)
  202.      online("Peat Farm")  
  203.        
  204. --[[Tree Farm]]--
  205.   elseif n == 2 then local n=CUI(subforestry)
  206.      online("Tree Farm")
  207.  
  208. --[[Rubber Tree Farm]]--  
  209.   elseif n == 3 then local n=CUI(subforestry)
  210.      online("Rubber Tree Farm")
  211.  
  212. --[[Cactus Farm]]--
  213.   elseif n == 4 then local n=CUI(subforestry)
  214.      online("Cactus Farm")
  215.  
  216. --[[Pumpkin Farm]]--
  217.   elseif n == 5 then local n=CUI(subforestry)
  218.      online("Pumpkin Farm")
  219.  
  220. --[[Reed Farm]]--
  221.   elseif n == 6 then local n=CUI(subforestry)
  222.      online("Reed Farm")
  223.  
  224. --[[Stillery]]--
  225.   elseif n == 7 then local n=CUI(subforestry)
  226.      online("Stillery")
  227.  
  228. --[[Bio Generation]]--
  229.   elseif n == 8 then local n=CUI(subforestry)
  230.         if n == 1 then term.setTextColor(colors.lime) print("Bio Generation Enabled") sleep(2) os.reboot() end
  231.         if n == 2 then term.setTextColor(colors.red) print("Bio Generation Disabled") sleep(2) os.reboot() end
  232.         if n == 3 then os.reboot()end
  233.  
  234.   elseif n == 9 then os.reboot() end
  235.  
  236. end
Advertisement
Add Comment
Please, Sign In to add comment