SHARE
TWEET

Untitled

a guest Nov 9th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. os.pullEvent = os.pullEventRaw
  2. --Variables
  3.  
  4. local w,h = term.getSize()
  5. local nOpt = 1
  6. local scr = 1 --Screen ID (1 = smenu 2 = App 3 = opt 4 = Util
  7. term.setTextColor( colors.green )
  8. --
  9. --PrintCen
  10. function printCentered (y,s)
  11.   local x = math.floor((w - string.len(s)) / 2)
  12.   term.setCursorPos(x,y)
  13.   term.clearLine()
  14.   term.write(s)  
  15. end
  16. --Draw menu
  17.  
  18.  
  19.  
  20. local function drawMenu()
  21.   term.clear()
  22.   term.setCursorPos(1,2)
  23.   term.write("BasOS Ver. V1.0 Dev build")
  24.     term.setCursorPos(1,3)
  25.     term.write("")
  26.   term.setCursorPos(1,18)
  27.   shell.run("time")
  28.   term.setCursorPos(w-11,1)
  29.  
  30.      if nOpt == 1 and scr == 1 then
  31.     term.write("Applications")
  32.   elseif nOpt == 2 and scr == 1 then
  33.     term.write("Options")
  34.  
  35.   elseif nOpt == 3 and scr == 1  then
  36.     term.write("Shutdown")
  37.   elseif nOpt == 1 and scr == 2 then
  38.     term.write("Games")
  39.   elseif nOpt == 2  and scr == 2 then
  40.     term.write("Utility")
  41.   elseif nOpt == 3 and scr == 2   then
  42.     term.write("Adventure")
  43.   elseif nOpt == 4 and scr == 2  then
  44.     term.write("Shell")
  45.       elseif nOpt == 5 and scr == 2  then
  46.  
  47.      elseif nOpt == 1 and scr == 3 then
  48.     term.write("Password")
  49.   elseif nOpt == 2 and scr == 3 then
  50.  
  51.     else
  52.     end
  53.  
  54. end
  55. --GUI
  56.  
  57. local function selectname()
  58.  
  59.  
  60. term.clear()
  61. printCentered(math.floor(h/2) - 3, "Enter name:")
  62. local input = read()
  63.  
  64.     shell.run("paint", input)
  65.  
  66. end
  67. local function dA()
  68.     scr = 1
  69.   printCentered(math.floor(h/2) - 3, "")
  70.   printCentered(math.floor(h/2) - 2, "Start Menu")
  71.   printCentered(math.floor(h/2) - 1, "")
  72.   printCentered(math.floor(h/2) + 0, ((nOpt == 1) and "[-> Applications <-]") or "Applications")
  73.   printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Options <-]") or "Options" )
  74.   printCentered(math.floor(h/2) + 2, ((nOpt == 3) and "[-> Shut-down <-]") or "Shut-down" )
  75.   printCentered(math.floor(h/2) + 3, ((nOpt == 4) and "[-> Reboot <-]") or "Reboot" )
  76. end  
  77. local function dBA()
  78. scr = 21
  79.  
  80.   printCentered(math.floor(h/2) - 5, "")
  81.   printCentered(math.floor(h/2) - 4, "")
  82.   printCentered(math.floor(h/2) - 2, "Game Menu")
  83.   printCentered(math.floor(h/2) - 1, "")
  84.  
  85.   printCentered(math.floor(h/2) + 0, ((nOpt == 1) and "[-> Worm <-]") or "Worm" )
  86.   printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Minesweeper <-]") or "Minesweeper" )
  87.    printCentered(math.floor(h/2) + 2, ((nOpt == 3) and "[-> Adventure <-]") or "Adventure" )
  88.       printCentered(math.floor(h/2) + 3, ((nOpt == 4) and "[-> Redirection <-]") or "Redirection" )
  89.             printCentered(math.floor(h/2) + 4, ((nOpt == 5) and "[-> Tetris <-]") or "Tetris" )
  90.   printCentered(math.floor(h/2) + 5, ((nOpt == 6) and "[-> Back <-]") or "Back" )
  91.  
  92.  
  93.   end
  94.   local function dB()--Applications
  95.   scr = 2
  96.  
  97.   printCentered(math.floor(h/2) - 5, "If it sends you to Shell,")
  98.   printCentered(math.floor(h/2) - 4, "type 'os' to return.")
  99.   printCentered(math.floor(h/2) - 2, "Applications Menu")
  100.   printCentered(math.floor(h/2) - 1, "")
  101.  
  102.   printCentered(math.floor(h/2) + 0, ((nOpt == 2) and "[-> Games <-]") or "Games" )
  103.   printCentered(math.floor(h/2) + 1, ((nOpt == 3) and "[-> Utility <-]") or "Utility" )
  104.    
  105.   printCentered(math.floor(h/2) + 2, ((nOpt == 4) and "[-> Shell <-]") or "Shell" )
  106.     printCentered(math.floor(h/2) + 3, ((nOpt == 5) and "[-> Paint <-]") or "Paint" )
  107.   printCentered(math.floor(h/2) + 4, ((nOpt == 6) and "[-> Back <-]") or "Back" )
  108.   end
  109.     local function dBB()--Utility Menu
  110.   scr = 22
  111.  
  112.   printCentered(math.floor(h/2) - 5, "")
  113.   printCentered(math.floor(h/2) - 4, "")
  114.   printCentered(math.floor(h/2) - 2, "Utility Menu")
  115.   printCentered(math.floor(h/2) - 1, "")
  116.  
  117.   printCentered(math.floor(h/2) + 0, ((nOpt == 2) and "[-> Ink <-]") or "Ink" )
  118.   printCentered(math.floor(h/2) + 1, ((nOpt == 3) and "[-> Disk <-]") or "Disk" )
  119.   printCentered(math.floor(h/2) + 2, ((nOpt == 4) and "[-> LuaIDE <-]") or "LuaIDE" )
  120.     printCentered(math.floor(h/2) + 3, ((nOpt == 5) and "[-> Chat <-]") or "Chat" )
  121.      printCentered(math.floor(h/2) + 4, ((nOpt == 6) and "[-> Chat Server <-]") or "Chat Server" )
  122.   printCentered(math.floor(h/2) + 5, ((nOpt == 7) and "[-> Back <-]") or "Back" )
  123.   end
  124.   local function dC()
  125. scr = 3
  126.     local d = fs.open("des", "r")
  127.   printCentered(math.floor(h/2) - 3, "")
  128.   printCentered(math.floor(h/2) - 2, "Options Menu")
  129.   printCentered(math.floor(h/2) - 1, "")
  130.   printCentered(math.floor(h/2) + 0, ((nOpt == 1) and "[-> Password <-]") or "Password" )
  131.   if d.readAll() == "t" then
  132.   local g = 1
  133.     printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Disable password <-]") or "Disable password" )
  134.     else
  135.     g = 0
  136.      printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Enable password <-]") or "Enable password" )
  137.     end
  138.   printCentered(math.floor(h/2) + 2, ((nOpt == 3) and "[-> Back <-]") or "Back" )
  139.     printCentered(math.floor(h/2) + 3, ((nOpt == 4) and "         ") or "          " )
  140.       printCentered(math.floor(h/2) + 4, ((nOpt == 5) and "          ") or "          " )
  141.   end
  142.  local function Pw()
  143. scr = 25
  144. term.clear()
  145. local title = disk.getAudioTitle("Bottom")
  146. printCentered(math.floor(h/2) - 3, "Music Disc Menu")
  147. printCentered(math.floor(h/2) - 2, ""..disk.getAudioTitle("bottom"))
  148.   printCentered(math.floor(h/2) + 0, ((nOpt == 1) and "[-> Play <-]") or "Play")
  149.   printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Stop <-]") or "Stop")
  150.   printCentered(math.floor(h/2) + 2, ((nOpt == 3) and "[-> Back <-]") or "Back")
  151.  
  152. end
  153. local function PwB()
  154. scr = 251
  155. term.clear()
  156.  
  157. printCentered(math.floor(h/2) - 3, "Floppy Disk Menu")
  158.  
  159.   printCentered(math.floor(h/2) + 0, ((nOpt == 1) and "[-> Data <-]") or "Data")
  160.   printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Name <-]") or "Name")
  161.   printCentered(math.floor(h/2) + 2, ((nOpt == 3) and "[-> Back <-]") or "Back")
  162.  
  163. end
  164. local function PwC()
  165. scr = 252
  166. term.clear()
  167. printCentered(math.floor(h/2) - 3, "Name Disk")
  168.  
  169.   printCentered(math.floor(h/2) - 3, "Input Name:")
  170. printCentered(math.floor(h/2) + 0, "")
  171. local input = read()
  172. disk.setLabel("bottom", input)
  173. PwB()
  174. end
  175. local function pset()
  176. while true do
  177. scr = 252
  178. term.clear()
  179. if fs.exists("pass") == true then
  180. shell.run("delete pass")
  181. end
  182.  
  183.  
  184. printCentered(math.floor(h/2) - 3, "Input new password")
  185.  
  186.   printCentered(math.floor(h/2) - 3, "        ")
  187. printCentered(math.floor(h/2) + 0, "")
  188. local input = read()
  189.  
  190. print("Invalid password!")
  191.  
  192.  
  193. local h = fs.open("pass", "w")
  194. h.write(input)
  195. scr = 3
  196.  
  197. dC()
  198. break
  199.  
  200. end
  201. end
  202.  
  203. function data()
  204. term.clear()
  205. shell.run("cd disk")
  206. end
  207.   function Wtd ()
  208.   while true do
  209.  
  210.   local e,p = os.pullEvent()
  211.     if e == "key" then
  212.     term.setTextColor( colors.green )
  213.         local key = p
  214.         if key == keys.w or key == keys.up then
  215.           term.setCursorPos(1,18)
  216.   shell.run("time")
  217.             if nOpt > 1 and scr == 1 then
  218.             nOpt = nOpt - 1
  219.             drawMenu()
  220.             dA()
  221.             elseif nOpt > 1 and scr == 25 then
  222.             nOpt = nOpt - 1
  223.             drawMenu()
  224.             Pw()
  225.             elseif nOpt > 1 and scr == 251 then
  226.             nOpt = nOpt - 1
  227.             drawMenu()
  228.             PwB()
  229.             elseif nOpt > 2 and scr == 2 then
  230.             nOpt = nOpt - 1
  231.             drawMenu()
  232.             dB()
  233.             elseif nOpt > 1 and scr == 3 then
  234.             nOpt = nOpt - 1
  235.             drawMenu()
  236.             dC()
  237.             elseif nOpt > 2 and scr == 22 then
  238.             nOpt = nOpt - 1
  239.             drawMenu()
  240.             dBB()
  241.             elseif nOpt > 1 and scr == 21 then
  242.             nOpt = nOpt - 1
  243.             drawMenu()
  244.             dBA()
  245.             else
  246.             end
  247.             elseif key == keys.s or key == keys.down then
  248.             if nOpt < 4 and scr == 1 then
  249.             nOpt = nOpt + 1
  250.             drawMenu()
  251.             dA()
  252.             elseif nOpt < 6 and scr == 2 then
  253.             nOpt = nOpt + 1
  254.             drawMenu()
  255.             dB()
  256.             elseif nOpt < 6 and scr == 2 then
  257.             nOpt = nOpt + 1
  258.             drawMenu()
  259.             dB()
  260.             elseif nOpt < 2 and scr == 3 then
  261.             nOpt = nOpt + 1
  262.             drawMenu()
  263.             dC()
  264.             elseif nOpt < 3 and scr == 3 then
  265.             nOpt = nOpt + 1
  266.             drawMenu()
  267.             dC()
  268.             elseif nOpt < 7 and scr == 22 then
  269.             nOpt = nOpt + 1
  270.             drawMenu()
  271.             dBB()
  272.         elseif nOpt < 6 and scr == 21 then
  273.             nOpt = nOpt + 1
  274.             drawMenu()
  275.             dBA()
  276.             elseif nOpt < 3 and scr == 251 then
  277.             nOpt = nOpt + 1
  278.             drawMenu()
  279.             PwB()
  280.             elseif nOpt < 3 and scr == 25 then
  281.             nOpt = nOpt + 1
  282.             drawMenu()
  283.             Pw()
  284.             else
  285.             end
  286.            
  287.             elseif key == keys.enter then
  288.             if nOpt == 3 and scr == 1 then
  289.                 printCentered(math.floor(h/2) - 2, "Shutting Down...")
  290.                 sleep(1)
  291.                 printCentered(math.floor(h/2) - 2, "                ")
  292.                 printCentered(math.floor(h/2) - 2, "")
  293.                 shell.run("shutdown")
  294.                 term.clear()
  295.             end
  296.             if nOpt == 4 and scr == 1 then
  297.                 printCentered(math.floor(h/2) - 2, "Rebooting...")
  298.                 sleep(1)
  299.                 printCentered(math.floor(h/2) - 2, "                ")
  300.                 printCentered(math.floor(h/2) - 2, "")
  301.                 shell.run("reboot")
  302.                 term.clear()
  303.             end
  304.         if nOpt == 3 and scr == 1 then
  305.         printCentered(math.floor(h/2) - 2, "Shutting Down...")
  306.         sleep(1)
  307.         printCentered(math.floor(h/2) - 1, "")
  308.             shell.run("shutdown")
  309.         end
  310.         if nOpt == 1 and scr == 1 then
  311.         scr = 2
  312.         nOpt = 2
  313.         drawMenu()
  314.         dB()
  315.         Wtd()
  316.         end
  317.         if nOpt == 1 and scr == 251 then
  318.         term.setCursorPos(1,1)
  319.         data()
  320.         print("type 'cd ..' then 'os' to return. type 'ls' for drive content")
  321.        
  322.        
  323.         shell.run("shell")
  324.         --shell.run("ls")
  325.         break
  326.         end
  327.         if nOpt == 3 and scr == 22 then
  328.        
  329.         nOpt = 1
  330.         drawMenu()
  331.         if disk.hasAudio("bottom") == true then
  332.         scr = 25
  333.         Pw()
  334.        
  335.         elseif disk.hasData("bottom") == true then
  336.         scr = 251
  337.         PwB()
  338.         else
  339.         end
  340.        
  341.         end
  342.         if nOpt == 6 and scr == 2 then
  343.         scr = 1
  344.         nOpt = 1
  345.         drawMenu()
  346.         dA()
  347.         Wtd()
  348.         end
  349.         if nOpt == 5 and scr == 2 then
  350.         selectname()
  351.         end
  352.         if nOpt == 3 and scr == 2 then
  353.         scr = 22
  354.         nOpt = 1
  355.         dBB()
  356.         Wtd()
  357.         end
  358.         if nOpt == 3 and scr == 3 then
  359.         scr = 1
  360.         nOpt = 1
  361.    
  362.         dA()
  363.         end
  364.         if nOpt == 2 and scr == 3 then
  365.             local d = fs.open("des", "w")
  366.        
  367.            
  368.             if g == 0 then
  369.            
  370.         d.write("t")
  371.         d.close()
  372.         g = 1
  373.         dC()
  374.         printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Disable password <-]") or "Disable password" )
  375.         elseif g == 1 then
  376.        
  377.         d.write("f")
  378.         d.close()
  379.         g = 0
  380.         dC()
  381.         printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Enable password <-]") or "Enable password" )
  382.         end
  383.    
  384.        
  385.            
  386.        
  387.         end
  388.         if nOpt == 1 and scr == 3 then
  389.         pset()
  390.         end
  391.         if nOpt == 2 and scr == 1 then
  392.         scr = 3
  393.         nOpt = 1
  394.    
  395.         dC()
  396.         end
  397.         if nOpt == 2 and scr == 2 then
  398.         scr = 21
  399.         nOpt = 1
  400.         dBA()
  401.         Wtd()
  402.         end
  403.         if nOpt == 1 and scr == 21 then
  404.         local newTabID = multishell.launch({}, "osdata/snake")
  405.  
  406. multishell.setTitle(newTabID, "Snake")
  407. multishell.setFocus(newTabID)
  408.         end
  409.         if nOpt == 5 and scr == 21 then
  410.         shell.run("rom/programs/pocket/falling")
  411.  
  412.  
  413.         end
  414.         if nOpt == 4 and scr == 21 then
  415.         shell.run("redir")
  416.         break
  417.         end
  418.         if nOpt == 2 and scr == 22 then
  419.         local newTabID = multishell.launch({}, "osdata/ink")
  420.  
  421. multishell.setTitle(newTabID, "Ink")
  422. multishell.setFocus(newTabID)
  423.         end
  424.         if nOpt == 4 and scr == 22 then
  425.         local newTabID = multishell.launch({}, "luaide")
  426.  
  427. multishell.setTitle(newTabID, "LUAIDE")
  428. multishell.setFocus(newTabID)
  429.         end
  430.         if nOpt == 2 and scr == 21 then
  431.         local newTabID = multishell.launch({}, "osdata/minesweep")
  432.  
  433. multishell.setTitle(newTabID, "Mines")
  434. multishell.setFocus(newTabID)
  435.         end
  436.                 if nOpt == 3 and scr == 21 then
  437.         local newTabID = multishell.launch({}, "rom/programs/fun/adventure")
  438.  
  439. multishell.setTitle(newTabID, "Advent")
  440. multishell.setFocus(newTabID)
  441.         end
  442.         if nOpt == 4 and scr == 2 then
  443.         term.clear()
  444.         term.setCursorPos(1,1)
  445.         print("Type 'os' to return.")
  446.         shell.run("shell")
  447.         break
  448.         end
  449.         if nOpt == 7 and scr == 22 then
  450.             nOpt = 2
  451.             scr = 2
  452.             drawMenu()
  453.             dB()
  454.             end
  455.             if nOpt == 5 and scr == 22 then
  456.                     local newTabID = multishell.launch({}, "talk")
  457.  
  458. multishell.setTitle(newTabID, "Chat")
  459. multishell.setFocus(newTabID)
  460. Wtd()
  461.             end
  462.             if nOpt == 6 and scr == 22 then
  463.                     shell.run("talks")
  464. Wtd()
  465.             end
  466.             if nOpt == 3 and scr == 25 then
  467.             nOpt = 1
  468.             scr = 22
  469.             drawMenu()
  470.             dBB()
  471.             end
  472.             if nOpt == 3 and scr == 251 then
  473.             nOpt = 1
  474.             scr = 22
  475.             drawMenu()
  476.             dBB()
  477.             end
  478.             if nOpt == 2 and scr == 251 then
  479.             nOpt = 1
  480.             scr = 252
  481.             drawMenu()
  482.             PwC()
  483.             end
  484.             if nOpt == 1 and scr == 25 then
  485.             disk.playAudio("bottom")
  486.             end
  487.             if nOpt == 2 and scr == 25 then
  488.             disk.stopAudio("bottom")
  489.             end
  490.         if nOpt == 6 and scr == 21 then
  491.        
  492.         scr = 2
  493.         nOpt = 2
  494.         drawMenu()
  495.         dB()
  496.         Wtd()  
  497.             end
  498.         end
  499.         end
  500.         end
  501.         end
  502.        
  503.         term.clear()
  504.          --Display
  505.   drawMenu()
  506.   dA()
  507.   Wtd()
  508.         --cond
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top