Advertisement
MC403

SJNOS-Terminal

Sep 21st, 2014
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.85 KB | None | 0 0
  1. --SJNOS by MC403. terminal.exe (GdZsddz6)
  2.  
  3. local w, h = term.getSize()
  4.  
  5. local tArgs = {...}
  6.  
  7. local COLOR_WD = colors.orange
  8. local COLOR_READ = colors.cyan
  9. local COLOR_DOLLAR = colors.cyan
  10. local COLOR_BG = colors.gray
  11. local COLOR_OUTPUT = colors.lightGray
  12. local COLOR_ERROR = colors.red
  13. local COLOR_WARNING = colors.yellow
  14. local COLOR_OK = colors.lime
  15. local COLOR_EXIT = colors.magenta
  16. local COLOR_FILE = colors.white
  17. local COLOR_DIR = colors.lightBlue
  18. local COLOR_READONLY_FILE = colors.yellow
  19. local COLOR_READONLY_DIR = colors.yellow
  20. local COLOR_SHELL = colors.white
  21.  
  22. local function start()
  23.     if term.isColor() then
  24.         local USERNAME = ""
  25.         for i=1,#fs.list("SJNOS/users") do
  26.             if tArgs[1]==fs.list("SJNOS/users")[i] then
  27.                 USERNAME = tArgs[1]
  28.             end
  29.         end
  30.         if USERNAME=="" then
  31.             error("Undifined Username")
  32.         end
  33.        
  34.         f = fs.open("SJNOS/users/"..USERNAME.."/config/.config","r")
  35.         f.readLine()
  36.         f.readLine()
  37.         f.readLine()
  38.         local USERRANK = f.readLine()
  39.         USERRANK = string.sub(USERRANK,string.find(USERRANK,"=")+1)
  40.        
  41.         f = fs.open("SJNOS/settings/name.set","r")
  42.         local PCNAME = f.readLine()
  43.         PCNAME = string.sub(PCNAME,string.find(PCNAME,"=")+1)
  44.                
  45.  
  46.         term.setBackgroundColor(COLOR_BG)
  47.         term.clear()
  48.         term.setCursorPos(1,1)
  49.  
  50.         local workingDir = "SJNOS/users/"..USERNAME.."/home"
  51.         local display = "~"
  52.        
  53.         local done = false
  54.        
  55.         while not done do
  56.             if workingDir=="SJNOS/users/"..USERNAME.."/home" then
  57.                 display = "~"
  58.             end
  59.            
  60.             term.setTextColor(COLOR_WD)
  61.             write(USERNAME.."@"..PCNAME..":"..display)
  62.             term.setTextColor(COLOR_DOLLAR)
  63.             write(" $ ")
  64.             term.setTextColor(COLOR_READ)
  65.             local input = read()
  66.            
  67.             term.setTextColor(COLOR_OUTPUT)
  68.             if input=="exit" then
  69.                 term.setTextColor(COLOR_EXIT)
  70.                 write("Exit")
  71.                 sleep(0.5)
  72.                 done = true
  73.                 term.setTextColor(colors.white)
  74.                 term.setBackgroundColor(colors.black)
  75.                 term.setCursorPos(1,1)
  76.                 term.clear()
  77.             elseif input=="terminal" then
  78.                 term.setBackgroundColor(COLOR_BG)
  79.                 term.setCursorPos(1,1)
  80.                 term.clear()
  81.                 workingDir = "SJNOS/users/"..USERNAME.."/home"
  82.                 display = "~"
  83.             elseif input=="ver" then
  84.                 f = fs.open("SJNOS/system/about/ver.txt","r")
  85.                 local ver = f.readLine()
  86.                 ver = string.sub(ver,string.find(ver,"=")+1)
  87.                 local status = f.readLine()
  88.                 status = string.sub(status,string.find(status,"=")+1)
  89.                 f.close()
  90.                 print("v"..ver.." "..status)
  91.             elseif input=="pwd" then
  92.                 print(workingDir)
  93.             elseif input=="rednet" or string.find(input,"rednet ")==1 then
  94.                 local args = string.sub(input,8)
  95.                
  96.                 local arg1End = string.find(args," ")
  97.                 if arg1End == nil then arg1End = #args+1 end
  98.                 local arg1 = string.sub(args,1,arg1End-1)
  99.                 local argRest = string.sub(args,arg1End+1)
  100.                 local arg2End = string.find(argRest," ")
  101.                 if arg2End == nil then arg2End = #argRest+1 end
  102.                 local arg2 = string.sub(argRest,1,arg2End-1)
  103.                 local arg3 = string.sub(argRest,arg2End+1)
  104.                
  105.                 if arg1=="-s" then
  106.                     --Send
  107.                     local receiver = tonumber(arg2)
  108.                     if receiver ~= nil then
  109.                         if receiver >= 0 then
  110.                             rednet.send(receiver,arg3)
  111.                             print("["..textutils.formatTime(os.time(),true).."]: Message has been send to "..receiver..".")
  112.                         else
  113.                             term.setTextColor(COLOR_ERROR)
  114.                             print("No valid receiver")
  115.                         end
  116.                     else
  117.                         term.setTextColor(COLOR_ERROR)
  118.                         print("No valid receiver")
  119.                     end
  120.                 elseif arg1 == "-r" then
  121.                     --Receive
  122.                    
  123.                     local timer = arg2
  124.                     local sender = arg3
  125.                    
  126.                     if timer ~= nil and timer~="" then
  127.                         if tonumber(timer)~=nil then
  128.                             --Time limit
  129.                             if sender ~= nil and sender ~="" then
  130.                                 if tonumber(sender)~=nil then
  131.                                     --Valid sender
  132.                                     print("Press [C] to terminate!")
  133.                                     local clocker = os.startTimer(tonumber(timer))
  134.                                     while true do
  135.                                         local event, side, channel, id, msg, dis = os.pullEventRaw()
  136.                                         if event=="key" and side==46 then
  137.                                             term.setTextColor(COLOR_WARNING)
  138.                                             print("Canceled.")
  139.                                             break
  140.                                         elseif event=="modem_message" and id==sender then
  141.                                             term.setTextColor(COLOR_OK)
  142.                                             print("["..textutils.formatTime(os.time(),true).."]: "..id.."> "..msg)
  143.                                             break
  144.                                         elseif event=="timer" and side==clocker then
  145.                                             term.setTextColor(COLOR_WARNING)
  146.                                             print("Timer finished.")
  147.                                             break
  148.                                         end
  149.                                     end
  150.                                     clocker = nil
  151.                                 else
  152.                                     term.setTextColor(COLOR_ERROR)
  153.                                     print("Sender not valid")
  154.                                 end
  155.                             else
  156.                                 --No sender
  157.                                 print("Press [C] to terminate!")
  158.                                 local clocker = os.startTimer(tonumber(timer))
  159.                                 while true do
  160.                                     local event, side, channel, id, msg, dis = os.pullEventRaw()
  161.                                     if event=="key" and side==46 then
  162.                                         term.setTextColor(COLOR_WARNING)
  163.                                         print("Canceled.")
  164.                                         break
  165.                                     elseif event=="modem_message" then
  166.                                         term.setTextColor(COLOR_OK)
  167.                                         print("["..textutils.formatTime(os.time(),true).."]: "..id.."> "..msg)
  168.                                         break
  169.                                     elseif event=="timer" and side==clocker then
  170.                                         term.setTextColor(COLOR_WARNING)
  171.                                         print("Timer finished.")
  172.                                         break
  173.                                     end
  174.                                 end
  175.                                 clocker = nil
  176.                             end
  177.                         else
  178.                             term.setTextColor(COLOR_ERROR)
  179.                             print("Time not valid")
  180.                         end
  181.                     else
  182.                         --No time limit
  183.                         if sender ~= nil and sender ~="" then
  184.                             if tonumber(sender)~=nil then
  185.                                 --Valid Sender
  186.                                 print("Press [C] to terminate!")
  187.                                 while true do
  188.                                     local event, side, channel, id, msg, dis = os.pullEventRaw()
  189.                                     if event=="key" and side==46 then
  190.                                         term.setTextColor(COLOR_WARNING)
  191.                                         print("Canceled.")
  192.                                         break
  193.                                     elseif event=="modem_message" and id==sender then
  194.                                         term.setTextColor(COLOR_OK)
  195.                                         print("["..textutils.formatTime(os.time(),true).."]: "..id.."> "..msg)
  196.                                         break
  197.                                     elseif event=="timer" and side==clocker then
  198.                                         term.setTextColor(COLOR_WARNING)
  199.                                         print("Timer finished.")
  200.                                         break
  201.                                     end
  202.                                 end
  203.                             else
  204.                                 --No valid sender
  205.                                 term.setTextColor(COLOR_ERROR)
  206.                                 print("Sender not valid")
  207.                             end
  208.                         else
  209.                             --No sender
  210.                             print("Press [C] to terminate!")
  211.                             while true do
  212.                                 local event, side, channel, id, msg, dis = os.pullEventRaw()
  213.                                 if event=="key" and side==46 then
  214.                                     term.setTextColor(COLOR_WARNING)
  215.                                     print("Canceled.")
  216.                                     break
  217.                                 elseif event=="modem_message" then
  218.                                     term.setTextColor(COLOR_OK)
  219.                                     print("["..textutils.formatTime(os.time(),true).."]: "..id.."> "..msg)
  220.                                     break
  221.                                 end
  222.                             end
  223.                         end
  224.                     end
  225.                 else
  226.                     term.setTextColor(COLOR_ERROR)
  227.                     print("Invalid Arguments. Try $help rednet")
  228.                 end
  229.             elseif input=="time" then
  230.                 print("Day "..os.day().." "..textutils.formatTime(os.time(),false))
  231.             elseif input=="help" or string.find(input,"help ") then
  232.                 if input == "help" then
  233.                     print("$cd                 : Change Directory -> $help cd ")
  234.                     print("$clear              : Clears the Screen            ")
  235.                     print("$exit               : Exit                         ")
  236.                     print("$help               : Help                         ")
  237.                     print("$ls                 : List -> $help ls             ")
  238.                     print("$pwd                : Print Working Directory      ")
  239.                     print("$terminal           : Reset the terminal           ")
  240.                     print("$ver                : Shows the version of SJNOS   ")
  241.                 else
  242.                     local args = string.sub(input,6)
  243.                     local arg1End = string.find(args," ")
  244.                     if arg1End == nil then arg1End = #args+1 end
  245.                     local arg1 = string.sub(args,1,arg1End-1)
  246.                     local arg2 = string.sub(args,arg1End+1)
  247.                    
  248.                     if arg1 == "cd" then
  249.                         print("CHANGE DIRECTORY")
  250.                         print("Usage: $cd <path>")
  251.                         print("path: DIRECTORY")
  252.                         print("$cd .. -> One Level higher")
  253.                         print("")
  254.                         print("$cd @ROOT  = Highest Level")
  255.                         print("$cd @HOME  = SJNOS/users/<your name>/home")
  256.                         print("$cd @USERS = SJNOS/users")
  257.                         print("$cd @ROM   = rom")
  258.                         print("$cd ~      = @HOME")
  259.                         print("$cd /      = @ROOT")
  260.                     end
  261.                 end
  262.             elseif input=="clear" then
  263.                 term.setBackgroundColor(COLOR_BG)
  264.                 term.setCursorPos(1,1)
  265.                 term.clear()
  266.             elseif input=="run" or string.find(input,"run ")==1 then
  267.                 local args = string.sub(input,5)
  268.                 local arg1End = string.find(args," ")
  269.                 if arg1End == nil then arg1End = #args+1 end
  270.                 local arg1 = string.sub(args,1,arg1End-1)
  271.                 local arg2 = string.sub(args,arg1End+1)
  272.                
  273.                 if arg1~=nil and arg1~="" then
  274.                     if fs.exists(workingDir.."/"..arg1) then
  275.                         if not fs.isDir(workingDir.."/"..arg1) then
  276.                             term.setTextColor(COLOR_WARNING)
  277.                             print("Are you sure to run the following File?")
  278.                             term.setTextColor(COLOR_OK)
  279.                             print('"'..workingDir.."/"..arg1..'"')
  280.                             term.setTextColor(COLOR_WD)
  281.                             write("[y/n] > ")
  282.                             term.setTextColor(COLOR_READ)
  283.                             local i = read()
  284.                             if i=="y" then
  285.                                 term.setTextColor(COLOR_SHELL)
  286.                                 shell.run(workingDir.."/"..arg1)
  287.                                 term.setTextColor(COLOR_OUTPUT)
  288.                                 term.setBackgroundColor(COLOR_BG)
  289.                                 print("[Press any key to continue!]")
  290.                                 os.pullEventRaw("key")
  291.                             end
  292.                         else
  293.                             term.setTextColor(COLOR_ERROR)
  294.                             print("Can't run a directory.")
  295.                         end
  296.                     else
  297.                         term.setTextColor(COLOR_ERROR)
  298.                         print("File does not exists!")
  299.                     end
  300.                 else
  301.                     term.setTextColor(COLOR_ERROR)
  302.                     print("Usage: $ run <file>")
  303.                 end
  304.             elseif string.find(input,"cd ")==1 then
  305.                 local args = string.sub(input,4)
  306.                 local arg1End = string.find(args," ")
  307.                 if arg1End == nil then arg1End = #args+1 end
  308.                 local arg1 = string.sub(args,1,arg1End-1)
  309.                 local arg2 = string.sub(args,arg1End+1)
  310.                
  311.                
  312.                 if arg1=="/" or arg1=="@ROOT" then
  313.                     if USERRANK == "a" then
  314.                         workingDir = ""
  315.                         display = workingDir
  316.                     else
  317.                         term.setTextColor(COLOR_ERROR)
  318.                         print("This path is only accessible for an Administrator.")
  319.                     end
  320.                 elseif arg1=="~" or arg1=="@HOME" then
  321.                     workingDir = "SJNOS/users/"..USERNAME.."/home"
  322.                     display = "~"
  323.                 elseif arg1=="@USERS" then
  324.                     if USERRANK == "a" then
  325.                         workingDir = "SJNOS/users"
  326.                         display = workingDir
  327.                     else
  328.                         term.setTextColor(COLOR_ERROR)
  329.                         print("This path is only accessible for an Administrator.")
  330.                     end
  331.                 elseif arg1=="@ROM" then
  332.                     workingDir = "rom"
  333.                     display = workingDir
  334.                 elseif arg1~="" then
  335.                     local now = arg1
  336.                     local rest = arg1
  337.                     local r = true
  338.                     while r do
  339.                         local i1 = string.find(rest,"/")
  340.                         if i1==nil then
  341.                             now = string.sub(rest,1)
  342.                             r = false
  343.                         else
  344.                             now = string.sub(rest,1,i1-1)
  345.                             rest = string.sub(rest,i1+1)
  346.                         end
  347.                        
  348.                        
  349.                         if #now==2 and string.sub(now,1,1)=="." and string.sub(now,2,2)=="." then
  350.                             -- ..
  351.                             if workingDir=="" then
  352.                                 term.setTextColor(COLOR_ERROR)
  353.                                 print("You are at the highest level.")
  354.                                 r = false
  355.                             elseif workingDir=="SJNOS/users/"..USERNAME.."/home" then
  356.                                 if USERRANK=="a" then
  357.                                     workingDir = "SJNOS/users/"..USERNAME
  358.                                     display = workingDir
  359.                                 else
  360.                                     term.setTextColor(COLOR_ERROR)
  361.                                     print("This path is only accessible for an Administrator.")
  362.                                     r = false
  363.                                 end
  364.                             else
  365.                                 local s1 = string.reverse(workingDir)
  366.                                 local i1 = string.find(s1,"/")
  367.                                 if i1~=nil then
  368.                                     local i2 = #workingDir
  369.                                     local i3 = i2 - i1
  370.                                     local s2 = string.sub(s1,i1+1)
  371.                                     local s3 = string.reverse(s2)
  372.                                     workingDir = s3
  373.                                 else
  374.                                     workingDir = ""
  375.                                 end
  376.                                                                    
  377.                                 if string.find(workingDir,"SJNOS/users/"..USERNAME.."/home")==1 then
  378.                                     local t1, t2 = string.find(workingDir,"SJNOS/users/"..USERNAME.."/home")
  379.                                     local t3 = string.sub(workingDir,t2+1)
  380.                                     display = "~"..t3
  381.                                 else
  382.                                     display = workingDir
  383.                                 end
  384.                             end
  385.                         else
  386.                             -- No ..
  387.                             if fs.exists(workingDir.."/"..now) then
  388.                                 if fs.isDir(workingDir.."/"..now) then
  389.                                     workingDir = workingDir.."/"..now
  390.                                     if string.find(workingDir,"SJNOS/users/"..USERNAME.."/home")==1 then
  391.                                         local t1, t2 = string.find(workingDir,"SJNOS/users/"..USERNAME.."/home")
  392.                                         local t3 = string.sub(workingDir,t2+1)
  393.                                         display = "~"..t3
  394.                                     else
  395.                                         display = workingDir
  396.                                     end
  397.                                 else
  398.                                     term.setTextColor(COLOR_ERROR)
  399.                                     print("Not a directory.")
  400.                                     r = false
  401.                                 end
  402.                             else
  403.                                 term.setTextColor(COLOR_ERROR)
  404.                                 print("This path doesnot exists.")
  405.                                 r = false
  406.                             end
  407.                         end
  408.                     end
  409.                 end
  410.             elseif string.find(input,"ls ")==1 or input=="ls" then
  411.                 ------------------------------------------
  412.                 local args = string.sub(input,4)
  413.                 local arg1End = string.find(args," ")
  414.                 if arg1End == nil then arg1End = #args+1 end
  415.                 local arg1 = string.sub(args,1,arg1End-1)
  416.                 local arg2 = string.sub(args,arg1End+1)
  417.                
  418.                 local function show(path)
  419.                     if fs.exists(path) then
  420.                         local list = fs.list(path)
  421.                        
  422.                         local readonlydirs = {}
  423.                         local dirs = {}
  424.                         local readonlyfiles = {}
  425.                         local files = {}
  426.  
  427.                         for i=1,#list do
  428.                             local path_list
  429.                             if path=="" then
  430.                                 path_list = list[i]
  431.                             else
  432.                                 path_list = path.."/"..list[i]
  433.                             end
  434.                            
  435.                             if fs.isReadOnly(path_list) then
  436.                                 if fs.isDir(path_list) then
  437.                                     table.insert(readonlydirs,list[i])
  438.                                 else
  439.                                     table.insert(readonlyfiles,list[i])
  440.                                 end
  441.                             else
  442.                                 if fs.isDir(path_list) then
  443.                                     table.insert(dirs,list[i])
  444.                                 else
  445.                                     table.insert(files,list[i])
  446.                                 end
  447.                             end
  448.                         end
  449.                        
  450.                         term.setTextColor(COLOR_READONLY_DIR)
  451.                         for i=1,#readonlydirs do
  452.                             print(readonlydirs[i])
  453.                         end
  454.  
  455.                         term.setTextColor(COLOR_DIR)
  456.                         for i=1,#dirs do
  457.                             print(dirs[i])
  458.                         end
  459.  
  460.                         term.setTextColor(COLOR_READONLY_FILE)
  461.                         for i=1,#readonlyfiles do
  462.                             print(readonlyfiles[i])
  463.                         end
  464.  
  465.                         term.setTextColor(COLOR_FILE)
  466.                         for i=1,#files do
  467.                             print(files[i])
  468.                         end
  469.                        
  470.                         --[[
  471.                         for i=1,#list do
  472.                             local path_list
  473.                             if path=="" then
  474.                                 path_list = list[i]
  475.                             else
  476.                                 path_list = path.."/"..list[i]
  477.                             end
  478.                            
  479.                             if fs.isReadOnly(path_list) then
  480.                                 if fs.isDir(path_list) then
  481.                                     term.setTextColor(COLOR_READONLY_DIR)
  482.                                 else
  483.                                     term.setTextColor(COLOR_READONLY_FILE)
  484.                                 end
  485.                             else
  486.                                 if fs.isDir(path_list) then
  487.                                     term.setTextColor(COLOR_DIR)
  488.                                 else
  489.                                     term.setTextColor(COLOR_FILE)
  490.                                 end
  491.                             end
  492.                             print(list[i])
  493.                         end--]]
  494.                     else
  495.                         term.setTextColor(COLOR_ERROR)
  496.                         print("Path does not exists!")
  497.                     end
  498.                 end
  499.                
  500.                 if arg1=="/" or arg1=="@ROOT" then
  501.                     if USERRANK == "a" then
  502.                         show("")
  503.                     else
  504.                         term.setTextColor(COLOR_ERROR)
  505.                         print("This path is only accessible for an Administrator.")
  506.                     end
  507.                 elseif arg1=="@HOME" then
  508.                     show("SJNOS/users/"..USERNAME.."/home")
  509.                 elseif arg1=="@USERS" then
  510.                     if USERRANK == "a" then
  511.                         show("SJNOS/users")
  512.                     else
  513.                         term.setTextColor(COLOR_ERROR)
  514.                         print("This path is only accessible for an Administrator.")
  515.                     end
  516.                 elseif arg1=="@PLUGINS" then
  517.                     if USERRANK == "a" then
  518.                         show("SJNOS/plugins")
  519.                     else
  520.                         term.setTextColor(COLOR_ERROR)
  521.                         print("This path is only accessible for an Administrator.")
  522.                     end
  523.                 elseif arg1=="@ROM" then
  524.                     show("rom")
  525.                 elseif arg1=="" then
  526.                     show(workingDir)
  527.                 else
  528.                
  529.                     local destination = workingDir
  530.                    
  531.                     local function setDest(d)
  532.                         DESTINATION = d
  533.                     end
  534.                    
  535.                     local now = arg1
  536.                     local rest = arg1
  537.                     local r = true
  538.                     while r do
  539.                         local i1 = string.find(rest,"/")
  540.                         if i1==nil then
  541.                             now = string.sub(rest,1)
  542.                             r = false
  543.                         else
  544.                             now = string.sub(rest,1,i1-1)
  545.                             rest = string.sub(rest,i1+1)
  546.                         end
  547.                        
  548.                        
  549.                         if #now==2 and string.sub(now,1,1)=="." and string.sub(now,2,2)=="." then
  550.                             -- ..
  551.                             if workingDir=="" then
  552.                                 term.setTextColor(COLOR_ERROR)
  553.                                 print("You are at the highest level.")
  554.                                 r = false
  555.                             elseif workingDir=="SJNOS/users/"..USERNAME.."/home" then
  556.                                 if USERRANK=="a" then
  557.                                     setDest("SJNOS/users/"..USERNAME)
  558.                                 else
  559.                                     term.setTextColor(COLOR_ERROR)
  560.                                     print("This path is only accessible for an Administrator.")
  561.                                     r = false
  562.                                 end
  563.                             else
  564.                                 local s1 = string.reverse(workingDir)
  565.                                 local i1 = string.find(s1,"/")
  566.                                 if i1~=nil then
  567.                                     local i2 = #workingDir
  568.                                     local i3 = i2 - i1
  569.                                     local s2 = string.sub(s1,i1+1)
  570.                                     local s3 = string.reverse(s2)
  571.                                     setDest(s3)
  572.                                 else
  573.                                     setDest("")
  574.                                 end                                                                    
  575.                             end
  576.                         else
  577.                             -- No ..
  578.                             if fs.exists(workingDir.."/"..now) then
  579.                                 setDest(workingDir.."/"..now)
  580.                             else
  581.                                 term.setTextColor(COLOR_ERROR)
  582.                                 print("This path doesnot exists.")
  583.                                 r = false
  584.                             end
  585.                         end
  586.                     end
  587.                     show(destination)
  588.                     ------------------------------------------
  589.                 end
  590.             elseif input~="" and input~=" " then
  591.                 term.setTextColor(COLOR_ERROR)
  592.                 print("This Command does not exist. Try $help.")
  593.             end
  594.         end
  595.     end
  596.     return true
  597. end
  598.  
  599. local ok, err = pcall(start)
  600. if not ok then
  601.     local function draw()f = fs.open(".errimg","w") f.writeLine("000000000000000000000000010000000000000000000000000") local w,h = term.getSize()
  602.     f.writeLine("000000000000000000000000111000000000000000000000000") f.writeLine("0000000000000000000000011f1100000000000000000000000")
  603.     f.writeLine("0000000000000000000000111f1110000000000000000000000") f.writeLine("0000000000000000000001111f1111000000000000000000000")
  604.     f.writeLine("000000000000000000001111111111100000000000000000000") f.writeLine("0000000000000000000111111f1111110000000000000000000")
  605.     f.writeLine("000000000000000000111111111111111000000000000000000") f.close() term.setBackgroundColor(colors.white) term.setTextColor(colors.cyan)
  606.     term.clear() img = paintutils.loadImage(".errimg") paintutils.drawImage(img,1,3) term.setBackgroundColor(colors.white) term.setCursorPos(1,1)
  607.     write("SJNOS ERROR") term.setCursorPos(47,1) write(textutils.formatTime(os.time(),true)) term.setTextColor(colors.black) fs.delete(".errimg")
  608.     term.setCursorPos((w-string.len("Oh No! Something went horribly wrong! :("))/2,12) write("Oh No! Something went horribly wrong :(")
  609.     term.setTextColor(colors.red) local error = {err} if #err > 40 then error[1] = string.sub(err,0,39) error[2] = string.sub(err,40) term.setCursorPos(1,1)
  610.     end for i=1,#error do term.setCursorPos((w-string.len(error[i]))/2,13+i) write(error[i]) end term.setBackgroundColor(colors.orange)
  611.     term.setTextColor(colors.black) startcoos = 17 term.setCursorPos(startcoos,18) write("Reboot") term.setCursorPos(startcoos+7,18) write("Edit")
  612.     term.setCursorPos(startcoos+12,18) write("Exit") end draw() local finished = false while not finished do local event, btn, x, y = os.pullEvent()
  613.     if event=="mouse_click" and btn==1 and y==18 then if x>=startcoos and x<=startcoos+6 then finished = true os.reboot()
  614.     elseif x>=startcoos+8 and x<=startcoos+11 then shell.run("edit",shell.getRunningProgram()) draw() elseif x>=startcoos+13 and x<=startcoos+16 then
  615.     finished = true term.setBackgroundColor(colors.white) term.setTextColor(colors.cyan) term.clear() term.setCursorPos(1,1) shell.run("startup") end end end
  616. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement