Advertisement
lego11

ApertureOS NOlogin

Jun 21st, 2018
1,361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. currentUser=nil
  2.  
  3. function os.pullEvent()
  4.     local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
  5.     if event == "terminate" and termDisabled then
  6.    
  7.     end
  8.     return event, p1, p2, p3, p4, p5
  9. end
  10.  
  11.  
  12.  
  13.  
  14. if not fs.exists("accountDatabase") then
  15.     shell.run("pastebin","get","kERnnPN8","accountDatabase")
  16. end
  17.  
  18. os.loadAPI("accountDatabase")
  19.  
  20. defaultPrograms={["UpdateOS"]="vFjP50hm", ["MediaPl."]="7MfZH0jH", ["FileMgr"]="zyAKNJwB", ["LuaInt"]="RBMbTH66", ["LuaIDE"]="6WpGXY09", ["LeNet"]="EQgHhsAA"}
  21.  
  22. function drawLogin()
  23.     termDisabled=true
  24.     username={}
  25.     pass={}
  26.     term.setTextColor(2)
  27.     loginDrawn=true
  28.     term.setBackgroundColor(8)
  29.     term.clear()
  30.     screenX,screenY=term.getSize()
  31.     term.setCursorPos(screenX/2-10,screenY/2-5)
  32.     term.setBackgroundColor(128)
  33.     term.write("Login to Aperture OS")
  34.     term.setBackgroundColor(256)
  35.     for i=1,7 do
  36.         term.setCursorPos(screenX/2-10,(screenY/2-5)+i)
  37.         term.write("                    ")
  38.     end
  39.     term.setBackgroundColor(1)
  40.     term.setCursorPos(screenX/2-2,(screenY/2-2))
  41.     term.write("        ")
  42.     term.setCursorPos(screenX/2-2,(screenY/2+0))
  43.     term.write("        ")
  44.     term.setBackgroundColor(256)
  45.     term.setCursorPos(screenX/2-7,(screenY/2-2))
  46.     term.write("User")
  47.     term.setCursorPos(screenX/2-7,(screenY/2+0))
  48.     term.write("Pass")
  49.     term.setCursorPos(screenX/2+4,screenY/2+2)
  50.     term.setBackgroundColor(128)
  51.     term.write("Login")
  52.     term.setBackgroundColor(1)
  53.     term.setTextColor(32768)
  54.     term.setCursorPos(screenX/2-2,(screenY/2-2))
  55.     term.setCursorBlink(true)
  56.    
  57. end
  58.  
  59. function loginEvents()
  60.     repeat
  61.         event,v1,v2,v3,v4,v5=os.pullEvent()
  62.         if event=="char" then
  63.             loginType(v1)
  64.         elseif event=="mouse_click" then
  65.            
  66.             screenX,screenY=term.getSize()
  67.             button=v1
  68.             x=v2
  69.             y=v3
  70.             if button==1 then
  71.                 if x>=screenX/2-3 and x< screenX/2+6 and y==math.floor(screenY/2-2) then
  72.                     term.setCursorPos(screenX/2-2+#username,(screenY/2-2))
  73.                 elseif x>=screenX/2-3 and x< screenX/2+6 and y==math.floor(screenY/2+0) then
  74.                     term.setCursorPos(screenX/2-2+#pass,(screenY/2+0))
  75.                 elseif x>=screenX/2+4 and x<screenX/2+9 and y==math.floor(screenY/2+2) then
  76.                     serialiseLogin()
  77.                 end        
  78.             end
  79.         elseif event=="key" then
  80.             key=v1
  81.             if key==14 then
  82.                 loginBackspace()
  83.             elseif key==15 then
  84.                 loginTab()
  85.             end
  86.         end
  87.     until currentUser~=nil
  88. end
  89.  
  90. function serialiseLogin()
  91.     userString=""
  92.     passString=""
  93.     for id,letter in ipairs(username) do
  94.         userString=userString..letter
  95.     end
  96.     for id,letter in ipairs(pass) do
  97.         passString=passString..letter
  98.     end
  99.     loggedIn=attemptLogin(userString,passString)
  100.     if not loggedIn then
  101.         oldX,oldY=term.getCursorPos()
  102.         term.setCursorBlink(false)
  103.         term.setCursorPos(screenX/2-9,screenY/2+5)
  104.         term.setTextColor(16384)
  105.         term.setBackgroundColor(32768)
  106.         term.write("Incorrect Password!")
  107.         sleep(1)
  108.         term.setBackgroundColor(8)
  109.         term.setCursorPos(screenX/2-9,screenY/2+5)
  110.         term.write("                  ")
  111.         term.setCursorPos(oldX,oldY)
  112.         term.setTextColor(32768)
  113.         term.setCursorBlink(true)
  114.     end
  115. end
  116.  
  117. function attemptLogin(user,pass)
  118.     password=accountDatabase.getData(user)
  119.     if password==nil then
  120.         passLength=string.len(pass)
  121.         if passLength<8 then
  122.             for i=1,8-passLength do
  123.                 pass=pass.." "
  124.             end
  125.         end
  126.         accountDatabase.setData(user,pass)
  127.         fs.makeDir("users/"..user)
  128.         for id,paste in pairs(defaultPrograms) do
  129.             if fs.exists(id)==false then
  130.                 term.setCursorPos(1000,1)
  131.                 shell.run("pastebin","get",paste,id)
  132.             end
  133.             fs.copy(id,"users/"..user.."/"..id)        
  134.         end    
  135.         login(user)
  136.         return true
  137.     else
  138.         password=string.gsub(password," ","")
  139.         password=string.gsub(password,"\n","")
  140.         if password==pass then
  141.             login(user)
  142.             return true
  143.         else
  144.             return false
  145.         end
  146.     end
  147. end
  148.  
  149. function login(user)
  150.     currentUser=user
  151.     term.setCursorBlink(false)
  152.     loginDrawn=false
  153.     currentDirectory="users/"..currentUser
  154.     for id,paste in pairs(defaultPrograms) do
  155.         if fs.exists(id)==false then
  156.             term.setCursorPos(1000,1)
  157.             shell.run("pastebin","get",paste,id)
  158.         end
  159.         if not fs.exists("users/"..user.."/"..id) then
  160.             fs.copy(id,"users/"..user.."/"..id)
  161.         end
  162.     end    
  163.     drawDesktop()  
  164.     desktopEvents()
  165. end
  166.  
  167. function loginType(char)
  168.     x,y=term.getCursorPos()
  169.     screenX,screenY=term.getSize()
  170.     if y==math.floor(screenY/2+0) and #pass<=8  then
  171.         writeChar="*"
  172.         pass[#pass+1]=char
  173.     elseif #username<8 then
  174.         writeChar=char
  175.         username[#username+1]=char
  176.     end
  177.     term.setBackgroundColor(1)
  178.     term.write(writeChar)
  179. end
  180.  
  181. function loginTab()
  182.     x,y=term.getCursorPos()
  183.     screenX,screenY=term.getSize()
  184.     if y==screenY/2+0 then
  185.         term.setCursorPos(screenX/2-2,(screenY/2-2))
  186.     else
  187.         term.setCursorPos(screenX/2-2,(screenY/2+0))
  188.     end
  189. end
  190.  
  191. function loginBackspace()
  192.     x,y=term.getCursorPos()
  193.     screenX,screenY=term.getSize()
  194.     x,y=term.getCursorPos()
  195.     if x>=screenX/2-2 then
  196.         if y==screenY/2+4  then
  197.             usernameOld=username
  198.             username={}
  199.             for id,letter in ipairs(usernameOld) do
  200.                 if id~=#usernameOld then
  201.                     username[#username+1]=letter
  202.                 end
  203.             end
  204.         else
  205.             passOld=pass
  206.             pass={}
  207.             for id,letter in ipairs(passOld) do
  208.                 if id~=#passOld then
  209.                     pass[#pass+1]=letter
  210.                 end
  211.             end
  212.         end
  213.         term.setBackgroundColor(1)
  214.         x,y=term.getCursorPos()
  215.         term.setCursorPos(x-1,y)
  216.         term.write(" ")
  217.         term.setCursorPos(x-1,y)
  218.     end
  219. end
  220.  
  221. function drawDesktop()
  222.     if currentUser==nil then
  223.         loginEvents()
  224.     else
  225.         screenX,screenY=term.getSize()
  226.         term.setBackgroundColor(256)    --Taskbar on top of the screen
  227.         touchScreenTable={}
  228.         term.clear()
  229.         term.setCursorPos(1,1)
  230.         term.setBackgroundColor(128)
  231.         for i=1,screenX do
  232.             term.setCursorPos(i,1)
  233.             term.write(" ")
  234.             --term.setCursorPos(i,2)
  235.             --term.write(" ")
  236.         end
  237.         term.setCursorPos(1,1)
  238.         term.setTextColor(1)
  239.         term.setBackgroundColor(32)
  240.         term.write("Aperture OS")
  241.         touchScreenTable["menu"]={1,1,10,0,false,mainMenuFunction}
  242.         term.setBackgroundColor(128)
  243.         term.setCursorPos(screenX-10,1)
  244.         term.write(currentUser)
  245.        
  246.         term.setBackgroundColor(256)  --Programs section
  247.         programsList=fs.list(currentDirectory)  --Get the programs
  248.         programs={}
  249.         for id,program in ipairs(programsList) do
  250.             programs[#programs+1]=program  
  251.         end
  252.         term.setCursorPos(screenX-(screenX+10),5)
  253.         programsTable={}
  254.         screenX,screenY=term.getSize()
  255.         pStart=screenX*0.75
  256.         pWidth=screenX*0.6
  257.         pTextLength=(pWidth-2)/3
  258.         term.setBackgroundColor(128)
  259.        
  260.         if currentDirectory~="users/"..currentUser then --Get directory and draw back button
  261.             term.setBackgroundColor(128)
  262.             term.setCursorPos(screenX-20,screenY*0.9)
  263.             term.setTextColor(16384)
  264.             term.write("Home directory")
  265.             touchScreenTable["goToHome"]={screenX-20,screenY*0.9,screenX-6,5,false,backToMainDirectory}
  266.         else
  267.             touchScreenTable["goToHome"]=nil
  268.         end
  269.        
  270.         for id,data in ipairs(programs) do
  271.             if fs.isDir("users/"..currentUser.."/"..data) then  --Draw programs
  272.                 term.setTextColor(16)
  273.                 shellRunner=false
  274.             else
  275.                 term.setTextColor(32)
  276.                 shellRunner=true
  277.             end
  278.             rowID=math.ceil(id/3)
  279.             collumnID=id-rowID*3
  280.             programsTable[data]={pStart+((collumnID)*pTextLength+((collumnID)*1)),screenY*0.3+rowID*2,pStart+((collumnID)*pTextLength+((collumnID)*1))+pTextLength,1,shellRunner}
  281.             term.setCursorPos(pStart+((collumnID)*pTextLength+((collumnID)*1)),screenY*0.3+rowID*2)
  282.             if string.len(data)<pTextLength then
  283.                 for i=1,pTextLength-string.len(data) do
  284.                     data=data.." "                 
  285.                 end
  286.             end
  287.             term.write(string.sub(data,1,pTextLength))
  288.         end
  289.         term.setTextColor(1)
  290.         term.setBackgroundColor(256)
  291.         for id,data in pairs(programsTable) do
  292.             touchScreenTable[id]=data
  293.         end
  294.         term.setBackgroundColor(256)
  295.         term.setTextColor(1)
  296.         term.setCursorPos(1,2)
  297.     end    
  298. end
  299.  
  300. function relogin()
  301.     currentUser=nil drawLogin() loginEvents()
  302. end
  303.  
  304. function doDaShell()
  305.     drawShell()
  306.     inputShell()
  307. end
  308.  
  309. function editFileFunction(id)
  310.     shell.run("edit",currentDirectory.."/"..id)
  311.     touchScreenTable={}
  312.     fileManager()
  313. end
  314.  
  315. function editFile()
  316.     programsList=fs.list(currentDirectory)  --Get the programs
  317.     programs={}
  318.     for id,program in ipairs(programsList) do
  319.         programs[#programs+1]=program  
  320.     end
  321.     term.setCursorPos(screenX-(screenX+10),5)
  322.         programsTable={}
  323.     screenX,screenY=term.getSize()
  324.     pStart=screenX*0.75
  325.     pWidth=screenX*0.6
  326.     pTextLength=(pWidth-2)/3
  327.     term.setBackgroundColor(2)
  328.    
  329.     for id,data in ipairs(programs) do
  330.         if fs.isDir("users/"..currentUser.."/"..data) then  --Draw programs
  331.             term.setTextColor(256)
  332.             shellRunner=false
  333.         else
  334.             term.setTextColor(1)
  335.             shellRunner=true
  336.         end
  337.         rowID=math.ceil(id/3)
  338.         collumnID=id-rowID*3
  339.         programsTable[data]={pStart+((collumnID)*pTextLength+((collumnID)*1)),screenY*0.3+rowID*2,pStart+((collumnID)*pTextLength+((collumnID)*1))+pTextLength,1,false,editFileFunction}
  340.         term.setCursorPos(pStart+((collumnID)*pTextLength+((collumnID)*1)),screenY*0.3+rowID*2)
  341.             if string.len(data)<pTextLength then
  342.             for i=1,pTextLength-string.len(data) do
  343.                 data=data.." "                 
  344.             end
  345.         end
  346.         term.write(string.sub(data,1,pTextLength))
  347.     end
  348.     term.setTextColor(1)
  349.     term.setBackgroundColor(256)
  350.     for id,data in pairs(programsTable) do
  351.         touchScreenTable[id]=data
  352.     end
  353.     term.setBackgroundColor(256)
  354.     term.setTextColor(1)
  355.     term.setCursorPos(1,2)
  356. end
  357.  
  358. function drawFrompastebin()
  359.     touchScreenTable={}
  360.     screenX,screenY=term.getSize()
  361.     term.setTextColor(1)
  362.     for i=1,5 do
  363.         term.setCursorPos(screenX/2-5,i+screenY/2)
  364.         term.setBackgroundColor(128)
  365.         term.write("          ")       
  366.     end
  367.     term.setCursorPos(screenX/2-4,1+screenY/2)
  368.     term.write("Link    ")
  369.     term.setCursorPos(screenX/2-4,2+screenY/2)
  370.     term.setBackgroundColor(1)
  371.     term.write("        ")
  372.     term.setCursorPos(screenX/2-4,3+screenY/2)
  373.     term.setBackgroundColor(128)
  374.     term.write("fileName")
  375.     term.setCursorPos(screenX/2-4,4+screenY/2)
  376.     term.setBackgroundColor(1)
  377.     term.write("        ")
  378.     term.setCursorPos(screenX/2-4,4+screenY/2)
  379.     term.setBackgroundColor(1)
  380.     term.setTextColor(32768)
  381.     term.setCursorPos(screenX/2-4,2+screenY/2)
  382.     link=read()
  383.     term.setCursorPos(screenX/2-4,4+screenY/2)
  384.     fileName=read()
  385.     term.setCursorPos(screenX/2-10,screenY/2)
  386.     term.setBackgroundColor(256)
  387.     shell.run("pastebin","get",link,currentDirectory.."/"..fileName)
  388.     fileManager()
  389. end
  390.  
  391. function drawNewFile()
  392.     touchScreenTable={}
  393.     screenX,screenY=term.getSize()
  394.     term.setTextColor(1)
  395.     for i=1,5 do
  396.         term.setCursorPos(screenX/2-5,i+screenY/2)
  397.         term.setBackgroundColor(128)
  398.         term.write("          ")       
  399.     end
  400.     term.setCursorPos(screenX/2-4,2+screenY/2)
  401.     term.setBackgroundColor(128)
  402.     term.write("fileName")
  403.     term.setCursorPos(screenX/2-4,3+screenY/2)
  404.     term.setBackgroundColor(1)
  405.     term.write("        ")
  406.     term.setBackgroundColor(1)
  407.     term.setTextColor(32768)
  408.     term.setCursorPos(screenX/2-4,3+screenY/2)
  409.     fileName=read()
  410.     term.setCursorPos(screenX/2-20,screenY/2)
  411.     term.setBackgroundColor(128)
  412.     editFileFunction(fileName)
  413.     fileManager()
  414. end
  415.  
  416. function newFile()
  417.     touchScreenTable={}
  418.     screenX,screenY=term.getSize()
  419.     term.setTextColor(1)
  420.     for i=1,5 do
  421.         term.setCursorPos(screenX/2-5,i+screenY/2)
  422.         term.setBackgroundColor(128)
  423.         term.write("          ")       
  424.     end
  425.     term.setCursorPos(screenX/2-4,2+screenY/2)
  426.     term.setBackgroundColor(8)
  427.     term.write("Create  ")
  428.     term.setCursorPos(screenX/2-4,4+screenY/2)
  429.     term.write("Pastebin")
  430.     touchScreenTable['createNewFile']={screenX/2-4,2+screenY/2+2,screenX/2+4,1,false,drawFrompastebin}
  431.     touchScreenTable['fileFromPastebin']={screenX/2-4,2+screenY/2,screenX/2+4,1,false,drawNewFile}
  432.    
  433. end
  434.  
  435. function deleteFile(fileName)
  436.     fs.delete(currentDirectory.."/"..fileName)
  437.     touchScreenTable={}
  438.     fileManager()
  439. end
  440.  
  441. function delFile()
  442.     programsList=fs.list(currentDirectory)  --Get the programs
  443.     programs={}
  444.     for id,program in ipairs(programsList) do
  445.         programs[#programs+1]=program  
  446.     end
  447.     term.setCursorPos(screenX-(screenX+10),5)
  448.     programsTable={}
  449.     screenX,screenY=term.getSize()
  450.     pStart=screenX*0.75
  451.     pWidth=screenX*0.6
  452.         pTextLength=(pWidth-2)/3
  453.     term.setBackgroundColor(16384)
  454.    
  455.     for id,data in ipairs(programs) do
  456.         if fs.isDir("users/"..currentUser.."/"..data) then  --Draw programs
  457.             term.setTextColor(256)
  458.             shellRunner=false
  459.         else
  460.             term.setTextColor(1)
  461.             shellRunner=true
  462.             end
  463.         rowID=math.ceil(id/3)
  464.         collumnID=id-rowID*3
  465.         programsTable[data]={pStart+((collumnID)*pTextLength+((collumnID)*1)),screenY*0.3+rowID*2,pStart+((collumnID)*pTextLength+((collumnID)*1))+pTextLength,1,false,deleteFile}
  466.         term.setCursorPos(pStart+((collumnID)*pTextLength+((collumnID)*1)),screenY*0.3+rowID*2)
  467.             if string.len(data)<pTextLength then
  468.             for i=1,pTextLength-string.len(data) do
  469.                 data=data.." "                 
  470.             end
  471.         end
  472.         term.write(string.sub(data,1,pTextLength))
  473.     end
  474.     term.setTextColor(1)
  475.     term.setBackgroundColor(256)
  476.     for id,data in pairs(programsTable) do
  477.         touchScreenTable[id]=data
  478.     end
  479.     term.setBackgroundColor(256)
  480.     term.setTextColor(1)
  481.     term.setCursorPos(1,2)
  482. end
  483.  
  484. function backFile()
  485.     touchScreenTable={}
  486.     drawDesktop()
  487. end
  488.  
  489. function fileManager()
  490.     touchScreenTable={}
  491.     term.setTextColor(1)
  492.     term.setBackgroundColor(256)
  493.     term.clear()
  494.     term.setBackgroundColor(2)
  495.     for i=1,3 do
  496.         term.setCursorPos(3,i+1)
  497.         term.write("         ")
  498.         if i==2 then
  499.             term.setCursorPos(3,i+1)
  500.             term.write("   edit  ")
  501.         end
  502.     end
  503.     term.setBackgroundColor(32)
  504.     for i=1,3 do
  505.         term.setCursorPos(3,i+5)
  506.         term.write("         ")
  507.         if i==2 then
  508.             term.setCursorPos(3,i+5)
  509.             term.write("   new   ")
  510.         end
  511.     end
  512.     term.setBackgroundColor(16384)
  513.     for i=1,3 do
  514.         term.setCursorPos(3,i+9)
  515.         term.write("         ")
  516.         if i==2 then
  517.             term.setCursorPos(3,i+9)
  518.             term.write("  delete ")
  519.         end
  520.     end
  521.    
  522.     term.setBackgroundColor(128)
  523.     for i=1,3 do
  524.         term.setCursorPos(3,i+13)
  525.         term.write("         ")
  526.         if i==2 then
  527.             term.setCursorPos(3,i+13)
  528.             term.write("   back  ")
  529.         end
  530.     end
  531.    
  532.     touchScreenTable["edit"]={2,2,11,3,false,editFile}
  533.     touchScreenTable["new"]={2,6,11,3,false,newFile}
  534.     touchScreenTable["del"]={2,10,11,3,false,delFile}
  535.     touchScreenTable["back"]={2,14,11,3,false,backFile}
  536.    
  537.     --drawDesktop()
  538. end
  539.  
  540. mainMenuItems={
  541. ["Shut down"]={['c']=16384,['f']=os.shutdown},
  542. ["Reboot"]={['c']=32,['f']=os.reboot},
  543. ["Log off"]={['c']=2,['f']=relogin},
  544. ["BASH Shell"]={['c']=8,['f']=doDaShell},
  545. ["Programs"]={['c']=8192,['f']=fileManager},
  546. }
  547.  
  548. function mainMenuFunction()
  549.     if mainmenuShown==nil then
  550.         mainmenuShown=false
  551.     end
  552.    
  553.     if mainmenuShown==true then
  554.         touchScreenTable={}
  555.         drawDesktop()
  556.     else
  557.         term.setBackgroundColor(128)
  558.         for i=1,6 do
  559.             term.setCursorPos(1,i+1)
  560.             term.write("          ")
  561.         end
  562.         term.setBackgroundColor(128)
  563.         i=2
  564.         for name,data in pairs(mainMenuItems) do
  565.             term.setCursorPos(1,i)
  566.             term.setTextColor(data['c'])
  567.             nameLength=string.len(name)
  568.             if nameLength<9 then
  569.                 for g=1,9-nameLength do
  570.                     name=name.." "
  571.                 end
  572.             end
  573.             term.write(name)
  574.             if data['f']==nil then
  575.                 touchScreenTable[name]={1,i,9,0,true}
  576.             else
  577.                 touchScreenTable[name]={1,i,9,0,false,data['f']}
  578.             end
  579.             i=i+1
  580.         end
  581.     end
  582.     mainmenuShown=not mainmenuShown
  583. end
  584.  
  585. function backToMainDirectory()
  586.     currentDirectory="users/"..currentUser
  587.     print("Main Directory")
  588.     drawDesktop()  
  589. end
  590.  
  591. function desktopEvents()
  592.     while true do
  593.         event,v1,v2,v3,v4,v5=os.pullEvent()
  594.         if event=="mouse_click" then
  595.             button=v1
  596.             x=v2
  597.             y=v3
  598.             for id,data in pairs(touchScreenTable) do
  599.                 if button==1 and x>=math.floor(data[1]) and x<=math.floor(data[3]) and y>=math.floor(data[2]) and y<=math.floor(data[2]+data[4])  then
  600.                     if data[5] then
  601.                         termDisabled=false
  602.                         shell.run(currentDirectory.."/"..id)
  603.                         drawDesktop()
  604.                         termDisabled=true
  605.                     elseif fs.isDir(currentDirectory.."/"..id) then
  606.                         currentDirectory="users/"..currentUser.."/"..id
  607.                         drawDesktop()
  608.                         termDisabled=true
  609.                     else
  610.                         termDisabled=false
  611.                         data[6](id)
  612.                         termDisabled=true
  613.                     end
  614.                        
  615.                 end
  616.             end
  617.         elseif event=="char" then
  618.            
  619.         elseif event=="key" then
  620.            
  621.         end
  622.     end
  623. end
  624.  
  625. --NanoShell
  626.  
  627. function drawShell()
  628.     term.setBackgroundColor(128)
  629.     for i=2,19 do
  630.         term.setCursorPos(1,i)
  631.         if i==2 then
  632.             term.write(" BASH Shell                        ")
  633.         else
  634.             term.write("                                   ")
  635.         end
  636.     end
  637.     term.setBackgroundColor(32768)
  638.     for i=3,18 do
  639.         term.setCursorPos(2,i)
  640.         term.write("                                ")
  641.     end
  642.     term.setCursorPos(2,3)
  643.     term.setTextColor(1)
  644. end
  645.  
  646. function inputShell()
  647.     term.setCursorPos(2,3)
  648.     term.setTextColor(1)
  649.     repeat
  650.         command=read()
  651.         x,y=term.getCursorPos()
  652.        
  653.         if string.find(command,"edit")~=nil then
  654.             command=string.gsub(command,"edit ","edit "..currentDirectory.."/")
  655.             term.write(command)
  656.         elseif string.find(command,"list")~=nil then
  657.             command=string.gsub(command,"list","list "..currentDirectory)
  658.         elseif string.find(command,"lua")~=nil then
  659.             command=nil
  660.             print("Access Denied")
  661.         end
  662.         if  string.find(command,"edit")~=nil then
  663.             shell.run(command)
  664.             term.setCursorPos(2,y+1)
  665.             drawDesktop()
  666.             drawShell()
  667.         elseif string.find(command,"list")~=nil then
  668.             programs=fs.list(currentDirectory)
  669.             ox,oy=term.getCursorPos()
  670.             term.setCursorPos(2,oy)
  671.             for id,program in pairs(programs) do
  672.                 term.write(program.." ")
  673.             end
  674.             term.setCursorPos(2,oy+1)
  675.         elseif command~=nil and command~="stop" and fs.exists(currentDirectory.."/"..command) then
  676.             returned=shell.run(currentDirectory.."/"..command)
  677.             term.setCursorPos(2,y+1)
  678.         else
  679.             if y>=17 then
  680.                 drawShell()
  681.                 term.setCursorPos(2,3)
  682.             else
  683.                 term.setCursorPos(2,y)
  684.                 term.write("No such program")
  685.                 term.setCursorPos(2,y+1)
  686.             end
  687.         end
  688.        
  689.     until command=="stop"
  690.     drawDesktop()
  691. end
  692.  
  693. function startOS()
  694. user = Utente
  695. pass = proprietario
  696.     drawDesktop()
  697. end
  698.  
  699. startOS()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement