Advertisement
Virgilcore

RobcOS v1.1.3

Jun 9th, 2022 (edited)
1,043
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.13 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. --Load Config Data.--
  3. function load(name)
  4. local file = fs.open(name,"r")
  5. local data = file.readAll()
  6. file.close()
  7. return textutils.unserialize(data)
  8. end
  9. --Set the Computer name variable from Config--
  10. function LoadName()
  11.   local config = load("RobcOS_ticket")
  12.   return config[1]
  13. end
  14.  
  15. --CONFIG SETTINGS--
  16. local Name = LoadName()
  17. local ready = fs.exists("RobcOS_ticket")
  18. --END OF CONFIG--
  19.  
  20. local mainpglines = {"Files", "Setup", "Misc", "Reboot", "Shutdown", "Check For Updates"}
  21. local funpglines = {"Game: Snake", "Utility: Chat System", "1.16+: Play Music", "Return"}
  22.  
  23. function WriteHeader(PcName)
  24. term.clear()
  25. term.setCursorPos(5, 1)
  26. term.write("ROBCO INDUSTRIES UNIFIED OPERATING SYSTEM")
  27. term.setCursorPos(7, 2)
  28. term.write("COPYRIGHT 2075-2077 ROBCO INDUSTRIES")
  29. term.setCursorPos(20, 3)
  30. term.write(PcName)
  31. end
  32.  
  33. function WriteMainPage()
  34.     term.setCursorPos(5, 6)
  35.     term.write(mainpglines[1])
  36.     term.setCursorPos(5, 7)
  37.     term.write(mainpglines[2])
  38.     term.setCursorPos(5, 8)
  39.     term.write(mainpglines[3])
  40.     term.setCursorPos(5, 9)
  41.     term.write(mainpglines[4])
  42.     term.setCursorPos(5, 10)
  43.     term.write(mainpglines[5])
  44.     term.setCursorPos(5, 11)
  45.     term.write(mainpglines[6])
  46. end
  47.  
  48. function WriteFunPage()
  49.     term.setCursorPos(5, 6)
  50.     term.write(funpglines[1])
  51.     term.setCursorPos(5, 7)
  52.     term.write(funpglines[2])
  53.     term.setCursorPos(5, 8)
  54.     term.write(funpglines[3])
  55.     term.setCursorPos(5, 9)
  56.     term.write(funpglines[4])
  57. end
  58.  
  59.  
  60.  
  61. function WriteSelectedLabel(x,y,table)
  62.     local number = (y - 5)
  63.     local page = table[number]
  64.     term.setCursorPos(x, y)
  65.     term.write(page)
  66. end
  67.  
  68. function PlayMusic()
  69.     term.setCursorPos(1, 1)
  70.     term.setTextColor(colors.green)
  71.     term.setBackgroundColor(colors.black)
  72.     term.clear()
  73.     term.write("Enter .dfpwm file URL")
  74.     term.setCursorPos(1, 2)
  75.     input = read()
  76.     shell.run("speaker", "play", input)
  77. end
  78.  
  79. function SelectorFun()
  80.     local x, y = 5, 6
  81.  
  82.  
  83. local xSize, ySize = term.getSize()
  84.  
  85.     while true do
  86.         -- Draw a white space at the current x/y co-ord:
  87.         term.setBackgroundColor(colours.black)
  88.         term.setTextColor(colours.green)
  89.         term.clear()
  90.         WriteHeader(Name)
  91.         WriteFunPage()
  92.         term.setCursorPos(x, y)
  93.         term.setBackgroundColor(colours.green)
  94.         term.setTextColor(colours.black)
  95.         WriteSelectedLabel(5,y,funpglines)
  96.        
  97.         -- Wait for a key event:
  98.         local event, key = os.pullEvent("key")
  99.        
  100.         -- Act on it:
  101.         if key == keys.up and y > 6 then
  102.             y = y - 1
  103.         elseif key == keys.down and y < 12 then
  104.             y = y + 1
  105.         elseif key == keys.enter and y == 6 then
  106.             shell.run("Rsnake")
  107.         elseif key == keys.enter and y == 7 then
  108.             shell.run("Rchat")
  109.         elseif key == keys.enter and y == 8 then
  110.             PlayMusic()
  111.         elseif key == keys.enter and y == 9 then
  112.             SelectorMain()
  113.             break
  114.         end
  115.     end
  116. end
  117.  
  118.  
  119. function SelectorMain()
  120.     local x, y = 5, 6
  121.  
  122. local xSize, ySize = term.getSize()
  123.  
  124.     while true do
  125.         -- Draw a white space at the current x/y co-ord:
  126.         term.setBackgroundColor(colours.black)
  127.         term.setTextColor(colours.green)
  128.         term.clear()
  129.         WriteHeader(Name)
  130.         WriteMainPage()
  131.         term.setCursorPos(x, y)
  132.         term.setBackgroundColor(colours.green)
  133.         term.setTextColor(colours.black)
  134.         WriteSelectedLabel(5,y,mainpglines)
  135.        
  136.         -- Wait for a key event:
  137.         local event, key = os.pullEvent("key")
  138.        
  139.         -- Act on it:
  140.         if key == keys.up and y > 6 then
  141.             y = y - 1
  142.         elseif key == keys.down and y < 12 then
  143.             y = y + 1
  144.         elseif key == keys.enter and y == 7 then
  145.             term.setBackgroundColor(colours.black)
  146.             term.setTextColor(colours.green)
  147.             shell.run("setup")
  148.         elseif key == keys.enter and y == 6 then
  149.             term.clear()
  150.             shell.run("filebrowse")
  151.         elseif key == keys.enter and y == 8 then
  152.             SelectorFun()
  153.             break
  154.         elseif key == keys.enter and y == 9 then
  155.             os.reboot()
  156.         elseif key == keys.enter and y == 10 then
  157.             os.shutdown()
  158.         elseif key == keys.enter and y == 11 then
  159.             term.setBackgroundColor(colours.black)
  160.             term.setTextColor(colours.green)
  161.             term.clear()
  162.             term.setCursorPos(1, 1)
  163.             shell.run("pastebin", "run", "gMC3n107")
  164.             break
  165.         end
  166.     end
  167. end
  168.  
  169. function OSmain()
  170.     WriteHeader(Name)
  171.     term.setCursorPos(5, 7)
  172.     SelectorMain()
  173. end
  174.  
  175. OSmain()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement