JustDoesGames

AOS

Sep 28th, 2019
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.96 KB | None | 0 0
  1. --$$ AOS (Advanced Opperating System) $$--
  2. --## Just Does Games ##--
  3. --## 9/24/2019 @ 3:10 PM ##--
  4.  
  5. if not term.isColor() then print("Advanced Computer Required!") return end
  6. local sx,sy = term.getSize()
  7. if sx ~= 51 or sy ~= 19 then print("51 by 19 required. got "..sx.." by "..xy) return end
  8. shell.run("cd /")
  9.  
  10. -- Pre-established Functions --
  11.  
  12. function setText(col)
  13.     term.setTextColor(colors[col])
  14. end
  15.  
  16. function setBack(col)
  17.     term.setBackgroundColor(colors[col])
  18. end
  19.  
  20. function cp(x,y)
  21.     term.setCursorPos(x,y)
  22. end
  23.  
  24. function clr()
  25.     term.clear()
  26. end
  27.  
  28. if not fs.exists("AOS_missingno.nfp") then
  29.  
  30.     local missingno = {"2f2f2","f2f2f7","2f2f27"," 77777"}
  31.  
  32.     local file = fs.open("AOS_missingno.nfp", "w")
  33.     for i=1, #missingno do
  34.         file.writeLine(missingno[i])
  35.     end
  36.     file.close()
  37. end
  38.  
  39. -- Functions --
  40.  
  41. function display_bar()
  42.     cp(1,sy) setBack("green") write(" ") setBack("white") for i=1, sx-1 do write(" ") end cp(2,2)
  43. end
  44.  
  45. function display_ico(delay)
  46.  
  47.     -- icons are 6 x 4
  48.     --local temp = paintutils.loadImage("os/AOS/ico/temp.nfp")
  49.  
  50.     local varia = 0
  51.     local raw_count = 1
  52.     setText("white")
  53.     for i=1, 3 do -- top to bottom
  54.         local varib = 0
  55.         for j=1, 7 do -- left to right
  56.             if menu_selected[raw_count] ~= nil then
  57.                 paintutils.drawImage(menu_selected[raw_count][1], (7-5)+(7*varib), (7-5)+(6*varia))
  58.                 cp((7-5)+(7*varib), (7-5)+(6*varia)+4)
  59.                 setBack("cyan")
  60.                 write(menu_selected[raw_count][2])
  61.                 if delay == nil then sleep(.0000001) end
  62.             end
  63.             varib = varib + 1
  64.             raw_count = raw_count + 1
  65.         end
  66.         varia = varia + 1
  67.     end
  68.  
  69.  
  70. end
  71.  
  72. function display_start()
  73.  
  74.     for i=1, #menu_start do
  75.         if start_menu_open == true then
  76.             setBack(menu_start[i][1])
  77.         else
  78.             setBack("cyan")
  79.         end
  80.         cp(1,sy-#menu_start+i-1)
  81.         for i=1, 10 do
  82.             write(" ")
  83.         end
  84.         if start_menu_open == true then
  85.             setBack("lightGray")
  86.             write(" ")
  87.             setBack(menu_start[i][1])
  88.         else
  89.             write(" ")
  90.         end
  91.     end
  92.     if start_menu_open == true then
  93.         for i=1, #menu_start do
  94.             cp(1,sy-#menu_start+i-1)
  95.             setText(menu_start[i][2])
  96.             setBack(menu_start[i][1])
  97.             write(menu_start[i][3])
  98.         end
  99.     end
  100.  
  101.     if start_menu_open == false then
  102.         display_ico(false)
  103.     end
  104. end
  105.  
  106. function display(icos)
  107.     setBack("cyan") clr() display_bar() if icos == nil then display_ico(false) else if icos == true then display_ico() end end
  108. end
  109.  
  110. function checkClick(x,y)
  111.     if x ~= 1 and x ~= sx-1 and x ~= sx and y ~= 1 then
  112.         if x ~= 8 and x ~= 15 and x ~= 22 and x ~= 29 and x ~= 36 and x ~= 43 and y ~= 7 and y ~= 13 then
  113.             if x >= 44 then
  114.                 if y >= 14 then
  115.                     -- 21
  116.                     lastClick = "click_21"
  117.                 elseif y >= 8 then
  118.                     -- 20
  119.                     lastClick = "click_14"
  120.                 elseif y >= 2 then
  121.                     -- 19
  122.                     lastClick = "click_7"
  123.                 else
  124.                     lastClick = false
  125.                 end
  126.             elseif x >= 37 then
  127.                 if y >= 14 then
  128.                     -- 18
  129.                     lastClick = "click_20"
  130.                 elseif y >= 8 then
  131.                     -- 17
  132.                     lastClick = "click_13"
  133.                 elseif y >= 2 then
  134.                     -- 16
  135.                     lastClick = "click_6"
  136.                 else
  137.                     lastClick = false
  138.                 end
  139.             elseif x >= 30 then
  140.                 if y >= 14 then
  141.                     -- 15
  142.                     lastClick = "click_19"
  143.                 elseif y >= 8 then
  144.                     -- 14
  145.                     lastClick = "click_12"
  146.                 elseif y >= 2 then
  147.                     -- 13
  148.                     lastClick = "click_5"
  149.                 else
  150.                     lastClick = false
  151.                 end
  152.             elseif x >= 23 then
  153.                 if y >= 14 then
  154.                     -- 12
  155.                     lastClick = "click_18"
  156.                 elseif y >= 8 then
  157.                     -- 11
  158.                     lastClick = "click_11"
  159.                 elseif y >= 2 then
  160.                     -- 10
  161.                     lastClick = "click_4"
  162.                 else
  163.                     lastClick = false
  164.                 end
  165.             elseif x >= 16 then
  166.                 if y >= 14 then
  167.                     -- 9
  168.                     lastClick = "click_17"
  169.                 elseif y >= 8 then
  170.                     -- 8
  171.                     lastClick = "click_10"
  172.                 elseif y >= 2 then
  173.                     -- 7
  174.                     lastClick = "click_3"
  175.                 else
  176.                     lastClick = false
  177.                 end
  178.             elseif x >= 9 then
  179.                 if y >= 14 then
  180.                     -- 6
  181.                     lastClick = "click_16"
  182.                 elseif y >= 8 then
  183.                     -- 5
  184.                     lastClick = "click_9"
  185.                 elseif y >= 2 then
  186.                     -- 4
  187.                     lastClick = "click_2"
  188.                 else
  189.                     lastClick = false
  190.                 end
  191.             elseif x >= 2 then
  192.                 if y >= 14 then
  193.                     -- 3
  194.                     lastClick = "click_15"
  195.                 elseif y >= 8 then
  196.                     -- 2
  197.                     lastClick = "click_8"
  198.                 elseif y >= 2 then
  199.                     -- 1
  200.                     lastClick = "click_1"
  201.                 else
  202.                     lastClick = false
  203.                 end
  204.             else
  205.                 lastClick = false
  206.             end
  207.         end
  208.     end
  209. end
  210.  
  211. function openWindow()
  212.     display(false) paintutils.drawImage(window,1,1)
  213. end
  214.  
  215. function icon_check(location)
  216.     if not fs.exists(location) then
  217.         return paintutils.loadImage("AOS_missingno.nfp")
  218.     else
  219.         return paintutils.loadImage(location)
  220.     end
  221. end
  222.  
  223. -- Menus and Variables --
  224.  
  225. menu_start = {{"red", "white", "Shutdown"}, {"orange", "white", "Reboot"}, {"yellow", "white", "Shell"}}
  226. menu_main = {{icon_check("/os/AOS/ico/apps.nfp"), "Apps"}, {icon_check("/os/AOS/ico/help.nfp"), "Help"}}
  227. menu_apps = {{icon_check("/os/AOS/ico/naiv_back.nfp"), "..."}, {icon_check("/os/AOS/ico/file_system.nfp"), "Files"}, {icon_check("/os/AOS/ico/paint.nfp"), "Paint"}, {icon_check("/os/AOS/ico/ico_maker.nfp"), "ico maker"}}
  228.  
  229. -- 6 x 4 icons
  230.  
  231. menu_selected = menu_main
  232. start_menu_open = false
  233. window = paintutils.loadImage("/os/AOS/ico/window.nfp")
  234. lastClick = false
  235.  
  236. -- Runtime --
  237.  
  238. function runtime()
  239.     display()
  240.     running = true
  241.     local x,y = 1,1
  242.     while running do
  243.         sleep(.01)
  244.         a,b,x,y = os.pullEvent("mouse_click") setText("black") setBack("white") cp(sx-13,sy) write("X: "..x.."  Y: "..y.."  ")
  245.         if x == 1 and y == sy then
  246.             if start_menu_open == true then start_menu_open = false else start_menu_open = true end display_start()
  247.         elseif x <= 10 and y >= sy-#menu_start and start_menu_open == true then -- Start menu
  248.             if y == 16 then
  249.                 os.shutdown()
  250.             elseif y == 17 then
  251.                 os.reboot()
  252.             elseif y == 18 then
  253.                 setBack("black") clr() cp(1,1) running = false
  254.             end
  255.         else -- anything other than start menu shit
  256.             if start_menu_open == true then start_menu_open = false display_start() end
  257.             checkClick(x,y)
  258.             if lastClick ~= false then
  259.                 if menu_selected == menu_main then
  260.                     if lastClick == "click_1" then
  261.                         menu_selected = menu_apps display(true)
  262.                     elseif lastClick == "click_2" then
  263.                         lastClick = false
  264.                         openWindow()
  265.                         cp(4,4)
  266.                         setText("black") setBack("white")
  267.                         print("AOS (Advanced Opperating System) is an OS use")
  268.                         cp(4,5)
  269.                         print("to increase usage of any Advanced Computer.")
  270.                         local lx,ly = 1,1
  271.                         repeat
  272.                             a,b,lx,ly = os.pullEvent("mouse_click")
  273.                         until lx == sx-3 and ly == 2 or lx == sx-4 and ly == 2
  274.                         display()
  275.                     end
  276.                 elseif menu_selected == menu_apps then
  277.                     if lastClick == "click_1" then
  278.                         menu_selected = menu_main display(true)
  279.                     elseif lastClick == "click_2" then
  280.                         --
  281.                     elseif lastClick == "click_3" then
  282.                         --
  283.                     elseif lastClick == "click_4" then
  284.                         --
  285.                     end
  286.                 end
  287.             end
  288.         end
  289.     end
  290. end
  291.  
  292.  
  293.  
  294.  
  295.  
  296. runtime()
Advertisement
Add Comment
Please, Sign In to add comment