Advertisement
Alakazard12

NovaAir

Jul 7th, 2013
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 88.23 KB | None | 0 0
  1. -- Nova GUI API lightweight edition. By alakazard12
  2. -- Feel free to use this as long as you give me credit, but there's no documentation yet
  3.  
  4. local LGW, LGH = term.getSize()
  5.  
  6. local VColors = {}
  7. local VClasses = {
  8.     ["TextButton"] = true;
  9.     ["TextLabel"] = true;
  10.     ["TextBox"] = true;
  11.     ["ImageButton"] = true;
  12.     ["ImageLabel"] = true;
  13. }
  14.  
  15. for _,Color in pairs(colors) do
  16.     if type(Color) == "number" then
  17.         VColors[Color] = true
  18.     end
  19. end
  20.  
  21. local function Round(Number)
  22.     return math.floor(Number + 0.5)
  23. end
  24.  
  25. local Check
  26. function Check(Object, BG, PX, PY, ChangeP)
  27.     if Object.Visible == true then
  28.         if Object.Class == "TextButton" or Object.Class == "TextBox" or Object.Class == "TextLabel" or Object.Class == "ImageButton" or Object.Class == "ImageLabel" then
  29.             -- if ChangeP ~= true then
  30.                 PX = PX + Object.Position[1] - 1
  31.                 PY = PY + Object.Position[2] - 1
  32.             -- end
  33.             if Object.ShowBackground == true then
  34.                 BG = Object.BackgroundColor
  35.             end
  36.             if Object.Class == "TextBox" and Object.Focused == true then
  37.                 BG = Object.ActiveTextColor
  38.             end
  39.             term.setBackgroundColor(BG)
  40.             for Y = 1, Object.Size[2] do
  41.                 term.setCursorPos(PX, PY + Y - 1)
  42.                 term.write(string.rep(" ", Object.Size[1]))
  43.             end
  44.  
  45.             if Object.Class == "ImageButton" or Object.Class == "ImageLabel" and Object.Image then
  46.                 paintutils.drawImage(Object.Image, PX, PY)
  47.             end
  48.  
  49.             if Object.Class == "TextButton" or Object.Class == "TextBox" or Object.Class == "TextLabel" then
  50.                 if Object.ShowText == true then
  51.                     term.setTextColor(Object.TextColor)
  52.  
  53.                     local Text = Object.Text
  54.                     if Object.TextChar then
  55.                         Text = string.rep(Object.TextChar, #Text)
  56.                     end
  57.  
  58.                     if Object.Focused == true then
  59.                         Text = Text .. " "
  60.                     end
  61.  
  62.                     if Object.MultiLine == true then
  63.                         local LastP = 1
  64.                         local LastS
  65.                         local Lines = {}
  66.                         local DidBreak = false
  67.                         local RPassed = false
  68.                         local ROnLine = false
  69.                         local ROnNum
  70.                         local RLine
  71.                         for On = 1, #Text do
  72.                             if Text:sub(On, On) == " " then
  73.                                 LastS = On
  74.                             end
  75.  
  76.                             if On - LastP + 2 > Object.Size[1] then
  77.                                 if #Lines == Object.Size[2] then
  78.                                     break
  79.                                 end
  80.  
  81.                                 if LastS then
  82.                                     table.insert(Lines, Text:sub(LastP, LastS))
  83.                                     LastP = LastS + 1
  84.                                 else
  85.                                     table.insert(Lines, Text:sub(LastP, On))
  86.                                     LastP = On + 1
  87.                                 end
  88.  
  89.                                 LastS = nil
  90.  
  91.                                 if #Lines == Object.Size[2] then
  92.                                     if Object.Focused == false then
  93.                                         DidBreak = true
  94.                                         break
  95.                                     else
  96.                                         table.remove(Lines, 1)
  97.                                     end
  98.                                 end
  99.                             end
  100.                         end
  101.  
  102.                         if DidBreak == false then
  103.                             table.insert(Lines, Text:sub(LastP))
  104.                         elseif Object.Focused == true then
  105.                             table.remove(Lines, 1)
  106.                             table.insert(Lines, Text:sub(LastP))
  107.                         end
  108.  
  109.                         local TextCount = 0
  110.  
  111.                         for _,Line in pairs(Lines) do
  112.                             local XA = 0
  113.                             local YA = 0
  114.  
  115.                             if Object.TextXAlignment == 0 then
  116.                                 XA = PX
  117.                             elseif Object.TextXAlignment == 1 then
  118.                                 XA = PX + Round((Object.Size[1] - #Line) / 2)
  119.                             else
  120.                                 XA = PX + Round(Object.Size[1] - #Line)
  121.                             end
  122.  
  123.                             if Object.TextYAlignment == 0 then
  124.                                 YA = PY + _ - 1
  125.                             elseif Object.TextYAlignment == 1 then
  126.                                 YA = PY + Round((Object.Size[2] - #Lines) / 2) + _ - 1
  127.                             else
  128.                                 YA = PY + Round(Object.Size[2] - #Lines) + _ - 1
  129.                             end
  130.  
  131.                             term.setCursorPos(XA, YA)
  132.                             term.write(Line)
  133.                         end
  134.                     else
  135.                         if #Text > Object.Size[1] then
  136.                             if Object.Focused == false then
  137.                                 Text = string.sub(Text, 1, Object.Size[1])
  138.                             -- elseif Object.RTextPos then
  139.                             -- Text = string.sub(Text, Object.RTextPos, Object.RTextPos + Object.Size[1] - 1)
  140.                             else
  141.                                 Text = string.sub(Text, #Text - Object.Size[1] + 1, #Text)
  142.                             end
  143.                         end
  144.  
  145.                         local XA = 0
  146.                         local YA = 0
  147.  
  148.                         if Object.TextXAlignment == 0 then
  149.                             XA = PX
  150.                         elseif Object.TextXAlignment == 1 then
  151.                             XA = PX + Round((Object.Size[1] - #Text) / 2)
  152.                         else
  153.                             XA = PX + Round(Object.Size[1] - #Text)
  154.                         end
  155.  
  156.                         if Object.TextYAlignment == 0 then
  157.                             YA = PY
  158.                         elseif Object.TextYAlignment == 1 then
  159.                             YA = PY + Round((Object.Size[2] - 1) / 2)
  160.                         else
  161.                             YA = PY + Round(Object.Size[2] - 1)
  162.                         end
  163.  
  164.                         term.setCursorPos(XA, YA)
  165.                         term.write(Text)
  166.                     end
  167.                     -- if Object.RTextPos == nil then
  168.                         Object.TextPos = {term.getCursorPos()}
  169.                         Object.TextPos[1] = Object.TextPos[1] - 1
  170.                     -- end
  171.                 end
  172.             end
  173.  
  174.             for _,Obj in pairs(Object.Children) do
  175.                 Check(Obj, BG, PX, PY)
  176.             end
  177.         end
  178.     end
  179. end
  180.  
  181. local function SortListen(Tbl)
  182.     local Clone = {}
  183.     for _,Item in pairs(Tbl) do
  184.         Clone[_] = Item
  185.     end
  186.     table.sort(Clone, function(A, B)
  187.         return A.ZIndex > B.ZIndex
  188.     end)
  189.     return Clone
  190. end
  191.  
  192. local function NewClass(Par, Class, Main)
  193.     if type(Class) ~= "string" then
  194.         error("bad argument #1: string expected, got " .. type(Class), 2)
  195.     end
  196.     if not VClasses[Class] then
  197.         error("Invalid class name.", 2)
  198.     end
  199.  
  200.     local PublicTable = {}
  201.     local LocalTable = {}
  202.  
  203.     LocalTable.Parent = Par
  204.     LocalTable.Class = Class
  205.  
  206.     function PublicTable:ClearChildren()
  207.         LocalTable.Children = {}
  208.     end
  209.  
  210.     if Class == "ImageButton" or Class == "ImageLabel" then
  211.         LocalTable.Size = {2, 2}
  212.         LocalTable.Position = {1, 1}
  213.         LocalTable.Visible = true
  214.         LocalTable.Active = true
  215.         LocalTable.Children = {}
  216.         LocalTable.ZIndex = 0
  217.         LocalTable.ShowBackground = true
  218.  
  219.         function PublicTable:Size(X, Y)
  220.             if type(X) ~= "number" then
  221.                 error("bad argument #1: number expected, got " .. type(X), 2)
  222.             end
  223.             if type(Y) ~= "number" then
  224.                 error("bad argument #2: number expected, got " .. type(Y), 2)
  225.             end
  226.  
  227.             LocalTable.Size = {X, Y}
  228.         end
  229.  
  230.         function PublicTable:Image(Image)
  231.             if type(Image) ~= "table" then
  232.                 error("bad argument #1: table expected, got " .. type(Image), 2)
  233.             end
  234.  
  235.             LocalTable.Image = Image
  236.         end
  237.  
  238.         function PublicTable:GetSize()
  239.             return unpack(LocalTable.Size)
  240.         end
  241.  
  242.         function PublicTable:ShowBackground(Bool)
  243.             if type(Bool) ~= "boolean" then
  244.                 error("bad argument #1: boolean expected, got " .. type(Bool), 2)
  245.             end
  246.             LocalTable.ShowBackground = Bool
  247.         end
  248.  
  249.         function PublicTable:GetShowBackground()
  250.             return LocalTable.ShowBackground
  251.         end
  252.  
  253.         function PublicTable:ZIndex(Number)
  254.             if type(Number) ~= "number" then
  255.                 error("bad argument #1: number expected, got " .. type(Number), 2)
  256.             end
  257.             LocalTable.ZIndex = Number
  258.             table.sort(Par.Children, function(A, B)
  259.                 return A.ZIndex < B.ZIndex
  260.             end)
  261.         end
  262.  
  263.         function PublicTable:GetZIndex()
  264.             return LocalTable.ZIndex
  265.         end
  266.  
  267.         function PublicTable:Position(X, Y)
  268.             if type(X) ~= "number" then
  269.                 error("bad argument #1: number expected, got " .. type(X), 2)
  270.             end
  271.             if type(Y) ~= "number" then
  272.                 error("bad argument #2: number expected, got " .. type(Y), 2)
  273.             end
  274.             LocalTable.Position = {X, Y}
  275.         end
  276.  
  277.         function PublicTable:GetPosition()
  278.             return unpack(LocalTable.Position)
  279.         end
  280.  
  281.         function PublicTable:Visible(Bool)
  282.             if type(Bool) ~= "boolean" then
  283.                 error("bad argument #1: boolean expected, got " .. type(Bool), 2)
  284.             end
  285.             LocalTable.Visible = Bool
  286.         end
  287.  
  288.         function PublicTable:GetVisible()
  289.             return LocalTable.Visible
  290.         end
  291.  
  292.         function PublicTable:Active(Bool)
  293.             if type(Bool) ~= "boolean" then
  294.                 error("bad argument #1: boolean expected, got " .. type(Bool), 2)
  295.             end
  296.             LocalTable.Active = Bool
  297.         end
  298.  
  299.         function PublicTable:GetActive()
  300.             return LocalTable.Active
  301.         end
  302.  
  303.         function PublicTable:BackgroundColor(Color)
  304.             if type(Color) ~= "number" then
  305.                 error("bad argument #1: number expected, got " .. type(Color), 2)
  306.             end
  307.             if VColors[Color] ~= true then
  308.                 error("Invalid color.", 2)
  309.             end
  310.             LocalTable.BackgroundColor = Color
  311.         end
  312.  
  313.         function PublicTable:GetBackgroundColor()
  314.             return LocalTable.BackgroundColor
  315.         end
  316.  
  317.         if Class == "ImageButton" then
  318.             function PublicTable:Button1Click(Function)
  319.                 if Function == nil then
  320.                     LocalTable.Button1Click = nil
  321.                 else
  322.                     if type(Function) ~= "function" then
  323.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  324.                     end
  325.                     LocalTable.Button1Click = Function
  326.                 end
  327.             end
  328.  
  329.             function PublicTable:GetButton1Click()
  330.                 return LocalTable.Button1Click
  331.             end
  332.  
  333.             function PublicTable:MouseScroll(Function)
  334.                 if Function == nil then
  335.                     LocalTable.MouseScroll = nil
  336.                 else
  337.                     if type(Function) ~= "function" then
  338.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  339.                     end
  340.                     LocalTable.MouseScroll = Function
  341.                 end
  342.             end
  343.  
  344.             function PublicTable:GetMouseScroll()
  345.                 return LocalTable.MouseScroll
  346.             end
  347.  
  348.             function PublicTable:MouseDrag1(Function)
  349.                 if Function == nil then
  350.                     LocalTable.MouseDrag1 = nil
  351.                 else
  352.                     if type(Function) ~= "function" then
  353.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  354.                     end
  355.                     LocalTable.MouseDrag1 = Function
  356.                 end
  357.             end
  358.  
  359.             function PublicTable:GetMouseDrag1()
  360.                 return LocalTable.MouseDrag1
  361.             end
  362.  
  363.             function PublicTable:MouseDrag2(Function)
  364.                 if Function == nil then
  365.                     LocalTable.MouseDrag2 = nil
  366.                 else
  367.                     if type(Function) ~= "function" then
  368.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  369.                     end
  370.                     LocalTable.MouseDrag2 = Function
  371.                 end
  372.             end
  373.  
  374.             function PublicTable:GetMouseDrag2()
  375.                 return LocalTable.MouseDrag2
  376.             end
  377.  
  378.             function PublicTable:MouseDrag3(Function)
  379.                 if Function == nil then
  380.                     LocalTable.MouseDrag3 = nil
  381.                 else
  382.                     if type(Function) ~= "function" then
  383.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  384.                     end
  385.                     LocalTable.MouseDrag3 = Function
  386.                 end
  387.             end
  388.  
  389.             function PublicTable:GetMouseDrag3()
  390.                 return LocalTable.MouseDrag3
  391.             end
  392.  
  393.             function PublicTable:Button2Click(Function)
  394.                 if Function == nil then
  395.                     LocalTable.Button2Click = nil
  396.                 else
  397.                     if type(Function) ~= "function" then
  398.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  399.                     end
  400.                     LocalTable.Button2Click = Function
  401.                 end
  402.             end
  403.  
  404.             function PublicTable:GetButton2Click()
  405.                 return LocalTable.Button2Click
  406.             end
  407.  
  408.             function PublicTable:Button3Click(Function)
  409.                 if Function == nil then
  410.                     LocalTable.Button3Click = nil
  411.                 else
  412.                     if type(Function) ~= "function" then
  413.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  414.                     end
  415.                     LocalTable.Button3Click = Function
  416.                 end
  417.             end
  418.  
  419.             function PublicTable:GetButton3Click()
  420.                 return LocalTable.Button3Click
  421.             end
  422.         end
  423.  
  424.         function PublicTable:New(Class)
  425.             return NewClass(LocalTable, Class, Main)
  426.         end
  427.  
  428.         function PublicTable:Draw()
  429.             local BG = Main.BackgroundColor
  430.             local FoundBG = false
  431.             local PX, PY = 1, 1
  432.  
  433.             local On = LocalTable.Parent
  434.             while On ~= Main do
  435.                 PX = PX + On.Position[1] - 1
  436.                 PY = PY + On.Position[2] - 1
  437.  
  438.                 if On.ShowBackground and FoundBG == false then
  439.                     BG = On.BackgroundColor
  440.                     FoundBG = true
  441.                 end
  442.                 On = On.Parent
  443.             end
  444.  
  445.             Check(LocalTable, BG, PX, PY)
  446.         end
  447.     elseif Class == "TextButton" or Class == "TextLabel" or Class == "TextBox" then
  448.         LocalTable.Size = {2, 2}
  449.         LocalTable.Position = {1, 1}
  450.         LocalTable.RawText = ""
  451.         LocalTable.Text = ""
  452.         LocalTable.BackgroundColor = colors.cyan
  453.         LocalTable.TextColor = colors.white
  454.         LocalTable.Visible = true
  455.         LocalTable.Active = true
  456.         LocalTable.Children = {}
  457.         LocalTable.ZIndex = 0
  458.         LocalTable.ShowBackground = true
  459.         LocalTable.ShowText = true
  460.         LocalTable.TextXAlignment = 1
  461.         LocalTable.TextYAlignment = 1
  462.         LocalTable.MultiLine = false
  463.  
  464.         if Class == "TextBox" then
  465.             LocalTable.ActiveTextColor = colors.blue
  466.             LocalTable.Overlap = false
  467.             LocalTable.Focused = false
  468.             LocalTable.ClearTextOnFocus = false
  469.             LocalTable.RTextPos = 8
  470.         end
  471.  
  472.         function PublicTable:TextXAlignment(Num)
  473.             if type(Num) == "string" then
  474.                 if Num:lower() == "left" then
  475.                     Num = 0
  476.                 elseif Num:lower() == "center" then
  477.                     Num = 1
  478.                 elseif Num:lower() == "right" then
  479.                     Num = 2
  480.                 else
  481.                     error("bad argument #1: '" .. Num .. "' is not a valid string", 2)
  482.                 end
  483.             end
  484.  
  485.             if type(Num) ~= "number" then
  486.                 error("bad argument #1: number expected, got " .. type(X), 2)
  487.             end
  488.             LocalTable.TextXAlignment = Num
  489.         end
  490.  
  491.         function PublicTable:GetTextXAlignment()
  492.             return LocalTable.TextXAlignment
  493.         end
  494.  
  495.         function PublicTable:TextYAlignment(Num)
  496.             if type(Num) == "string" then
  497.                 if Num:lower() == "top" then
  498.                     Num = 0
  499.                 elseif Num:lower() == "center" then
  500.                     Num = 1
  501.                 elseif Num:lower() == "bottom" then
  502.                     Num = 2
  503.                 else
  504.                     error("bad argument #1: '" .. Num .. "' is not a valid string", 2)
  505.                 end
  506.             end
  507.  
  508.             if type(Num) ~= "number" then
  509.                 error("bad argument #1: number expected, got " .. type(X), 2)
  510.             end
  511.             LocalTable.TextYAlignment = Num
  512.         end
  513.  
  514.         function PublicTable:GetTextYAlignment()
  515.             return LocalTable.TextYAlignment
  516.         end
  517.  
  518.         function PublicTable:Size(X, Y)
  519.             if type(X) ~= "number" then
  520.                 error("bad argument #1: number expected, got " .. type(X), 2)
  521.             end
  522.             if type(Y) ~= "number" then
  523.                 error("bad argument #2: number expected, got " .. type(Y), 2)
  524.             end
  525.  
  526.             LocalTable.Size = {X, Y}
  527.         end
  528.  
  529.         function PublicTable:GetSize()
  530.             return unpack(LocalTable.Size)
  531.         end
  532.  
  533.         function PublicTable:ShowBackground(Bool)
  534.             if type(Bool) ~= "boolean" then
  535.                 error("bad argument #1: boolean expected, got " .. type(Bool), 2)
  536.             end
  537.             LocalTable.ShowBackground = Bool
  538.         end
  539.  
  540.         function PublicTable:GetShowBackground()
  541.             return LocalTable.ShowBackground
  542.         end
  543.  
  544.         function PublicTable:ShowText(Bool)
  545.             if type(Bool) ~= "boolean" then
  546.                 error("bad argument #1: boolean expected, got " .. type(Bool), 2)
  547.             end
  548.             LocalTable.ShowText = Bool
  549.         end
  550.  
  551.         function PublicTable:GetShowText()
  552.             return LocalTable.ShowText
  553.         end
  554.  
  555.         function PublicTable:MultiLine(Bool)
  556.             if type(Bool) ~= "boolean" then
  557.                 error("bad argument #1: boolean expected, got " .. type(Bool), 2)
  558.             end
  559.             LocalTable.MultiLine = Bool
  560.         end
  561.  
  562.         function PublicTable:GetMultiLine()
  563.             return LocalTable.MultiLine
  564.         end
  565.  
  566.         function PublicTable:ZIndex(Number)
  567.             if type(Number) ~= "number" then
  568.                 error("bad argument #1: number expected, got " .. type(Number), 2)
  569.             end
  570.             LocalTable.ZIndex = Number
  571.             table.sort(Par.Children, function(A, B)
  572.                 return A.ZIndex < B.ZIndex
  573.             end)
  574.         end
  575.  
  576.         function PublicTable:GetZIndex()
  577.             return LocalTable.ZIndex
  578.         end
  579.  
  580.         function PublicTable:Position(X, Y)
  581.             if type(X) ~= "number" then
  582.                 error("bad argument #1: number expected, got " .. type(X), 2)
  583.             end
  584.             if type(Y) ~= "number" then
  585.                 error("bad argument #2: number expected, got " .. type(Y), 2)
  586.             end
  587.             LocalTable.Position = {X, Y}
  588.         end
  589.  
  590.         function PublicTable:GetPosition()
  591.             return unpack(LocalTable.Position)
  592.         end
  593.  
  594.         function PublicTable:Visible(Bool)
  595.             if type(Bool) ~= "boolean" then
  596.                 error("bad argument #1: boolean expected, got " .. type(Bool), 2)
  597.             end
  598.             LocalTable.Visible = Bool
  599.         end
  600.  
  601.         function PublicTable:GetVisible()
  602.             return LocalTable.Visible
  603.         end
  604.  
  605.         function PublicTable:Active(Bool)
  606.             if type(Bool) ~= "boolean" then
  607.                 error("bad argument #1: boolean expected, got " .. type(Bool), 2)
  608.             end
  609.             LocalTable.Active = Bool
  610.         end
  611.  
  612.         function PublicTable:GetActive()
  613.             return LocalTable.Active
  614.         end
  615.  
  616.         function PublicTable:Text(Text)
  617.             if Text == nil then
  618.                 Text = ""
  619.             end
  620.             if type(Text) ~= "string" then
  621.                 error("bad argument #1: string expected, got " .. type(Text), 2)
  622.             end
  623.             LocalTable.Text = Text
  624.         end
  625.  
  626.         function PublicTable:GetText()
  627.             return LocalTable.Text
  628.         end
  629.  
  630.         function PublicTable:BackgroundColor(Color)
  631.             if type(Color) ~= "number" then
  632.                 error("bad argument #1: number expected, got " .. type(Color), 2)
  633.             end
  634.             if VColors[Color] ~= true then
  635.                 error("Invalid color.", 2)
  636.             end
  637.             LocalTable.BackgroundColor = Color
  638.         end
  639.  
  640.         function PublicTable:GetBackgroundColor()
  641.             return LocalTable.BackgroundColor
  642.         end
  643.  
  644.         function PublicTable:TextColor(Color)
  645.             if type(Color) ~= "number" then
  646.                 error("bad argument #1: number expected, got " .. type(Color), 2)
  647.             end
  648.             if VColors[Color] ~= true then
  649.                 error("Invalid color.", 2)
  650.             end
  651.             LocalTable.TextColor = Color
  652.         end
  653.  
  654.         function PublicTable:GetTextColor()
  655.             return LocalTable.TextColor
  656.         end
  657.  
  658.         function PublicTable:MouseScroll(Function)
  659.                 if Function == nil then
  660.                     LocalTable.MouseScroll = nil
  661.                 else
  662.                 if type(Function) ~= "function" then
  663.                     error("bad argument #1: function expected, got " .. type(Function), 2)
  664.                 end
  665.                 LocalTable.MouseScroll = Function
  666.             end
  667.         end
  668.  
  669.         if Class == "TextButton" then
  670.             function PublicTable:Button1Click(Function)
  671.                 if Function == nil then
  672.                     LocalTable.Button1Click = nil
  673.                 else
  674.                     if type(Function) ~= "function" then
  675.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  676.                     end
  677.                     LocalTable.Button1Click = Function
  678.                 end
  679.             end
  680.  
  681.             function PublicTable:GetButton1Click()
  682.                 return LocalTable.Button1Click
  683.             end
  684.  
  685.             function PublicTable:GetMouseScroll()
  686.                 return LocalTable.MouseScroll
  687.             end
  688.  
  689.             function PublicTable:MouseDrag1(Function)
  690.                 if Function == nil then
  691.                     LocalTable.MouseDrag1 = nil
  692.                 else
  693.                     if type(Function) ~= "function" then
  694.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  695.                     end
  696.                     LocalTable.MouseDrag1 = Function
  697.                 end
  698.             end
  699.  
  700.             function PublicTable:GetMouseDrag1()
  701.                 return LocalTable.MouseDrag1
  702.             end
  703.  
  704.             function PublicTable:MouseDrag2(Function)
  705.                 if Function == nil then
  706.                     LocalTable.MouseDrag2 = nil
  707.                 else
  708.                     if type(Function) ~= "function" then
  709.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  710.                     end
  711.                     LocalTable.MouseDrag2 = Function
  712.                 end
  713.             end
  714.  
  715.             function PublicTable:GetMouseDrag2()
  716.                 return LocalTable.MouseDrag2
  717.             end
  718.  
  719.             function PublicTable:MouseDrag3(Function)
  720.                 if Function == nil then
  721.                     LocalTable.MouseDrag3 = nil
  722.                 else
  723.                     if type(Function) ~= "function" then
  724.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  725.                     end
  726.                     LocalTable.MouseDrag3 = Function
  727.                 end
  728.             end
  729.  
  730.             function PublicTable:GetMouseDrag3()
  731.                 return LocalTable.MouseDrag3
  732.             end
  733.  
  734.             function PublicTable:Button2Click(Function)
  735.                 if Function == nil then
  736.                     LocalTable.Button2Click = nil
  737.                 else
  738.                     if type(Function) ~= "function" then
  739.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  740.                     end
  741.                     LocalTable.Button2Click = Function
  742.                 end
  743.             end
  744.  
  745.             function PublicTable:GetButton2Click()
  746.                 return LocalTable.Button2Click
  747.             end
  748.  
  749.             function PublicTable:Button3Click(Function)
  750.                 if Function == nil then
  751.                     LocalTable.Button3Click = nil
  752.                 else
  753.                     if type(Function) ~= "function" then
  754.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  755.                     end
  756.                     LocalTable.Button3Click = Function
  757.                 end
  758.             end
  759.  
  760.             function PublicTable:GetButton3Click()
  761.                 return LocalTable.Button3Click
  762.             end
  763.         elseif Class == "TextBox" then
  764.             function PublicTable:ActiveTextColor(Color)
  765.                 if type(Color) ~= "number" then
  766.                     error("bad argument #1: number expected, got " .. type(Color), 2)
  767.                 end
  768.                 if VColors[Color] ~= true then
  769.                     error("Invalid color.", 2)
  770.                 end
  771.                 LocalTable.ActiveTextColor = Color
  772.             end
  773.  
  774.             function PublicTable:EnterPress(Function)
  775.                 if Function == nil then
  776.                     LocalTable.EnterPress = nil
  777.                 else
  778.                     if type(Function) ~= "function" then
  779.                         error("bad argument #1: function expected, got " .. type(Function), 2)
  780.                     end
  781.                     LocalTable.EnterPress = Function
  782.                 end
  783.             end
  784.  
  785.             function PublicTable:GetEnterPress()
  786.                 return LocalTable.EnterPress
  787.             end
  788.  
  789.             function PublicTable:Overlap(Bool)
  790.                 if type(Bool) ~= "boolean" then
  791.                     error("bad argument #1: boolean expected, got " .. type(Bool), 2)
  792.                 end
  793.                 LocalTable.Overlap = Bool
  794.             end
  795.  
  796.             function PublicTable:GetOverlap()
  797.                 return LocalTable.Overlap
  798.             end
  799.  
  800.             function PublicTable:ClearTextOnFocus(Bool)
  801.                 if type(Bool) ~= "boolean" then
  802.                     error("bad argument #1: boolean expected, got " .. type(Bool), 2)
  803.                 end
  804.                 LocalTable.ClearTextOnFocus = Bool
  805.             end
  806.  
  807.             function PublicTable:GetClearTextOnFocus()
  808.                 return LocalTable.ClearTextOnFocus
  809.             end
  810.  
  811.             function PublicTable:Focus()
  812.                 Main.MakeFocus = LocalTable
  813.                 os.queueEvent("")
  814.             end
  815.  
  816.             function PublicTable:StopFocus()
  817.                 Main.StopFocus = true
  818.                 os.queueEvent("")
  819.             end
  820.  
  821.             function PublicTable:TextChar(Char)
  822.                 if Char == nil then
  823.                     LocalTable.TextChar = nil
  824.                 else
  825.                     if type(Char) ~= "string" then
  826.                         error("bad argument #1: string expected, got " .. type(Char), 2)
  827.                     end
  828.                     LocalTable.TextChar = Char
  829.                 end
  830.             end
  831.  
  832.             function PublicTable:GetTextChar()
  833.                 return LocalTable.TextChar
  834.             end
  835.         end
  836.  
  837.         function PublicTable:New(Class)
  838.             return NewClass(LocalTable, Class, Main)
  839.         end
  840.  
  841.         function PublicTable:Draw()
  842.             local BG = Main.BackgroundColor
  843.             local FoundBG = false
  844.             local PX, PY = 1, 1
  845.  
  846.             local On = LocalTable.Parent
  847.             while On ~= Main do
  848.                 PX = PX + On.Position[1] - 1
  849.                 PY = PY + On.Position[2] - 1
  850.  
  851.                 if On.ShowBackground and FoundBG == false then
  852.                     BG = On.BackgroundColor
  853.                     FoundBG = true
  854.                 end
  855.                 On = On.Parent
  856.             end
  857.  
  858.             Check(LocalTable, BG, PX, PY , true)
  859.         end
  860.     end
  861.  
  862.     LocalTable.Pub = PublicTable
  863.  
  864.     table.insert(Par.Children, LocalTable)
  865.  
  866.     function PublicTable:Destroy()
  867.         for _,Object in pairs(Par.Children) do
  868.             if LocalTable == Object then
  869.                 table.remove(Par.Children, _)
  870.                 break
  871.             end
  872.         end
  873.         LocalTable = nil
  874.         PublicTable = nil
  875.     end
  876.  
  877.     return PublicTable
  878. end
  879.  
  880. local function NewUI()
  881.     local LocalTable = {}
  882.     local PublicTable = {}
  883.  
  884.     LocalTable.BackgroundColor = colors.red
  885.     LocalTable.Visible = true
  886.     LocalTable.Active = true
  887.     LocalTable.Children = {}
  888.     LocalTable.Listening = false
  889.  
  890.     function PublicTable:BackgroundColor(Color)
  891.         if type(Color) ~= "number" then
  892.             error("bad argument #1: number expected, got " .. type(Color), 2)
  893.         end
  894.         if not VColors[Color] then
  895.             error("Invalid color.", 2)
  896.         end
  897.         LocalTable.BackgroundColor = Color
  898.     end
  899.  
  900.     function PublicTable:New(Class)
  901.         return NewClass(LocalTable, Class, LocalTable)
  902.     end
  903.  
  904.     function PublicTable:ClearChildren()
  905.         LocalTable.Children = {}
  906.     end
  907.  
  908.     function PublicTable:ErrorHandle(Function)
  909.         if type(Function) ~= "function" and Function ~= nil then
  910.             error("bad argument #1: function expected, got " .. type(Function), 2)
  911.         end
  912.  
  913.         LocalTable.ErrorHandle = Function
  914.     end
  915.  
  916.     function PublicTable:Output(Function)
  917.         if type(Function) ~= "function" and Function ~= nil then
  918.             error("bad argument #1: function expected, got " .. type(Function), 2)
  919.         end
  920.  
  921.         LocalTable.Output = Function
  922.     end
  923.  
  924.     function PublicTable:Listen()
  925.         LocalTable.Listening = true
  926.         local ActiveBox
  927.         local LastClick1
  928.         local LastClick2
  929.         local LastClick3
  930.  
  931.         while LocalTable.Listening == true do
  932.             local Event, P1, P2, P3, P4, P5 = os.pullEvent()
  933.             if LocalTable.Listening == false then
  934.                 break
  935.             end
  936.  
  937.             if LocalTable.MakeFocus then
  938.                 if ActiveBox then
  939.                     ActiveBox.Focused = false
  940.                     ActiveBox.StopFocus = nil
  941.                     term.setCursorBlink(false)
  942.                     if ActiveBox.Overlap == true then
  943.                         ActiveBox.Pub:Draw()
  944.                     else
  945.                         PublicTable:Draw()
  946.                     end
  947.                 end
  948.                 ActiveBox = LocalTable.MakeFocus
  949.                 LocalTable.MakeFocus = nil
  950.                 ActiveBox.Focused = true
  951.                 if ActiveBox.Overlap == true then
  952.                     ActiveBox.Pub:Draw()
  953.                 else
  954.                     PublicTable:Draw()
  955.                 end
  956.  
  957.                 term.setCursorBlink(true)
  958.                 term.setTextColor(ActiveBox.TextColor)
  959.                 term.setCursorPos(unpack(ActiveBox.TextPos))
  960.             end
  961.  
  962.             if ActiveBox and ActiveBox.StopFocus then
  963.                 ActiveBox.Focused = false
  964.                 ActiveBox.StopFocus = nil
  965.                 term.setCursorBlink(false)
  966.                 if ActiveBox.Overlap == true then
  967.                     ActiveBox.Pub:Draw()
  968.                 else
  969.                     PublicTable:Draw()
  970.                 end
  971.                 if ActiveBox.EnterPress then
  972.                     ActiveBox.EnterPress()
  973.                 end
  974.                 ActiveBox = nil
  975.             end
  976.  
  977.             if LocalTable.Output then
  978.                 if LocalTable.ErrorHandle then
  979.                     local Success, Err = pcall(LocalTable.Output, Event, P1, P2, P3, P4, P5)
  980.                     if not Success then
  981.                         LocalTable.ErrorHandle(Err)
  982.                     end
  983.                 else
  984.                     LocalTable.Output(Event, P1, P2, P3, P4, P5)
  985.                 end
  986.             end
  987.  
  988.             if Event == "char" then
  989.                 if ActiveBox then
  990.                     ActiveBox.Text = ActiveBox.Text .. P1
  991.                     if ActiveBox.Overlap == true then
  992.                         ActiveBox.Pub:Draw()
  993.                     else
  994.                         PublicTable:Draw()
  995.                     end
  996.                     term.setTextColor(ActiveBox.TextColor)
  997.  
  998.                     term.setCursorPos(unpack(ActiveBox.TextPos))
  999.                 end
  1000.             elseif Event == "key" then
  1001.                 if ActiveBox then
  1002.                     if P1 == 14 then
  1003.                         if #ActiveBox.Text > 0 then
  1004.                             ActiveBox.Text = string.sub(ActiveBox.Text, 1, #ActiveBox.Text - 1)
  1005.                             if ActiveBox.Overlap == true then
  1006.                                 ActiveBox.Pub:Draw()
  1007.                             else
  1008.                                 PublicTable:Draw()
  1009.                             end
  1010.                             term.setTextColor(ActiveBox.TextColor)
  1011.  
  1012.                             term.setCursorPos(unpack(ActiveBox.TextPos))
  1013.                         end
  1014.                     elseif P1 == 28 then
  1015.                         ActiveBox.Focused = false
  1016.                         term.setCursorBlink(false)
  1017.  
  1018.                         if ActiveBox.Overlap == true then
  1019.                             ActiveBox.Pub:Draw()
  1020.                         else
  1021.                             PublicTable:Draw()
  1022.                         end
  1023.  
  1024.                         if ActiveBox.EnterPress then
  1025.                             if LocalTable.ErrorHandle then
  1026.                                 local Success, Err = pcall(ActiveBox.EnterPress)
  1027.                                 if not Success then
  1028.                                     LocalTable.ErrorHandle(Err)
  1029.                                 end
  1030.                             else
  1031.                                 ActiveBox.EnterPress()
  1032.                             end
  1033.                         end
  1034.                         ActiveBox = nil
  1035.                     end
  1036.                 end
  1037.             elseif Event == "mouse_scroll" then
  1038.                 local PStop = false
  1039.                 local Check
  1040.                 function Check(Object, Par, PX, PY)
  1041.                     if Object.Active == true then
  1042.                         if PStop == true then return end
  1043.                         if Object.Class == "TextLabel" or Object.Class == "TextButton" or Object.Class == "ImageButton" then
  1044.                             if P2 >= Object.Position[1] + PX - 1 and P2 <= Object.Position[1] + Object.Size[1] + PX - 2 and P3 >= Object.Position[2] + PY - 1 and P3 <= Object.Position[2] + Object.Size[2] + PY - 2 then
  1045.                                 if Object.MouseScroll then
  1046.                                     if LocalTable.ErrorHandle then
  1047.                                         local Success, Err = pcall(Object.MouseScroll, P1)
  1048.                                         if not Success then
  1049.                                             LocalTable.ErrorHandle(Err)
  1050.                                         end
  1051.                                     else
  1052.                                         Object.MouseScroll(P1)
  1053.                                     end
  1054.                                     PStop = true
  1055.                                 end
  1056.                             end
  1057.                         end
  1058.  
  1059.                         for _,Object in pairs(SortListen(Object.Children)) do
  1060.                             Check(Object, Object, PX + Object.Position[1] - 1, PY + Object.Position[2] - 1)
  1061.                         end
  1062.                     end
  1063.                 end
  1064.  
  1065.                 for _,Object in pairs(SortListen(LocalTable.Children))  do
  1066.                     Check(Object, LocalTable, 1, 1)
  1067.                 end
  1068.             elseif Event == "mouse_drag" then
  1069.                 if P1 == 1 and LastClick1 then
  1070.                     if LastClick1.MouseDrag1 then
  1071.                         if LocalTable.ErrorHandle then
  1072.                             local Success, Err = pcall(LastClick1.MouseDrag1, P2, P3)
  1073.                             if not Success then
  1074.                                 LocalTable.ErrorHandle(Err)
  1075.                             end
  1076.                         else
  1077.                             LastClick1.MouseDrag1(P2, P3)
  1078.                         end
  1079.                     end
  1080.                 elseif P1 == 2 and LastClick2 then
  1081.                     if LastClick2.MouseDrag2 then
  1082.                         if LocalTable.ErrorHandle then
  1083.                             local Success, Err = pcall(Object.MouseDrag2, P2, P3)
  1084.                             if not Success then
  1085.                                 LocalTable.ErrorHandle(Err)
  1086.                             end
  1087.                         else
  1088.                             Object.MouseDrag2(P2, P3)
  1089.                         end
  1090.                     end
  1091.                 elseif P1 == 3 and LastClick3 then
  1092.                     if LastClick3.MouseDrag3 then
  1093.                         if LocalTable.ErrorHandle then
  1094.                             local Success, Err = pcall(Object.MouseDrag3, P2, P3)
  1095.                             if not Success then
  1096.                                 LocalTable.ErrorHandle(Err)
  1097.                             end
  1098.                         else
  1099.                             Object.MouseDrag3(P2, P3)
  1100.                         end
  1101.                     end
  1102.                 end
  1103.             elseif Event == "mouse_click" then
  1104.                 LastClick1 = nil
  1105.                 LastClick2 = nil
  1106.                 LastClick3 = nil
  1107.                 local PStop = false
  1108.                 local StopFocus = true
  1109.                 local Check
  1110.                 function Check(Object, Par, PX, PY)
  1111.                     if Object.Active == true then
  1112.                         if PStop == true then return end
  1113.                         if Object.Class == "TextButton" or Object.Class == "ImageButton" or Object.Class == "TextBox" then
  1114.                             if P2 >= Object.Position[1] + PX - 1 and P2 <= Object.Position[1] + Object.Size[1] + PX - 2 and P3 >= Object.Position[2] + PY - 1 and P3 <= Object.Position[2] + Object.Size[2] + PY - 2 then
  1115.                                 if ActiveBox and Object ~= ActiveBox then
  1116.                                     ActiveBox.Focused = false
  1117.                                     ActiveBox.StopFocus = nil
  1118.                                     term.setCursorBlink(false)
  1119.                                     if ActiveBox.Overlap == true then
  1120.                                         ActiveBox.Pub:Draw()
  1121.                                     else
  1122.                                         PublicTable:Draw()
  1123.                                     end
  1124.  
  1125.                                     if ActiveBox.EnterPress then
  1126.                                         if LocalTable.ErrorHandle then
  1127.                                             local Success, Err = pcall(ActiveBox.EnterPress)
  1128.                                             if not Success then
  1129.                                                 LocalTable.ErrorHandle(Err)
  1130.                                             end
  1131.                                         else
  1132.                                             ActiveBox.EnterPress()
  1133.                                         end
  1134.                                     end
  1135.                                     ActiveBox = nil
  1136.                                 end
  1137.                                 if P1 == 1 then
  1138.                                     LastClick1 = Object
  1139.                                     if (Object.Class == "TextButton" or Object.Class == "ImageButton") and Object.Button1Click then
  1140.                                         if LocalTable.ErrorHandle then
  1141.                                             local Success, Err = pcall(Object.Button1Click, P2, P3)
  1142.                                             if not Success then
  1143.                                                 LocalTable.ErrorHandle(Err)
  1144.                                             end
  1145.                                         else
  1146.                                             Object.Button1Click(P2, P3)
  1147.                                         end
  1148.                                     elseif Object.Class == "TextBox" then
  1149.                                         ActiveBox = Object
  1150.                                         Object.Focused = true
  1151.  
  1152.                                         if Object.ClearTextOnFocus == true then
  1153.                                             Object.Text = ""
  1154.                                         end
  1155.  
  1156.                                         Object.RawText = ""
  1157.                                         Object.RTextPos = 6
  1158.  
  1159.                                         if Object.Overlap == true then
  1160.                                             Object.Pub:Draw()
  1161.                                         else
  1162.                                             PublicTable:Draw()
  1163.                                         end
  1164.                                         term.setCursorBlink(true)
  1165.                                         term.setTextColor(ActiveBox.TextColor)
  1166.                                         term.setCursorPos(unpack(Object.TextPos))
  1167.                                     end
  1168.                                 elseif P1 == 2 then
  1169.                                     LastClick2 = Object
  1170.                                     if (Object.Class == "TextButton" or Object.Class == "ImageButton") and Object.Button2Click then
  1171.                                         if LocalTable.ErrorHandle then
  1172.                                             local Success, Err = pcall(Object.Button2Click, P2, P3)
  1173.                                             if not Success then
  1174.                                                 LocalTable.ErrorHandle(Err)
  1175.                                             end
  1176.                                         else
  1177.                                             Object.Button2Click(P2, P3)
  1178.                                         end
  1179.                                     end
  1180.                                 elseif P1 == 3 then
  1181.                                     LastClick3 = Object
  1182.                                     if (Object.Class == "TextButton" or Object.Class == "ImageButton") and Object.Button3Click then
  1183.                                         if LocalTable.ErrorHandle then
  1184.                                             local Success, Err = pcall(Object.Button3Click, P2, P3)
  1185.                                             if not Success then
  1186.                                                 LocalTable.ErrorHandle(Err)
  1187.                                             end
  1188.                                         else
  1189.                                             Object.Button3Click(P2, P3)
  1190.                                         end
  1191.                                     end
  1192.                                 end
  1193.  
  1194.                                 PStop = true
  1195.                             end
  1196.                         end
  1197.  
  1198.                         for _,Object2 in pairs(SortListen(Object.Children)) do
  1199.                             Check(Object2, Object, PX + Object.Position[1] - 1, PY + Object.Position[2] - 1)
  1200.                         end
  1201.                     end
  1202.                 end
  1203.  
  1204.                 for _,Object in pairs(SortListen(LocalTable.Children))  do
  1205.                     Check(Object, LocalTable, 1, 1)
  1206.                 end
  1207.             end
  1208.         end
  1209.     end
  1210.  
  1211.     function PublicTable:StopListen()
  1212.         LocalTable.Listening = false
  1213.     end
  1214.  
  1215.     function PublicTable:Draw()
  1216.         term.setBackgroundColor(LocalTable.BackgroundColor)
  1217.         term.clear()
  1218.  
  1219.         for _,Item in ipairs(LocalTable.Children) do
  1220.             Check(Item, LocalTable.BackgroundColor, 1, 1)
  1221.         end
  1222.     end
  1223.     return PublicTable
  1224. end
  1225.  
  1226. -- End of alakazard12's Nova GUI API
  1227.  
  1228. local tArgs = {...}
  1229.  
  1230. local LogoImage = {[1]={[1]=256,[2]=256,[3]=0,[4]=0,[5]=0,[6]=256,[7]=0,[8]=256,[9]=256,[10]=256,[11]=256,[12]=256,[13]=256,[14]=0,[15]=256,[16]=0,[17]=0,[18]=0,[19]=0,[20]=256,[21]=0,[22]=0,[23]=256,[24]=256,[25]=256,[26]=256,[27]=0,[28]=0,[29]=0,[30]=16384,[31]=16384,[32]=16384,[33]=16384,[34]=0,[35]=0,[36]=16384,[37]=0,[38]=16384,[39]=16384,[40]=16384,[41]=16384,[42]=16384,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[2]={[1]=256,[2]=0,[3]=256,[4]=0,[5]=0,[6]=256,[7]=0,[8]=256,[9]=0,[10]=0,[11]=0,[12]=0,[13]=256,[14]=0,[15]=256,[16]=0,[17]=0,[18]=0,[19]=0,[20]=256,[21]=0,[22]=256,[23]=0,[24]=0,[25]=0,[26]=0,[27]=256,[28]=0,[29]=16384,[30]=0,[31]=0,[32]=0,[33]=0,[34]=16384,[35]=0,[36]=16384,[37]=0,[38]=16384,[39]=0,[40]=0,[41]=0,[42]=0,[43]=16384,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[3]={[1]=256,[2]=0,[3]=0,[4]=256,[5]=0,[6]=256,[7]=0,[8]=256,[9]=0,[10]=0,[11]=0,[12]=0,[13]=256,[14]=0,[15]=256,[16]=0,[17]=0,[18]=0,[19]=0,[20]=256,[21]=0,[22]=256,[23]=256,[24]=256,[25]=256,[26]=256,[27]=256,[28]=0,[29]=16384,[30]=16384,[31]=16384,[32]=16384,[33]=16384,[34]=16384,[35]=0,[36]=16384,[37]=0,[38]=16384,[39]=0,[40]=0,[41]=0,[42]=0,[43]=16384,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[4]={[1]=256,[2]=0,[3]=0,[4]=0,[5]=256,[6]=256,[7]=0,[8]=256,[9]=0,[10]=0,[11]=0,[12]=0,[13]=256,[14]=0,[15]=256,[16]=0,[17]=0,[18]=0,[19]=0,[20]=256,[21]=0,[22]=256,[23]=0,[24]=0,[25]=0,[26]=0,[27]=256,[28]=0,[29]=16384,[30]=0,[31]=0,[32]=0,[33]=0,[34]=16384,[35]=0,[36]=16384,[37]=0,[38]=16384,[39]=16384,[40]=16384,[41]=16384,[42]=16384,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[5]={[1]=256,[2]=0,[3]=0,[4]=0,[5]=0,[6]=256,[7]=0,[8]=256,[9]=0,[10]=0,[11]=0,[12]=0,[13]=256,[14]=0,[15]=0,[16]=256,[17]=0,[18]=0,[19]=256,[20]=0,[21]=0,[22]=256,[23]=0,[24]=0,[25]=0,[26]=0,[27]=256,[28]=0,[29]=16384,[30]=0,[31]=0,[32]=0,[33]=0,[34]=16384,[35]=0,[36]=16384,[37]=0,[38]=16384,[39]=0,[40]=0,[41]=0,[42]=16384,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[6]={[1]=256,[2]=0,[3]=0,[4]=0,[5]=0,[6]=256,[7]=0,[8]=256,[9]=256,[10]=256,[11]=256,[12]=256,[13]=256,[14]=0,[15]=0,[16]=0,[17]=256,[18]=256,[19]=0,[20]=0,[21]=0,[22]=256,[23]=0,[24]=0,[25]=0,[26]=0,[27]=256,[28]=0,[29]=16384,[30]=0,[31]=0,[32]=0,[33]=0,[34]=16384,[35]=0,[36]=16384,[37]=0,[38]=16384,[39]=0,[40]=0,[41]=0,[42]=0,[43]=16384,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[7]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[8]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[9]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[10]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[11]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[12]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[13]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[14]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[15]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[16]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[17]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[18]={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},}
  1231.  
  1232. local InstallDirectory = "/.NovaAir"
  1233. local InstallDir = InstallDirectory
  1234. local Version = "1.1.8"
  1235.  
  1236. if turtle then
  1237.     printError("Why are you running this on a turtle?")
  1238.     return
  1239. end
  1240.  
  1241. local W, H = term.getSize()
  1242. if W ~= 51 or H ~= 19 then
  1243.     printError("NovaAir is only supported on a 51 x 19 sized terminal.")
  1244.     return
  1245. end
  1246.  
  1247. if not term.isColor() then
  1248.     printError("NovaAir is only supported on a colored terminal.")
  1249.     return
  1250. end
  1251.  
  1252. local StartUI = NewUI()
  1253. StartUI:BackgroundColor(colors.white)
  1254.  
  1255. local Logo = StartUI:New("ImageLabel")
  1256. Logo:Image(LogoImage)
  1257. Logo:ShowBackground(false)
  1258. Logo:Size(W, 7)
  1259. Logo:Position(5, 4)
  1260.  
  1261. local Output = StartUI:New("TextLabel")
  1262. Output:Size(W, 8)
  1263. Output:BackgroundColor(colors.black)
  1264. Output:Position(1, H - 8 + 1)
  1265.  
  1266. local TopBorder = StartUI:New("TextLabel")
  1267. TopBorder:Size(W, 1)
  1268. TopBorder:Position(1, H - 8)
  1269. TopBorder:BackgroundColor(colors.gray)
  1270. TopBorder:TextColor(colors.lightGray)
  1271. TopBorder:Text("NovaAir by alakazard12")
  1272.  
  1273. local OutputTexts = {}
  1274. for i = 1, 8 do
  1275.     local Temp = Output:New("TextLabel")
  1276.     Temp:Size(W, 1)
  1277.     Temp:Position(1, i)
  1278.     Temp:ShowBackground(false)
  1279.     Temp:TextXAlignment(0)
  1280.  
  1281.     OutputTexts[i] = Temp
  1282. end
  1283.  
  1284. local LinesPassed = 0
  1285.  
  1286. local function PrintOutput(Text)
  1287.     Text = "> " .. Text
  1288.     LinesPassed = LinesPassed + 1
  1289.  
  1290.     if LinesPassed > 8 then
  1291.         for i = 2, 8 do
  1292.             OutputTexts[i - 1]:Text(OutputTexts[i]:GetText())
  1293.             OutputTexts[i - 1]:Draw()
  1294.         end
  1295.  
  1296.         OutputTexts[8]:Text(Text)
  1297.         OutputTexts[8]:Draw()
  1298.     else
  1299.         OutputTexts[LinesPassed]:Text(Text)
  1300.         OutputTexts[LinesPassed]:Draw()
  1301.     end
  1302. end
  1303.  
  1304. --[[local ToB = false
  1305. local Der = loadstring('\27\76\117\97\81\0\0\4\4\4\8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\13\0\0\0\145\0\0\0\36\0\0\64\100\0\0\0\133\1\64\64\139\1\0\64\156\0\0\128\133\0\0\192\193\0\1\1\5\1\129\0\213\1\0\64\156\0\0\128\133\0\1\64\193\1\0\64\156\0\1\128\129\0\0\192\202\0\0\129\10\0\0\65\74\1\0\1\128\0\2\129\193\3\1\193\149\132\129\129\73\132\1\65\9\0\0\65\74\1\0\1\128\0\3\1\193\3\1\193\149\132\129\129\73\133\129\65\9\131\129\0\201\0\0\1\10\134\129\0\201\0\0\1\10\135\1\0\201\0\3\193\5\0\0\65\26\128\0\128\22\0\0\129\5\0\4\1\65\1\0\65\28\0\0\1\0\1\0\1\64\0\1\1\129\2\129\129\85\1\0\129\28\0\0\1\64\1\0\1\128\0\4\65\193\3\1\193\149\1\0\129\92\0\1\1\133\2\1\128\87\128\5\192\22\0\0\129\133\0\4\129\193\1\0\65\156\0\4\193\133\3\69\1\134\0\5\65\197\3\197\129\198\0\128\1\220\0\0\65\156\0\128\1\128\1\0\1\192\0\4\66\1\3\130\1\213\0\5\66\5\4\69\130\6\0\128\2\28\0\0\65\156\0\5\65\133\3\69\193\134\0\5\65\197\3\197\129\198\0\128\1\220\0\0\65\156\0\128\0\30\0\4\193\133\3\70\1\134\0\5\65\197\3\197\129\198\0\128\129\220\0\6\66\1\1\128\129\156\3\70\129\198\0\128\129\220\3\70\194\6\0\128\66\28\2\129\192\87\128\7\64\22\2\199\0\87\128\6\192\22\0\0\130\5\0\7\66\65\1\0\66\28\0\4\194\5\4\69\2\6\0\5\66\69\4\197\130\70\0\128\2\92\0\0\66\28\0\4\194\5\4\70\2\6\0\5\66\69\4\197\130\70\0\128\130\92\0\7\130\129\1\128\130\28\4\71\194\70\2\128\2\128\1\0\66\92\4\70\194\70\0\128\66\92\0\5\66\69\4\197\194\70\0\5\66\133\5\69\130\134\0\128\2\156\0\0\66\92\0\128\0\30\0\4\194\5\4\72\2\6\0\8\66\69\1\0\130\28\0\0\66\26\128\2\64\22\0\4\194\5\4\72\130\6\0\8\66\69\1\0\66\28\0\0\130\5\0\8\194\65\0\8\66\133\0\9\2\193\4\130\194\85\1\0\66\28\4\0\2\3\0\0\130\36\4\0\0\0\0\128\0\0\4\0\2\64\0\8\66\133\1\128\2\192\0\9\67\1\2\0\66\92\0\128\0\30\0\0\0\38\4\0\0\0\8\83\116\97\114\116\85\73\0\4\0\0\0\5\68\114\97\119\0\4\0\0\0\12\80\114\105\110\116\79\117\116\112\117\116\0\4\0\0\0\27\76\97\117\110\99\104\105\110\103\32\78\111\118\97\65\105\114\32\118\101\114\115\105\111\110\32\0\4\0\0\0\8\86\101\114\115\105\111\110\0\4\0\0\0\42\67\104\101\99\107\105\110\103\32\102\111\114\32\109\105\115\115\105\110\103\32\112\97\99\107\97\103\101\115\32\97\110\100\32\117\112\100\97\116\101\115\0\4\0\0\0\51\104\116\116\112\115\58\47\47\114\97\119\46\103\105\116\104\117\98\46\99\111\109\47\97\108\97\107\97\122\97\114\100\49\50\47\78\111\118\97\65\105\114\47\109\97\115\116\101\114\47\0\4\0\0\0\6\80\97\103\101\115\0\4\0\0\0\5\104\111\109\101\0\4\0\0\0\6\105\110\100\101\120\0\4\0\0\0\21\80\97\103\101\115\47\104\111\109\101\47\105\110\100\101\120\124\49\46\48\0\4\0\0\0\7\115\101\114\118\101\114\0\4\0\0\0\23\80\97\103\101\115\47\115\101\114\118\101\114\47\105\110\100\101\120\124\49\46\48\0\4\0\0\0\7\67\104\97\99\104\101\0\4\0\0\0\8\83\101\114\118\101\114\115\0\4\0\0\0\5\104\116\116\112\0\4\0\0\0\43\72\84\84\80\32\105\115\32\110\111\116\32\101\110\97\98\108\101\100\44\32\78\111\118\97\65\105\114\32\109\97\121\32\110\111\116\32\119\111\114\107\46\0\4\0\0\0\8\78\111\118\97\65\105\114\0\4\0\0\0\22\78\101\119\32\118\101\114\115\105\111\110\32\97\118\97\105\108\97\98\108\101\0\4\0\0\0\3\102\115\0\4\0\0\0\7\100\101\108\101\116\101\0\4\0\0\0\6\115\104\101\108\108\0\4\0\0\0\18\103\101\116\82\117\110\110\105\110\103\80\114\111\103\114\97\109\0\4\0\0\0\4\114\117\110\0\4\0\0\0\5\111\112\101\110\0\4\0\0\0\2\114\0\4\0\0\0\8\114\101\97\100\65\108\108\0\4\0\0\0\6\99\108\111\115\101\0\4\0\0\0\23\69\114\114\111\114\32\100\111\119\110\108\111\97\100\105\110\103\32\102\105\108\101\0\4\0\0\0\22\78\111\118\97\65\105\114\32\103\111\116\32\99\111\114\114\117\112\116\101\100\0\4\0\0\0\2\119\0\4\0\0\0\6\119\114\105\116\101\0\4\0\0\0\7\101\120\105\115\116\115\0\4\0\0\0\11\73\110\115\116\97\108\108\68\105\114\0\4\0\0\0\8\109\97\107\101\68\105\114\0\4\0\0\0\10\67\114\101\97\116\101\100\32\39\0\4\0\0\0\2\39\0\4\0\0\0\1\0\0\0\0\3\0\0\0\0\0\0\0\1\0\0\0\15\0\1\0\4\0\0\0\23\0\0\0\69\0\0\64\90\128\0\64\22\0\0\64\65\1\0\0\94\0\0\0\69\0\192\128\70\0\0\0\128\1\0\128\92\0\0\64\90\128\1\64\22\0\0\192\133\0\1\0\193\1\0\64\156\0\1\0\129\1\0\0\158\128\1\0\22\0\193\64\134\0\128\128\156\0\193\128\198\0\128\64\220\1\0\0\158\0\128\0\30\0\0\0\7\4\0\0\0\5\104\116\116\112\0\4\0\0\0\17\72\84\84\80\32\110\111\116\32\101\110\97\98\108\101\100\0\4\0\0\0\4\103\101\116\0\4\0\0\0\12\80\114\105\110\116\79\117\116\112\117\116\0\4\0\0\0\23\69\114\114\111\114\32\100\111\119\110\108\111\97\100\105\110\103\32\102\105\108\101\0\4\0\0\0\8\114\101\97\100\65\108\108\0\4\0\0\0\6\99\108\111\115\101\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\17\0\0\0\31\0\2\0\6\0\0\0\28\0\0\0\133\0\0\64\154\128\0\0\22\0\128\0\30\0\0\0\133\1\64\64\134\0\0\0\192\1\0\128\156\0\0\64\154\128\0\192\22\0\0\128\197\0\0\193\1\1\0\64\220\128\3\0\22\0\1\0\197\1\193\64\198\0\128\1\0\0\1\129\65\1\128\128\220\1\193\193\6\1\66\1\70\0\128\1\92\0\0\65\28\1\194\65\6\0\128\65\28\1\66\65\6\0\128\65\28\0\128\0\30\0\0\0\10\4\0\0\0\5\104\116\116\112\0\4\0\0\0\4\103\101\116\0\4\0\0\0\12\80\114\105\110\116\79\117\116\112\117\116\0\4\0\0\0\23\69\114\114\111\114\32\100\111\119\110\108\111\97\100\105\110\103\32\102\105\108\101\0\4\0\0\0\3\102\115\0\4\0\0\0\5\111\112\101\110\0\4\0\0\0\2\119\0\4\0\0\0\6\119\114\105\116\101\0\4\0\0\0\8\114\101\97\100\65\108\108\0\4\0\0\0\6\99\108\111\115\101\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\88\0\0\0\122\2\3\0\14\0\0\0\128\0\0\0\197\0\128\1\0\1\0\128\220\1\192\64\23\128\9\0\22\0\0\128\197\1\192\192\198\1\0\1\0\0\1\1\65\0\0\1\128\2\1\129\21\1\0\128\220\0\0\64\218\128\3\0\22\0\1\64\197\0\1\129\1\0\0\1\64\0\1\193\129\2\1\129\21\1\0\64\220\0\0\128\197\1\194\0\198\1\0\1\0\0\1\1\65\0\0\1\128\2\1\129\21\1\0\64\220\0\2\64\197\0\128\1\0\1\1\0\220\128\1\192\22\0\0\2\4\3\0\2\64\3\128\2\128\1\0\2\192\0\1\3\1\0\0\3\64\5\131\66\213\2\0\66\28\0\0\128\225\127\253\64\22\128\21\0\22\0\0\0\194\0\2\129\5\2\66\193\6\0\128\1\64\0\3\1\129\1\128\129\28\0\195\65\75\0\3\129\193\2\67\130\13\2\0\129\92\0\195\65\139\2\67\130\12\1\128\129\156\0\0\129\197\3\192\193\198\1\0\2\0\0\1\2\65\0\0\2\128\4\2\130\21\1\0\129\220\0\0\1\218\128\1\192\22\0\0\129\197\3\192\193\198\1\0\2\0\0\3\194\65\4\2\66\21\1\0\129\220\0\0\65\218\128\0\64\22\0\128\0\194\128\6\64\22\0\0\129\197\3\196\1\198\1\0\2\0\0\3\194\65\4\2\66\21\0\4\66\65\1\128\129\220\3\196\130\6\0\128\130\28\3\2\0\87\128\3\0\22\0\0\130\5\4\68\194\6\1\0\2\64\0\3\194\129\4\130\130\85\1\0\66\28\0\0\130\5\4\68\194\6\1\0\2\64\0\1\2\129\0\0\2\192\4\130\194\85\1\0\66\28\3\197\2\6\0\128\66\28\1\197\64\23\128\6\0\22\0\1\65\197\0\5\130\1\0\0\2\64\0\1\194\129\4\2\130\21\1\0\65\220\0\128\1\196\2\128\2\0\1\0\2\64\0\1\2\129\0\0\2\192\4\130\194\85\1\128\65\220\0\0\129\197\3\196\1\198\1\0\2\0\0\3\194\65\4\2\66\21\0\5\194\65\1\128\129\220\3\198\2\6\3\0\2\64\1\0\66\28\3\197\2\6\0\128\66\28\0\128\0\30\0\0\0\25\4\0\0\0\5\116\121\112\101\0\4\0\0\0\6\116\97\98\108\101\0\4\0\0\0\3\102\115\0\4\0\0\0\7\101\120\105\115\116\115\0\4\0\0\0\2\47\0\4\0\0\0\12\80\114\105\110\116\79\117\116\112\117\116\0\4\0\0\0\11\67\114\101\97\116\105\110\103\32\39\0\4\0\0\0\2\39\0\4\0\0\0\8\109\97\107\101\68\105\114\0\4\0\0\0\6\112\97\105\114\115\0\4\0\0\0\7\115\116\114\105\110\103\0\4\0\0\0\5\102\105\110\100\0\4\0\0\0\2\124\0\4\0\0\0\4\115\117\98\0\3\63\240\0\0\0\0\0\0\4\0\0\0\9\47\86\101\114\115\105\111\110\0\4\0\0\0\5\111\112\101\110\0\4\0\0\0\2\114\0\4\0\0\0\8\114\101\97\100\65\108\108\0\4\0\0\0\7\100\101\108\101\116\101\0\4\0\0\0\6\99\108\111\115\101\0\1\1\4\0\0\0\14\68\111\119\110\108\111\97\100\105\110\103\32\39\0\4\0\0\0\2\119\0\4\0\0\0\6\119\114\105\116\101\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', "Updater")
  1306. setfenv(Der, setmetatable({["Version"] = Version; ["StartUI"] = StartUI; ["PrintOutput"] = PrintOutput; ["InstallDir"] = InstallDir; ["shell"] = shell}, {__index = getfenv()}))
  1307. ToB = Der()
  1308. if ToB == true then
  1309.     PrintOutput("Stopping")
  1310.     return
  1311. end ]]
  1312.  
  1313. local function GetData(URL)
  1314.     local Handle = http.get(URL)
  1315.     if Handle then
  1316.         local Data = Handle.readAll()
  1317.         Handle.close()
  1318.         return Data
  1319.     else
  1320.         return nil
  1321.     end
  1322. end
  1323.  
  1324. StartUI:Draw()
  1325. PrintOutput("Checking for updates")
  1326.  
  1327. if not http then
  1328.     PrintOutput("HTTP not enabled, cannot check for updates or install necessary files")
  1329. else
  1330.     local NVersion = GetData("https://raw.github.com/alakazard12/NovaAir/master/Version")
  1331.     if NVersion ~= Version then
  1332.         PrintOutput("Update available (" .. NVersion .. ")")
  1333.         local New = GetData("https://raw.github.com/alakazard12/NovaAir/master/NovaAir")
  1334.         local Prog = shell.getRunningProgram()
  1335.         local File = fs.open(Prog, "w")
  1336.         File.write(New)
  1337.         File.close()
  1338.         PrintOutput("Updated NovaAir")
  1339.         shell.run("/" .. Prog)
  1340.         return
  1341.     end
  1342.     if not fs.exists(InstallDirectory) then
  1343.         fs.makeDir(InstallDirectory)
  1344.     end
  1345.     local DFiles = {
  1346.         ["Cache"] = {
  1347.         };
  1348.         ["Pages"] = {
  1349.             ["home"] = {
  1350.                 ["Version"] = "1.0";
  1351.                 ["index"] = "https://raw.github.com/alakazard12/NovaAir/master/Pages/home/index";
  1352.             };
  1353.             ["server"] = {
  1354.                 ["index"] = "https://raw.github.com/alakazard12/NovaAir/master/Pages/server/index";
  1355.                 ["Version"] = "1.1.3";
  1356.             };
  1357.             ["search"] = {
  1358.                 ["index"] = "https://raw.github.com/alakazard12/NovaAir/master/Pages/search/index";
  1359.                 ["Version"] = "1.1.5";
  1360.             };
  1361.             ["help"] = {
  1362.                 ["index"] = "https://raw.github.com/alakazard12/NovaAir/master/Pages/help/index";
  1363.                 ["Version"] = "1.1";
  1364.             };
  1365.             ["pages"] = {
  1366.                 ["index"] = "https://raw.github.com/alakazard12/NovaAir/master/Pages/pages/index";
  1367.                 ["Version"] = "1.2";
  1368.             };
  1369.         };
  1370.         ["Servers"] = {
  1371.  
  1372.         };
  1373.     }
  1374.  
  1375.     local CheckDirectory
  1376.     function CheckDirectory(Path, Files, Name)
  1377.         for i,v in pairs(Files) do
  1378.             if type(v) == "table" then
  1379.                 if not fs.exists(Path .. "/" .. i) then
  1380.                     fs.makeDir(Path .. "/" .. i)
  1381.                 end
  1382.                 CheckDirectory(Path .. "/" .. i, v, i)
  1383.             elseif type(v) == "string" and i ~= "index" then
  1384.                 if i == "Version" then
  1385.                     if not fs.exists(Path .. "/" .. i) then
  1386.                         local File = fs.open(Path .. "/" .. i, "w")
  1387.                         File.write(v)
  1388.                         File.close()
  1389.                     else
  1390.                         local File = fs.open(Path .. "/" .. i, "r")
  1391.                         local FVersion = File.readAll()
  1392.                         File.close()
  1393.                         if FVersion ~= v then
  1394.                             local Data = GetData(Files["index"])
  1395.                             local File = fs.open(Path .. "/index", "w")
  1396.                             File.write(Data)
  1397.                             File.close()
  1398.                             File = fs.open(Path .. "/" .. i, "w")
  1399.                             File.write(v)
  1400.                             File.close()
  1401.                             PrintOutput("Updated " .. Name)
  1402.                         end
  1403.                     end
  1404.                     if not fs.exists(Path .. "/index") then
  1405.                         local File = fs.open(Path .. "/index", "w")
  1406.                         local Data = GetData(Files["index"])
  1407.                         File.write(Data)
  1408.                         File.close()
  1409.                         PrintOutput("Installed " .. Name)
  1410.                     end
  1411.                 end
  1412.             end
  1413.         end
  1414.     end
  1415.     CheckDirectory(InstallDirectory, DFiles)
  1416. end
  1417.  
  1418. PrintOutput("Opening modem")
  1419.  
  1420. local HasModem
  1421. for _,Side in pairs(rs.getSides()) do
  1422.     if peripheral.getType(Side) == "modem" then
  1423.         HasModem = Side
  1424.         peripheral.call(Side, "open", 8964)
  1425.         break
  1426.     end
  1427. end
  1428.  
  1429. if not HasModem then
  1430.     PrintOutput("No modem detected. Attach a modem and re-launch.")
  1431. end
  1432.  
  1433. if not tArgs[1] then
  1434.     PrintOutput("Click any key to continue")
  1435.     os.pullEventRaw("key")
  1436. end
  1437.  
  1438. if not HasModem then
  1439.     term.setCursorPos(1, 1)
  1440.     term.setBackgroundColor(colors.black)
  1441.     term.clear()
  1442.     return
  1443. end
  1444.  
  1445. CheckFile = nil
  1446. InstallFiles = nil
  1447. Repo = nil
  1448. PrintOutput = nil
  1449. DownloadFile = nil
  1450. OutputTexts = nil
  1451. TopBorder = nil
  1452. Output = nil
  1453. Logo = nil
  1454. StartUI = nil
  1455. LogoImage = nil
  1456. SyncCheck = nil
  1457. CVersion = nil
  1458. GetFile = nil
  1459. Con = nil
  1460. File = nil
  1461.  
  1462. local MainUI = NewUI()
  1463. MainUI:BackgroundColor(colors.lightGray)
  1464.  
  1465. local Index
  1466.  
  1467. local ABegin = MainUI:New("TextLabel")
  1468. ABegin:Size(7, 1)
  1469. ABegin:BackgroundColor(colors.white)
  1470. ABegin:Text("Nova://")
  1471. ABegin:TextColor(colors.black)
  1472.  
  1473. local AInput = MainUI:New("TextBox")
  1474. AInput:Size(W - 10, 1)
  1475. AInput:Position(8, 1)
  1476. AInput:Text("home")
  1477. AInput:BackgroundColor(colors.white)
  1478. AInput:TextColor(colors.black)
  1479. AInput:Overlap(true)
  1480. AInput:ActiveTextColor(colors.white)
  1481. AInput:TextXAlignment(0)
  1482.  
  1483. local function DrawIndex()
  1484.     if Index then
  1485.         Index:Destroy()
  1486.     end
  1487.  
  1488.     Index = MainUI:New("TextLabel")
  1489.     Index:Size(W, H - 1)
  1490.     Index:Position(1, 2)
  1491.     Index:BackgroundColor(colors.lightGray)
  1492. end
  1493.  
  1494. local function ErrorPage(Head, Error, Suggest)
  1495.     DrawIndex()
  1496.     local Title = Index:New("TextLabel")
  1497.     Title:Size(W, 3)
  1498.     Title:BackgroundColor(colors.gray)
  1499.     Title:TextColor(colors.black)
  1500.     Title:MultiLine(true)
  1501.     Title:Text(Head)
  1502.  
  1503.     local Err = Index:New("TextLabel")
  1504.     Err:Size(W, 3)
  1505.     Err:Position(1, 5)
  1506.     Err:ShowBackground(false)
  1507.     Err:TextColor(colors.red)
  1508.     Err:Text(Error)
  1509.     Err:MultiLine(true)
  1510.  
  1511.     local Sug = Index:New("TextLabel")
  1512.     Sug:Size(W, 3)
  1513.     Sug:ShowBackground(false)
  1514.     Sug:Position(1, 10)
  1515.     Sug:Text(Suggest)
  1516.     Sug:TextColor(colors.blue)
  1517.     Sug:MultiLine(true)
  1518.  
  1519.     Index:Draw()
  1520. end
  1521.  
  1522. local DrawPage
  1523. function DrawPage(Text, Arg)
  1524.     DrawIndex()
  1525.     Index:Draw()
  1526.  
  1527.     if Text:sub(#Text, #Text) == " " then
  1528.         repeat
  1529.             Text = Text:sub(1, #Text - 1)
  1530.         until Text:sub(#Text, #Text) ~= " "
  1531.     end
  1532.     local Args = {}
  1533.     for Arg in Text:gmatch("([^/]+)") do
  1534.         table.insert(Args, Arg)
  1535.     end
  1536.  
  1537.     if #Args == 0 then
  1538.         Args[1] = "help"
  1539.     end
  1540.  
  1541.     MainUI:Output()
  1542.     local SiteName = Args[1]
  1543.  
  1544.     if fs.exists(InstallDir .. "/Pages/" .. Args[1]) then
  1545.         local File = InstallDir .. "/Pages/" .. Args[1]
  1546.         if #Args > 1 then
  1547.             table.remove(Args, 1)
  1548.             for _,Arg in pairs(Args) do
  1549.                 File = File .. "/" .. Arg
  1550.             end
  1551.             if not fs.exists(File) then
  1552.                 File = File .. "/index"
  1553.             end
  1554.         else
  1555.             File = File .. "/index"
  1556.         end
  1557.  
  1558.         if fs.exists(File) then
  1559.             local PageF = fs.open(File, "r")
  1560.             local Page, Error = loadstring(PageF.readAll(), SiteName)
  1561.             PageF.close()
  1562.  
  1563.             if not Page then
  1564.                 ErrorPage("Hmm, looks like a built-in website crashed, that's odd", Error, "Report this error to alakazard12 so it can be fixed ASAP")
  1565.                 return
  1566.             end
  1567.  
  1568.             local Env = {
  1569.                 ["redirect"] = function(Link, Arg)
  1570.                     if type(Link) ~= "string" then
  1571.                         error("bad argument #1: string expected, got " .. type(Link), 2)
  1572.                     end
  1573.  
  1574.                     AInput:Text(Link)
  1575.                     AInput:Draw()
  1576.                     DrawPage(Link, Arg)
  1577.                 end;
  1578.  
  1579.                 ["shell"] = shell;
  1580.  
  1581.                 ["Index"] = Index;
  1582.  
  1583.                 ["Output"] = function(Arg)
  1584.                     return MainUI:Output(Arg)
  1585.                 end;
  1586.  
  1587.                 ["ModemSide"] = HasModem;
  1588.  
  1589.                 --[[["Listen"] = function()
  1590.                     return MainUI:Listen()
  1591.                 end;
  1592.  
  1593.                 ["StopListen"] = function()
  1594.                     return MainUI:StopListen()
  1595.                 end; ]]
  1596.  
  1597.                 ["Draw"] = function()
  1598.                     return MainUI:Draw()
  1599.                 end;
  1600.             }
  1601.  
  1602.             setmetatable(Env, {__index = _G})
  1603.             setfenv(Page, Env)
  1604.  
  1605.             MainUI:ErrorHandle(function(Error)
  1606.                 ErrorPage("Hmm, looks like a built-in website crashed, that's odd", Error, "Report this error to alakazard12 so it can be fixed ASAP")
  1607.             end)
  1608.  
  1609.             local Co = coroutine.create(Page)
  1610.            
  1611.             local Success, Error
  1612.             if Arg then
  1613.                 Success, Error = coroutine.resume(Co, Arg)
  1614.             else
  1615.                 Success, Error = coroutine.resume(Co)
  1616.             end
  1617.  
  1618.             if Success == false then
  1619.                 ErrorPage("Oh no, NovaAir just had an error!", Error, "Report this error to alakazard12 so it can be fixed ASAP")
  1620.             end
  1621.  
  1622.             MainUI:Output(function(Event, P1, P2, P3, P4, P5)
  1623.                 if coroutine.status(Co) == "dead" then
  1624.                     MainUI:Output()
  1625.                     return
  1626.                 end
  1627.  
  1628.                 if Error then
  1629.                     if Event == Error then
  1630.                         Success, Error = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
  1631.                     end
  1632.                 else
  1633.                     Success, Error = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
  1634.                 end
  1635.  
  1636.                 if Success == false then
  1637.                     ErrorPage("Oh no, NovaAir just had an error!", Error, "Report this error to alakazard12 so it can be fixed ASAP")
  1638.                 end
  1639.             end)
  1640.  
  1641.             --[[local Co = coroutine.create(Page)
  1642.             local EWant, Err
  1643.  
  1644.             EWant = coroutine.resume(Co)
  1645.            
  1646.             while true do
  1647.                 if coroutine.status(Co) == "suspended" then
  1648.                     local Event, P1, P2, P3, P4, P5 = coroutine.yield()
  1649.                     if EWant then
  1650.                         if Event == EWant then
  1651.                             EWant, Err = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
  1652.                         end
  1653.                     else
  1654.                         EWant, Err = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
  1655.                     end
  1656.                 elseif coroutine.status(Co) == "dead" then
  1657.                     break
  1658.                 end
  1659.             end]]
  1660.         end
  1661.     else
  1662.         if not HasModem then return end
  1663.         peripheral.call(HasModem, "transmit", 8964, os.getComputerID(), textutils.serialize({"NovaAir", "Find", Text}))
  1664.         local Timer = os.startTimer(0.2)
  1665.         MainUI:Output(function(Event, P1, P2, P3, P4, P5)
  1666.             if Event == "timer" and P1 == Timer then
  1667.                 ErrorPage("NovaAir could not find the site you're looking for", "", "If you believe this is an error, contact the operator")
  1668.             elseif Event == "modem_message" then
  1669.                 if P2 == 8964 then
  1670.                     local Args = textutils.unserialize(P4)
  1671.                     if type(Args) == "table" then
  1672.                         if Args[1] == "NovaAir" then
  1673.                             if Args[2] == "Site" then
  1674.                                 if Args[3] and Args[3]:lower() == Text:lower() and Args[4] then
  1675.                                     MainUI:Output()
  1676.                                     local Page, Error = loadstring(Args[4], SiteName)
  1677.                                     if not Page then
  1678.                                         ErrorPage("Oh no! The website has just crashed!", Error, "Report this error to the site operator so it can be fixed.")
  1679.                                         return
  1680.                                     end
  1681.  
  1682.                                     local Stop = false
  1683.  
  1684.                                     local allowed = {}
  1685.  
  1686.                                     local function RequestF(Req, Func, ...)
  1687.                                         if allowed[Func] == true then
  1688.                                             return Func(...)
  1689.                                         end
  1690.                                         Stop = true
  1691.                                         local Sac
  1692.                                         local OverF = MainUI:New("TextLabel")
  1693.                                         OverF:Text("")
  1694.                                         OverF:Size(51, 1)
  1695.                                         OverF:ZIndex(100)
  1696.                                         OverF:BackgroundColor(colors.red)
  1697.  
  1698.                                         local Text = OverF:New("TextLabel")
  1699.                                         Text:Size(29, 1)
  1700.                                         Text:ShowBackground(false)
  1701.                                         Text:Text(Req)
  1702.                                         Text:TextXAlignment(0)
  1703.  
  1704.                                         local Yes = OverF:New("TextButton")
  1705.                                         Yes:Size(10, 1)
  1706.                                         Yes:Position(31, 1)
  1707.                                         Yes:Text("[ Allow ]")
  1708.                                         Yes:ShowBackground(false)
  1709.                                         Yes:Button1Click(function()
  1710.                                             Sac = "yes"
  1711.                                         end)
  1712.  
  1713.                                         local No = OverF:New("TextButton")
  1714.                                         No:Size(10, 1)
  1715.                                         No:Position(41, 1)
  1716.                                         No:Text("[ Deny ]")
  1717.                                         No:ShowBackground(false)
  1718.                                         No:Button1Click(function()
  1719.                                             Sac = "no"
  1720.                                         end)
  1721.  
  1722.                                         OverF:Draw()
  1723.  
  1724.                                         repeat sleep(0) until Sac ~= nil
  1725.  
  1726.  
  1727.                                         OverF:Destroy()
  1728.                                         MainUI:Draw()
  1729.                                         Stop = false
  1730.                                         term.setCursorPos(1, 1)
  1731.                                         if Sac == "yes" then
  1732.                                             allowed[Func] = true
  1733.                                             return Func(...)
  1734.                                         else
  1735.                                             return
  1736.                                         end
  1737.                                     end
  1738.  
  1739.                                     local Env = {
  1740.                                         ["redirect"] = function(Link, Arg)
  1741.                                             if type(Link) ~= "string" then
  1742.                                                 error("bad argument #1: string expected, got " .. type(Link), 2)
  1743.                                             end
  1744.  
  1745.                                             AInput:Text(Link)
  1746.                                             AInput:Draw()
  1747.                                             DrawPage(Link, Arg)
  1748.                                         end;
  1749.  
  1750.                                         ["Index"] = Index;
  1751.  
  1752.                                         ["Output"] = function(Arg)
  1753.                                             return MainUI:Output(Arg)
  1754.                                         end;
  1755.  
  1756.                                         ["ModemSide"] = HasModem;
  1757.  
  1758.                                         ["Draw"] = function()
  1759.                                             return MainUI:Draw()
  1760.                                         end;
  1761.  
  1762.                                         ["os"] = {};
  1763.                                         ["shell"] = {};
  1764.                                         ["fs"] = {};
  1765.                                         ["io"] = {};
  1766.                                         ["term"] = {};
  1767.                                         ["redstone"] = {};
  1768.                                         ["gps"] = {};
  1769.                                         ["keys"] = {};
  1770.                                         ["peripheral"] = {};
  1771.                                         ["bit"] = {};
  1772.                                         ["coroutine"] = {};
  1773.                                         ["disk"] = {};
  1774.                                         ["colors"] = {};
  1775.                                         ["colours"] = {};
  1776.                                         ["math"] = {};
  1777.                                         ["rednet"] = {};
  1778.                                         ["help"] = {};
  1779.                                         ["http"] = {};
  1780.                                         ["string"] = {};
  1781.                                         ["table"] = {};
  1782.                                         ["parallel"] = {};
  1783.                                         ["textutils"] = {};
  1784.                                         ["vector"] = {};
  1785.                                         ["paintutils"] = {};
  1786.  
  1787.                                         ["setfenv"] = function(...)
  1788.                                             return RequestF("Alow setfenv?", setfenv, ...)
  1789.                                         end;
  1790.  
  1791.                                         ["getfenv"] = function(...)
  1792.                                             return RequestF("Alow getfenv?", getfenv, ...)
  1793.                                         end;
  1794.                                     }
  1795.  
  1796.                                     for i,v in pairs(term) do
  1797.                                         Env.term[i] = v
  1798.                                     end
  1799.  
  1800.                                     for i,v in pairs(redstone) do
  1801.                                         Env.redstone[i] = v
  1802.                                     end
  1803.  
  1804.                                     for i,v in pairs(gps) do
  1805.                                         Env.gps[i] = v
  1806.                                     end
  1807.  
  1808.                                     for i,v in pairs(keys) do
  1809.                                         Env.keys[i] = v
  1810.                                     end
  1811.  
  1812.                                     for i,v in pairs(peripheral) do
  1813.                                         Env.peripheral[i] = v
  1814.                                     end
  1815.  
  1816.                                     for i,v in pairs(bit) do
  1817.                                         Env.bit[i] = v
  1818.                                     end
  1819.  
  1820.                                     for i,v in pairs(coroutine) do
  1821.                                         Env.coroutine[i] = v
  1822.                                     end
  1823.  
  1824.                                     for i,v in pairs(disk) do
  1825.                                         Env.disk[i] = v
  1826.                                     end
  1827.  
  1828.                                     for i,v in pairs(colors) do
  1829.                                         Env.colors[i] = v
  1830.                                     end
  1831.  
  1832.                                     for i,v in pairs(colours) do
  1833.                                         Env.colours[i] = v
  1834.                                     end
  1835.  
  1836.                                     for i,v in pairs(math) do
  1837.                                         Env.math[i] = v
  1838.                                     end
  1839.  
  1840.                                     for i,v in pairs(rednet) do
  1841.                                         Env.rednet[i] = v
  1842.                                     end
  1843.  
  1844.                                     for i,v in pairs(help) do
  1845.                                         Env.help[i] = v
  1846.                                     end
  1847.  
  1848.                                     for i,v in pairs(http) do
  1849.                                         Env.http[i] = v
  1850.                                     end
  1851.  
  1852.                                     for i,v in pairs(string) do
  1853.                                         Env.string[i] = v
  1854.                                     end
  1855.  
  1856.                                     for i,v in pairs(table) do
  1857.                                         Env.table[i] = v
  1858.                                     end
  1859.  
  1860.                                     for i,v in pairs(parallel) do
  1861.                                         Env.parallel[i] = v
  1862.                                     end
  1863.  
  1864.                                     for i,v in pairs(textutils) do
  1865.                                         Env.textutils[i] = v
  1866.                                     end
  1867.  
  1868.                                     for i,v in pairs(vector) do
  1869.                                         Env.vector[i] = v
  1870.                                     end
  1871.  
  1872.                                     for i,v in pairs(paintutils) do
  1873.                                         Env.paintutils[i] = v
  1874.                                     end
  1875.  
  1876.                                     Env.rs = Env.redstone
  1877.  
  1878.                                     local osblocked = {
  1879.                                         "run";
  1880.                                         "loadAPI";
  1881.                                         "unloadAPI";
  1882.                                         "shutdown";
  1883.                                         "reboot";
  1884.                                     }
  1885.  
  1886.                                     local shellblocked = {
  1887.                                         "exit";
  1888.                                         "setDir";
  1889.                                         "setPath";
  1890.                                         "setAlias";
  1891.                                         "clearAlias";
  1892.                                         "run";
  1893.                                     }  
  1894.  
  1895.                                     local fsblocked = {
  1896.                                         "open";
  1897.                                         "makeDir";
  1898.                                         "move";
  1899.                                         "copy";
  1900.                                         "delete";
  1901.                                     }  
  1902.  
  1903.                                     local ioblocked = {
  1904.                                         "open";
  1905.                                     }
  1906.                                    
  1907.                                     for i,v in pairs(os) do
  1908.                                         Env.os[i] = v
  1909.                                     end
  1910.  
  1911.                                     for i,v in pairs(osblocked) do
  1912.                                         Env.os[v] = function(...)
  1913.                                             return RequestF("Alow os." .. v .. "?", os[v], ...)
  1914.                                         end
  1915.                                     end
  1916.  
  1917.                                     for i,v in pairs(shell) do
  1918.                                         Env.shell[i] = v
  1919.                                     end
  1920.  
  1921.                                     for i,v in pairs(shellblocked) do
  1922.                                         Env.shell[v] = function(...)
  1923.                                             return RequestF("Alow shell." .. v .. "?", shell[v], ...)
  1924.                                         end
  1925.                                     end
  1926.  
  1927.                                     for i,v in pairs(fs) do
  1928.                                         Env.fs[i] = v
  1929.                                     end
  1930.  
  1931.                                     for i,v in pairs(fsblocked) do
  1932.                                         Env.fs[v] = function(...)
  1933.                                             return RequestF("Alow fs." .. v .. "?", fs[v], ...)
  1934.                                         end
  1935.                                     end
  1936.  
  1937.                                     for i,v in pairs(io) do
  1938.                                         Env.io[i] = v
  1939.                                     end
  1940.  
  1941.                                     for i,v in pairs(ioblocked) do
  1942.                                         Env.io[v] = function(...)
  1943.                                             return RequestF("Alow io." .. v .. "?", io[v], ...)
  1944.                                         end
  1945.                                     end
  1946.                                     Env.os.queueEvent = nil
  1947.  
  1948.                                     setmetatable(Env, {__metatable = "THIS S" .. "H" .. "I" .. "T IS LOCKED"})
  1949.                                     setfenv(Page, Env)
  1950.  
  1951.                                     MainUI:ErrorHandle(function(Error)
  1952.                                         ErrorPage("Oh no! The website has just crashed!", Error, "Report this error to the site operator so it can be fixed.")
  1953.                                     end)
  1954.                                    
  1955.                                     local Co = coroutine.create(Page)
  1956.                                    
  1957.                                     local Success, Error
  1958.                                     if Arg then
  1959.                                         Success, Error = coroutine.resume(Co, Arg)
  1960.                                     else
  1961.                                         Success, Error = coroutine.resume(Co)
  1962.                                     end
  1963.  
  1964.                                     if Success == false then
  1965.                                         ErrorPage("Oh no! The website has just crashed!", Error, "Report this error to the site operator so it can be fixed.")
  1966.                                     end
  1967.  
  1968.                                     MainUI:Output(function(Event, P1, P2, P3, P4, P5)
  1969.                                         if Stop == true then if Event ~= "timer" then return end end
  1970.                                         if coroutine.status(Co) == "dead" then
  1971.                                             MainUI:Output()
  1972.                                             return
  1973.                                         end
  1974.  
  1975.                                         if Error then
  1976.                                             if Event == Error then
  1977.                                                 Success, Error = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
  1978.                                             end
  1979.                                         else
  1980.                                             Success, Error = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
  1981.                                         end
  1982.  
  1983.                                         if Success == false then
  1984.                                             ErrorPage("Oh no! The website has just crashed!", Error, "Report this error to the site operator so it can be fixed.")
  1985.                                         end
  1986.                                     end)
  1987.                                 end
  1988.                             end
  1989.                         end
  1990.                     end
  1991.                 end
  1992.             end
  1993.         end)
  1994.     end
  1995. end
  1996.  
  1997. AInput:EnterPress(function()
  1998.     DrawPage(AInput:GetText():lower())
  1999. end)
  2000.  
  2001. local AClose = MainUI:New("TextButton")
  2002. AClose:Size(3, 1)
  2003. AClose:Position(W - 2, 1)
  2004. AClose:Text("X")
  2005. AClose:BackgroundColor(colors.gray)
  2006. AClose:TextColor(colors.black)
  2007. AClose:Button1Click(function()
  2008.     MainUI:StopListen()
  2009.     term.setBackgroundColor(colors.black)
  2010.     term.clear()
  2011.     term.setCursorPos(1, 1)
  2012. end)
  2013.  
  2014. MainUI:Draw()
  2015.  
  2016. if tArgs[1] then
  2017.     AInput:Text(tArgs[1])
  2018.     AInput:Draw()
  2019.     local Pg = tArgs[1]
  2020.     table.remove(tArgs, 1)
  2021.     DrawPage(Pg, table.concat(tArgs, " "))
  2022. else
  2023.     DrawPage("home")
  2024. end
  2025.  
  2026. MainUI:Listen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement