Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Nova GUI API lightweight edition. By alakazard12
- -- Feel free to use this as long as you give me credit, but there's no documentation yet
- local LGW, LGH = term.getSize()
- local VColors = {}
- local VClasses = {
- ["TextButton"] = true;
- ["TextLabel"] = true;
- ["TextBox"] = true;
- ["ImageButton"] = true;
- ["ImageLabel"] = true;
- }
- for _,Color in pairs(colors) do
- if type(Color) == "number" then
- VColors[Color] = true
- end
- end
- local function Round(Number)
- return math.floor(Number + 0.5)
- end
- local Check
- function Check(Object, BG, PX, PY, ChangeP)
- if Object.Visible == true then
- if Object.Class == "TextButton" or Object.Class == "TextBox" or Object.Class == "TextLabel" or Object.Class == "ImageButton" or Object.Class == "ImageLabel" then
- -- if ChangeP ~= true then
- PX = PX + Object.Position[1] - 1
- PY = PY + Object.Position[2] - 1
- -- end
- if Object.ShowBackground == true then
- BG = Object.BackgroundColor
- end
- if Object.Class == "TextBox" and Object.Focused == true then
- BG = Object.ActiveTextColor
- end
- term.setBackgroundColor(BG)
- for Y = 1, Object.Size[2] do
- term.setCursorPos(PX, PY + Y - 1)
- term.write(string.rep(" ", Object.Size[1]))
- end
- if Object.Class == "ImageButton" or Object.Class == "ImageLabel" and Object.Image then
- paintutils.drawImage(Object.Image, PX, PY)
- end
- if Object.Class == "TextButton" or Object.Class == "TextBox" or Object.Class == "TextLabel" then
- if Object.ShowText == true then
- term.setTextColor(Object.TextColor)
- local Text = Object.Text
- if Object.TextChar then
- Text = string.rep(Object.TextChar, #Text)
- end
- if Object.Focused == true then
- Text = Text .. " "
- end
- if Object.MultiLine == true then
- local LastP = 1
- local LastS
- local Lines = {}
- local DidBreak = false
- local RPassed = false
- local ROnLine = false
- local ROnNum
- local RLine
- for On = 1, #Text do
- if Text:sub(On, On) == " " then
- LastS = On
- end
- if On - LastP + 2 > Object.Size[1] then
- if #Lines == Object.Size[2] then
- break
- end
- if LastS then
- table.insert(Lines, Text:sub(LastP, LastS))
- LastP = LastS + 1
- else
- table.insert(Lines, Text:sub(LastP, On))
- LastP = On + 1
- end
- LastS = nil
- if #Lines == Object.Size[2] then
- if Object.Focused == false then
- DidBreak = true
- break
- else
- table.remove(Lines, 1)
- end
- end
- end
- end
- if DidBreak == false then
- table.insert(Lines, Text:sub(LastP))
- elseif Object.Focused == true then
- table.remove(Lines, 1)
- table.insert(Lines, Text:sub(LastP))
- end
- local TextCount = 0
- for _,Line in pairs(Lines) do
- local XA = 0
- local YA = 0
- if Object.TextXAlignment == 0 then
- XA = PX
- elseif Object.TextXAlignment == 1 then
- XA = PX + Round((Object.Size[1] - #Line) / 2)
- else
- XA = PX + Round(Object.Size[1] - #Line)
- end
- if Object.TextYAlignment == 0 then
- YA = PY + _ - 1
- elseif Object.TextYAlignment == 1 then
- YA = PY + Round((Object.Size[2] - #Lines) / 2) + _ - 1
- else
- YA = PY + Round(Object.Size[2] - #Lines) + _ - 1
- end
- term.setCursorPos(XA, YA)
- term.write(Line)
- end
- else
- if #Text > Object.Size[1] then
- if Object.Focused == false then
- Text = string.sub(Text, 1, Object.Size[1])
- -- elseif Object.RTextPos then
- -- Text = string.sub(Text, Object.RTextPos, Object.RTextPos + Object.Size[1] - 1)
- else
- Text = string.sub(Text, #Text - Object.Size[1] + 1, #Text)
- end
- end
- local XA = 0
- local YA = 0
- if Object.TextXAlignment == 0 then
- XA = PX
- elseif Object.TextXAlignment == 1 then
- XA = PX + Round((Object.Size[1] - #Text) / 2)
- else
- XA = PX + Round(Object.Size[1] - #Text)
- end
- if Object.TextYAlignment == 0 then
- YA = PY
- elseif Object.TextYAlignment == 1 then
- YA = PY + Round((Object.Size[2] - 1) / 2)
- else
- YA = PY + Round(Object.Size[2] - 1)
- end
- term.setCursorPos(XA, YA)
- term.write(Text)
- end
- -- if Object.RTextPos == nil then
- Object.TextPos = {term.getCursorPos()}
- Object.TextPos[1] = Object.TextPos[1] - 1
- -- end
- end
- end
- for _,Obj in pairs(Object.Children) do
- Check(Obj, BG, PX, PY)
- end
- end
- end
- end
- local function SortListen(Tbl)
- local Clone = {}
- for _,Item in pairs(Tbl) do
- Clone[_] = Item
- end
- table.sort(Clone, function(A, B)
- return A.ZIndex > B.ZIndex
- end)
- return Clone
- end
- local function NewClass(Par, Class, Main)
- if type(Class) ~= "string" then
- error("bad argument #1: string expected, got " .. type(Class), 2)
- end
- if not VClasses[Class] then
- error("Invalid class name.", 2)
- end
- local PublicTable = {}
- local LocalTable = {}
- LocalTable.Parent = Par
- LocalTable.Class = Class
- function PublicTable:ClearChildren()
- LocalTable.Children = {}
- end
- if Class == "ImageButton" or Class == "ImageLabel" then
- LocalTable.Size = {2, 2}
- LocalTable.Position = {1, 1}
- LocalTable.Visible = true
- LocalTable.Active = true
- LocalTable.Children = {}
- LocalTable.ZIndex = 0
- LocalTable.ShowBackground = true
- function PublicTable:Size(X, Y)
- if type(X) ~= "number" then
- error("bad argument #1: number expected, got " .. type(X), 2)
- end
- if type(Y) ~= "number" then
- error("bad argument #2: number expected, got " .. type(Y), 2)
- end
- LocalTable.Size = {X, Y}
- end
- function PublicTable:Image(Image)
- if type(Image) ~= "table" then
- error("bad argument #1: table expected, got " .. type(Image), 2)
- end
- LocalTable.Image = Image
- end
- function PublicTable:GetSize()
- return unpack(LocalTable.Size)
- end
- function PublicTable:ShowBackground(Bool)
- if type(Bool) ~= "boolean" then
- error("bad argument #1: boolean expected, got " .. type(Bool), 2)
- end
- LocalTable.ShowBackground = Bool
- end
- function PublicTable:GetShowBackground()
- return LocalTable.ShowBackground
- end
- function PublicTable:ZIndex(Number)
- if type(Number) ~= "number" then
- error("bad argument #1: number expected, got " .. type(Number), 2)
- end
- LocalTable.ZIndex = Number
- table.sort(Par.Children, function(A, B)
- return A.ZIndex < B.ZIndex
- end)
- end
- function PublicTable:GetZIndex()
- return LocalTable.ZIndex
- end
- function PublicTable:Position(X, Y)
- if type(X) ~= "number" then
- error("bad argument #1: number expected, got " .. type(X), 2)
- end
- if type(Y) ~= "number" then
- error("bad argument #2: number expected, got " .. type(Y), 2)
- end
- LocalTable.Position = {X, Y}
- end
- function PublicTable:GetPosition()
- return unpack(LocalTable.Position)
- end
- function PublicTable:Visible(Bool)
- if type(Bool) ~= "boolean" then
- error("bad argument #1: boolean expected, got " .. type(Bool), 2)
- end
- LocalTable.Visible = Bool
- end
- function PublicTable:GetVisible()
- return LocalTable.Visible
- end
- function PublicTable:Active(Bool)
- if type(Bool) ~= "boolean" then
- error("bad argument #1: boolean expected, got " .. type(Bool), 2)
- end
- LocalTable.Active = Bool
- end
- function PublicTable:GetActive()
- return LocalTable.Active
- end
- function PublicTable:BackgroundColor(Color)
- if type(Color) ~= "number" then
- error("bad argument #1: number expected, got " .. type(Color), 2)
- end
- if VColors[Color] ~= true then
- error("Invalid color.", 2)
- end
- LocalTable.BackgroundColor = Color
- end
- function PublicTable:GetBackgroundColor()
- return LocalTable.BackgroundColor
- end
- if Class == "ImageButton" then
- function PublicTable:Button1Click(Function)
- if Function == nil then
- LocalTable.Button1Click = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.Button1Click = Function
- end
- end
- function PublicTable:GetButton1Click()
- return LocalTable.Button1Click
- end
- function PublicTable:MouseScroll(Function)
- if Function == nil then
- LocalTable.MouseScroll = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.MouseScroll = Function
- end
- end
- function PublicTable:GetMouseScroll()
- return LocalTable.MouseScroll
- end
- function PublicTable:MouseDrag1(Function)
- if Function == nil then
- LocalTable.MouseDrag1 = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.MouseDrag1 = Function
- end
- end
- function PublicTable:GetMouseDrag1()
- return LocalTable.MouseDrag1
- end
- function PublicTable:MouseDrag2(Function)
- if Function == nil then
- LocalTable.MouseDrag2 = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.MouseDrag2 = Function
- end
- end
- function PublicTable:GetMouseDrag2()
- return LocalTable.MouseDrag2
- end
- function PublicTable:MouseDrag3(Function)
- if Function == nil then
- LocalTable.MouseDrag3 = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.MouseDrag3 = Function
- end
- end
- function PublicTable:GetMouseDrag3()
- return LocalTable.MouseDrag3
- end
- function PublicTable:Button2Click(Function)
- if Function == nil then
- LocalTable.Button2Click = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.Button2Click = Function
- end
- end
- function PublicTable:GetButton2Click()
- return LocalTable.Button2Click
- end
- function PublicTable:Button3Click(Function)
- if Function == nil then
- LocalTable.Button3Click = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.Button3Click = Function
- end
- end
- function PublicTable:GetButton3Click()
- return LocalTable.Button3Click
- end
- end
- function PublicTable:New(Class)
- return NewClass(LocalTable, Class, Main)
- end
- function PublicTable:Draw()
- local BG = Main.BackgroundColor
- local FoundBG = false
- local PX, PY = 1, 1
- local On = LocalTable.Parent
- while On ~= Main do
- PX = PX + On.Position[1] - 1
- PY = PY + On.Position[2] - 1
- if On.ShowBackground and FoundBG == false then
- BG = On.BackgroundColor
- FoundBG = true
- end
- On = On.Parent
- end
- Check(LocalTable, BG, PX, PY)
- end
- elseif Class == "TextButton" or Class == "TextLabel" or Class == "TextBox" then
- LocalTable.Size = {2, 2}
- LocalTable.Position = {1, 1}
- LocalTable.RawText = ""
- LocalTable.Text = ""
- LocalTable.BackgroundColor = colors.cyan
- LocalTable.TextColor = colors.white
- LocalTable.Visible = true
- LocalTable.Active = true
- LocalTable.Children = {}
- LocalTable.ZIndex = 0
- LocalTable.ShowBackground = true
- LocalTable.ShowText = true
- LocalTable.TextXAlignment = 1
- LocalTable.TextYAlignment = 1
- LocalTable.MultiLine = false
- if Class == "TextBox" then
- LocalTable.ActiveTextColor = colors.blue
- LocalTable.Overlap = false
- LocalTable.Focused = false
- LocalTable.ClearTextOnFocus = false
- LocalTable.RTextPos = 8
- end
- function PublicTable:TextXAlignment(Num)
- if type(Num) == "string" then
- if Num:lower() == "left" then
- Num = 0
- elseif Num:lower() == "center" then
- Num = 1
- elseif Num:lower() == "right" then
- Num = 2
- else
- error("bad argument #1: '" .. Num .. "' is not a valid string", 2)
- end
- end
- if type(Num) ~= "number" then
- error("bad argument #1: number expected, got " .. type(X), 2)
- end
- LocalTable.TextXAlignment = Num
- end
- function PublicTable:GetTextXAlignment()
- return LocalTable.TextXAlignment
- end
- function PublicTable:TextYAlignment(Num)
- if type(Num) == "string" then
- if Num:lower() == "top" then
- Num = 0
- elseif Num:lower() == "center" then
- Num = 1
- elseif Num:lower() == "bottom" then
- Num = 2
- else
- error("bad argument #1: '" .. Num .. "' is not a valid string", 2)
- end
- end
- if type(Num) ~= "number" then
- error("bad argument #1: number expected, got " .. type(X), 2)
- end
- LocalTable.TextYAlignment = Num
- end
- function PublicTable:GetTextYAlignment()
- return LocalTable.TextYAlignment
- end
- function PublicTable:Size(X, Y)
- if type(X) ~= "number" then
- error("bad argument #1: number expected, got " .. type(X), 2)
- end
- if type(Y) ~= "number" then
- error("bad argument #2: number expected, got " .. type(Y), 2)
- end
- LocalTable.Size = {X, Y}
- end
- function PublicTable:GetSize()
- return unpack(LocalTable.Size)
- end
- function PublicTable:ShowBackground(Bool)
- if type(Bool) ~= "boolean" then
- error("bad argument #1: boolean expected, got " .. type(Bool), 2)
- end
- LocalTable.ShowBackground = Bool
- end
- function PublicTable:GetShowBackground()
- return LocalTable.ShowBackground
- end
- function PublicTable:ShowText(Bool)
- if type(Bool) ~= "boolean" then
- error("bad argument #1: boolean expected, got " .. type(Bool), 2)
- end
- LocalTable.ShowText = Bool
- end
- function PublicTable:GetShowText()
- return LocalTable.ShowText
- end
- function PublicTable:MultiLine(Bool)
- if type(Bool) ~= "boolean" then
- error("bad argument #1: boolean expected, got " .. type(Bool), 2)
- end
- LocalTable.MultiLine = Bool
- end
- function PublicTable:GetMultiLine()
- return LocalTable.MultiLine
- end
- function PublicTable:ZIndex(Number)
- if type(Number) ~= "number" then
- error("bad argument #1: number expected, got " .. type(Number), 2)
- end
- LocalTable.ZIndex = Number
- table.sort(Par.Children, function(A, B)
- return A.ZIndex < B.ZIndex
- end)
- end
- function PublicTable:GetZIndex()
- return LocalTable.ZIndex
- end
- function PublicTable:Position(X, Y)
- if type(X) ~= "number" then
- error("bad argument #1: number expected, got " .. type(X), 2)
- end
- if type(Y) ~= "number" then
- error("bad argument #2: number expected, got " .. type(Y), 2)
- end
- LocalTable.Position = {X, Y}
- end
- function PublicTable:GetPosition()
- return unpack(LocalTable.Position)
- end
- function PublicTable:Visible(Bool)
- if type(Bool) ~= "boolean" then
- error("bad argument #1: boolean expected, got " .. type(Bool), 2)
- end
- LocalTable.Visible = Bool
- end
- function PublicTable:GetVisible()
- return LocalTable.Visible
- end
- function PublicTable:Active(Bool)
- if type(Bool) ~= "boolean" then
- error("bad argument #1: boolean expected, got " .. type(Bool), 2)
- end
- LocalTable.Active = Bool
- end
- function PublicTable:GetActive()
- return LocalTable.Active
- end
- function PublicTable:Text(Text)
- if Text == nil then
- Text = ""
- end
- if type(Text) ~= "string" then
- error("bad argument #1: string expected, got " .. type(Text), 2)
- end
- LocalTable.Text = Text
- end
- function PublicTable:GetText()
- return LocalTable.Text
- end
- function PublicTable:BackgroundColor(Color)
- if type(Color) ~= "number" then
- error("bad argument #1: number expected, got " .. type(Color), 2)
- end
- if VColors[Color] ~= true then
- error("Invalid color.", 2)
- end
- LocalTable.BackgroundColor = Color
- end
- function PublicTable:GetBackgroundColor()
- return LocalTable.BackgroundColor
- end
- function PublicTable:TextColor(Color)
- if type(Color) ~= "number" then
- error("bad argument #1: number expected, got " .. type(Color), 2)
- end
- if VColors[Color] ~= true then
- error("Invalid color.", 2)
- end
- LocalTable.TextColor = Color
- end
- function PublicTable:GetTextColor()
- return LocalTable.TextColor
- end
- function PublicTable:MouseScroll(Function)
- if Function == nil then
- LocalTable.MouseScroll = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.MouseScroll = Function
- end
- end
- if Class == "TextButton" then
- function PublicTable:Button1Click(Function)
- if Function == nil then
- LocalTable.Button1Click = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.Button1Click = Function
- end
- end
- function PublicTable:GetButton1Click()
- return LocalTable.Button1Click
- end
- function PublicTable:GetMouseScroll()
- return LocalTable.MouseScroll
- end
- function PublicTable:MouseDrag1(Function)
- if Function == nil then
- LocalTable.MouseDrag1 = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.MouseDrag1 = Function
- end
- end
- function PublicTable:GetMouseDrag1()
- return LocalTable.MouseDrag1
- end
- function PublicTable:MouseDrag2(Function)
- if Function == nil then
- LocalTable.MouseDrag2 = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.MouseDrag2 = Function
- end
- end
- function PublicTable:GetMouseDrag2()
- return LocalTable.MouseDrag2
- end
- function PublicTable:MouseDrag3(Function)
- if Function == nil then
- LocalTable.MouseDrag3 = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.MouseDrag3 = Function
- end
- end
- function PublicTable:GetMouseDrag3()
- return LocalTable.MouseDrag3
- end
- function PublicTable:Button2Click(Function)
- if Function == nil then
- LocalTable.Button2Click = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.Button2Click = Function
- end
- end
- function PublicTable:GetButton2Click()
- return LocalTable.Button2Click
- end
- function PublicTable:Button3Click(Function)
- if Function == nil then
- LocalTable.Button3Click = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.Button3Click = Function
- end
- end
- function PublicTable:GetButton3Click()
- return LocalTable.Button3Click
- end
- elseif Class == "TextBox" then
- function PublicTable:ActiveTextColor(Color)
- if type(Color) ~= "number" then
- error("bad argument #1: number expected, got " .. type(Color), 2)
- end
- if VColors[Color] ~= true then
- error("Invalid color.", 2)
- end
- LocalTable.ActiveTextColor = Color
- end
- function PublicTable:EnterPress(Function)
- if Function == nil then
- LocalTable.EnterPress = nil
- else
- if type(Function) ~= "function" then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.EnterPress = Function
- end
- end
- function PublicTable:GetEnterPress()
- return LocalTable.EnterPress
- end
- function PublicTable:Overlap(Bool)
- if type(Bool) ~= "boolean" then
- error("bad argument #1: boolean expected, got " .. type(Bool), 2)
- end
- LocalTable.Overlap = Bool
- end
- function PublicTable:GetOverlap()
- return LocalTable.Overlap
- end
- function PublicTable:ClearTextOnFocus(Bool)
- if type(Bool) ~= "boolean" then
- error("bad argument #1: boolean expected, got " .. type(Bool), 2)
- end
- LocalTable.ClearTextOnFocus = Bool
- end
- function PublicTable:GetClearTextOnFocus()
- return LocalTable.ClearTextOnFocus
- end
- function PublicTable:Focus()
- Main.MakeFocus = LocalTable
- os.queueEvent("")
- end
- function PublicTable:StopFocus()
- Main.StopFocus = true
- os.queueEvent("")
- end
- function PublicTable:TextChar(Char)
- if Char == nil then
- LocalTable.TextChar = nil
- else
- if type(Char) ~= "string" then
- error("bad argument #1: string expected, got " .. type(Char), 2)
- end
- LocalTable.TextChar = Char
- end
- end
- function PublicTable:GetTextChar()
- return LocalTable.TextChar
- end
- end
- function PublicTable:New(Class)
- return NewClass(LocalTable, Class, Main)
- end
- function PublicTable:Draw()
- local BG = Main.BackgroundColor
- local FoundBG = false
- local PX, PY = 1, 1
- local On = LocalTable.Parent
- while On ~= Main do
- PX = PX + On.Position[1] - 1
- PY = PY + On.Position[2] - 1
- if On.ShowBackground and FoundBG == false then
- BG = On.BackgroundColor
- FoundBG = true
- end
- On = On.Parent
- end
- Check(LocalTable, BG, PX, PY , true)
- end
- end
- LocalTable.Pub = PublicTable
- table.insert(Par.Children, LocalTable)
- function PublicTable:Destroy()
- for _,Object in pairs(Par.Children) do
- if LocalTable == Object then
- table.remove(Par.Children, _)
- break
- end
- end
- LocalTable = nil
- PublicTable = nil
- end
- return PublicTable
- end
- local function NewUI()
- local LocalTable = {}
- local PublicTable = {}
- LocalTable.BackgroundColor = colors.red
- LocalTable.Visible = true
- LocalTable.Active = true
- LocalTable.Children = {}
- LocalTable.Listening = false
- function PublicTable:BackgroundColor(Color)
- if type(Color) ~= "number" then
- error("bad argument #1: number expected, got " .. type(Color), 2)
- end
- if not VColors[Color] then
- error("Invalid color.", 2)
- end
- LocalTable.BackgroundColor = Color
- end
- function PublicTable:New(Class)
- return NewClass(LocalTable, Class, LocalTable)
- end
- function PublicTable:ClearChildren()
- LocalTable.Children = {}
- end
- function PublicTable:ErrorHandle(Function)
- if type(Function) ~= "function" and Function ~= nil then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.ErrorHandle = Function
- end
- function PublicTable:Output(Function)
- if type(Function) ~= "function" and Function ~= nil then
- error("bad argument #1: function expected, got " .. type(Function), 2)
- end
- LocalTable.Output = Function
- end
- function PublicTable:Listen()
- LocalTable.Listening = true
- local ActiveBox
- local LastClick1
- local LastClick2
- local LastClick3
- while LocalTable.Listening == true do
- local Event, P1, P2, P3, P4, P5 = os.pullEvent()
- if LocalTable.Listening == false then
- break
- end
- if LocalTable.MakeFocus then
- if ActiveBox then
- ActiveBox.Focused = false
- ActiveBox.StopFocus = nil
- term.setCursorBlink(false)
- if ActiveBox.Overlap == true then
- ActiveBox.Pub:Draw()
- else
- PublicTable:Draw()
- end
- end
- ActiveBox = LocalTable.MakeFocus
- LocalTable.MakeFocus = nil
- ActiveBox.Focused = true
- if ActiveBox.Overlap == true then
- ActiveBox.Pub:Draw()
- else
- PublicTable:Draw()
- end
- term.setCursorBlink(true)
- term.setTextColor(ActiveBox.TextColor)
- term.setCursorPos(unpack(ActiveBox.TextPos))
- end
- if ActiveBox and ActiveBox.StopFocus then
- ActiveBox.Focused = false
- ActiveBox.StopFocus = nil
- term.setCursorBlink(false)
- if ActiveBox.Overlap == true then
- ActiveBox.Pub:Draw()
- else
- PublicTable:Draw()
- end
- if ActiveBox.EnterPress then
- ActiveBox.EnterPress()
- end
- ActiveBox = nil
- end
- if LocalTable.Output then
- if LocalTable.ErrorHandle then
- local Success, Err = pcall(LocalTable.Output, Event, P1, P2, P3, P4, P5)
- if not Success then
- LocalTable.ErrorHandle(Err)
- end
- else
- LocalTable.Output(Event, P1, P2, P3, P4, P5)
- end
- end
- if Event == "char" then
- if ActiveBox then
- ActiveBox.Text = ActiveBox.Text .. P1
- if ActiveBox.Overlap == true then
- ActiveBox.Pub:Draw()
- else
- PublicTable:Draw()
- end
- term.setTextColor(ActiveBox.TextColor)
- term.setCursorPos(unpack(ActiveBox.TextPos))
- end
- elseif Event == "key" then
- if ActiveBox then
- if P1 == 14 then
- if #ActiveBox.Text > 0 then
- ActiveBox.Text = string.sub(ActiveBox.Text, 1, #ActiveBox.Text - 1)
- if ActiveBox.Overlap == true then
- ActiveBox.Pub:Draw()
- else
- PublicTable:Draw()
- end
- term.setTextColor(ActiveBox.TextColor)
- term.setCursorPos(unpack(ActiveBox.TextPos))
- end
- elseif P1 == 28 then
- ActiveBox.Focused = false
- term.setCursorBlink(false)
- if ActiveBox.Overlap == true then
- ActiveBox.Pub:Draw()
- else
- PublicTable:Draw()
- end
- if ActiveBox.EnterPress then
- if LocalTable.ErrorHandle then
- local Success, Err = pcall(ActiveBox.EnterPress)
- if not Success then
- LocalTable.ErrorHandle(Err)
- end
- else
- ActiveBox.EnterPress()
- end
- end
- ActiveBox = nil
- end
- end
- elseif Event == "mouse_scroll" then
- local PStop = false
- local Check
- function Check(Object, Par, PX, PY)
- if Object.Active == true then
- if PStop == true then return end
- if Object.Class == "TextLabel" or Object.Class == "TextButton" or Object.Class == "ImageButton" then
- 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
- if Object.MouseScroll then
- if LocalTable.ErrorHandle then
- local Success, Err = pcall(Object.MouseScroll, P1)
- if not Success then
- LocalTable.ErrorHandle(Err)
- end
- else
- Object.MouseScroll(P1)
- end
- PStop = true
- end
- end
- end
- for _,Object in pairs(SortListen(Object.Children)) do
- Check(Object, Object, PX + Object.Position[1] - 1, PY + Object.Position[2] - 1)
- end
- end
- end
- for _,Object in pairs(SortListen(LocalTable.Children)) do
- Check(Object, LocalTable, 1, 1)
- end
- elseif Event == "mouse_drag" then
- if P1 == 1 and LastClick1 then
- if LastClick1.MouseDrag1 then
- if LocalTable.ErrorHandle then
- local Success, Err = pcall(LastClick1.MouseDrag1, P2, P3)
- if not Success then
- LocalTable.ErrorHandle(Err)
- end
- else
- LastClick1.MouseDrag1(P2, P3)
- end
- end
- elseif P1 == 2 and LastClick2 then
- if LastClick2.MouseDrag2 then
- if LocalTable.ErrorHandle then
- local Success, Err = pcall(Object.MouseDrag2, P2, P3)
- if not Success then
- LocalTable.ErrorHandle(Err)
- end
- else
- Object.MouseDrag2(P2, P3)
- end
- end
- elseif P1 == 3 and LastClick3 then
- if LastClick3.MouseDrag3 then
- if LocalTable.ErrorHandle then
- local Success, Err = pcall(Object.MouseDrag3, P2, P3)
- if not Success then
- LocalTable.ErrorHandle(Err)
- end
- else
- Object.MouseDrag3(P2, P3)
- end
- end
- end
- elseif Event == "mouse_click" then
- LastClick1 = nil
- LastClick2 = nil
- LastClick3 = nil
- local PStop = false
- local StopFocus = true
- local Check
- function Check(Object, Par, PX, PY)
- if Object.Active == true then
- if PStop == true then return end
- if Object.Class == "TextButton" or Object.Class == "ImageButton" or Object.Class == "TextBox" then
- 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
- if ActiveBox and Object ~= ActiveBox then
- ActiveBox.Focused = false
- ActiveBox.StopFocus = nil
- term.setCursorBlink(false)
- if ActiveBox.Overlap == true then
- ActiveBox.Pub:Draw()
- else
- PublicTable:Draw()
- end
- if ActiveBox.EnterPress then
- if LocalTable.ErrorHandle then
- local Success, Err = pcall(ActiveBox.EnterPress)
- if not Success then
- LocalTable.ErrorHandle(Err)
- end
- else
- ActiveBox.EnterPress()
- end
- end
- ActiveBox = nil
- end
- if P1 == 1 then
- LastClick1 = Object
- if (Object.Class == "TextButton" or Object.Class == "ImageButton") and Object.Button1Click then
- if LocalTable.ErrorHandle then
- local Success, Err = pcall(Object.Button1Click, P2, P3)
- if not Success then
- LocalTable.ErrorHandle(Err)
- end
- else
- Object.Button1Click(P2, P3)
- end
- elseif Object.Class == "TextBox" then
- ActiveBox = Object
- Object.Focused = true
- if Object.ClearTextOnFocus == true then
- Object.Text = ""
- end
- Object.RawText = ""
- Object.RTextPos = 6
- if Object.Overlap == true then
- Object.Pub:Draw()
- else
- PublicTable:Draw()
- end
- term.setCursorBlink(true)
- term.setTextColor(ActiveBox.TextColor)
- term.setCursorPos(unpack(Object.TextPos))
- end
- elseif P1 == 2 then
- LastClick2 = Object
- if (Object.Class == "TextButton" or Object.Class == "ImageButton") and Object.Button2Click then
- if LocalTable.ErrorHandle then
- local Success, Err = pcall(Object.Button2Click, P2, P3)
- if not Success then
- LocalTable.ErrorHandle(Err)
- end
- else
- Object.Button2Click(P2, P3)
- end
- end
- elseif P1 == 3 then
- LastClick3 = Object
- if (Object.Class == "TextButton" or Object.Class == "ImageButton") and Object.Button3Click then
- if LocalTable.ErrorHandle then
- local Success, Err = pcall(Object.Button3Click, P2, P3)
- if not Success then
- LocalTable.ErrorHandle(Err)
- end
- else
- Object.Button3Click(P2, P3)
- end
- end
- end
- PStop = true
- end
- end
- for _,Object2 in pairs(SortListen(Object.Children)) do
- Check(Object2, Object, PX + Object.Position[1] - 1, PY + Object.Position[2] - 1)
- end
- end
- end
- for _,Object in pairs(SortListen(LocalTable.Children)) do
- Check(Object, LocalTable, 1, 1)
- end
- end
- end
- end
- function PublicTable:StopListen()
- LocalTable.Listening = false
- end
- function PublicTable:Draw()
- term.setBackgroundColor(LocalTable.BackgroundColor)
- term.clear()
- for _,Item in ipairs(LocalTable.Children) do
- Check(Item, LocalTable.BackgroundColor, 1, 1)
- end
- end
- return PublicTable
- end
- -- End of alakazard12's Nova GUI API
- local tArgs = {...}
- 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,},}
- local InstallDirectory = "/.NovaAir"
- local InstallDir = InstallDirectory
- local Version = "1.1.8"
- if turtle then
- printError("Why are you running this on a turtle?")
- return
- end
- local W, H = term.getSize()
- if W ~= 51 or H ~= 19 then
- printError("NovaAir is only supported on a 51 x 19 sized terminal.")
- return
- end
- if not term.isColor() then
- printError("NovaAir is only supported on a colored terminal.")
- return
- end
- local StartUI = NewUI()
- StartUI:BackgroundColor(colors.white)
- local Logo = StartUI:New("ImageLabel")
- Logo:Image(LogoImage)
- Logo:ShowBackground(false)
- Logo:Size(W, 7)
- Logo:Position(5, 4)
- local Output = StartUI:New("TextLabel")
- Output:Size(W, 8)
- Output:BackgroundColor(colors.black)
- Output:Position(1, H - 8 + 1)
- local TopBorder = StartUI:New("TextLabel")
- TopBorder:Size(W, 1)
- TopBorder:Position(1, H - 8)
- TopBorder:BackgroundColor(colors.gray)
- TopBorder:TextColor(colors.lightGray)
- TopBorder:Text("NovaAir by alakazard12")
- local OutputTexts = {}
- for i = 1, 8 do
- local Temp = Output:New("TextLabel")
- Temp:Size(W, 1)
- Temp:Position(1, i)
- Temp:ShowBackground(false)
- Temp:TextXAlignment(0)
- OutputTexts[i] = Temp
- end
- local LinesPassed = 0
- local function PrintOutput(Text)
- Text = "> " .. Text
- LinesPassed = LinesPassed + 1
- if LinesPassed > 8 then
- for i = 2, 8 do
- OutputTexts[i - 1]:Text(OutputTexts[i]:GetText())
- OutputTexts[i - 1]:Draw()
- end
- OutputTexts[8]:Text(Text)
- OutputTexts[8]:Draw()
- else
- OutputTexts[LinesPassed]:Text(Text)
- OutputTexts[LinesPassed]:Draw()
- end
- end
- --[[local ToB = false
- 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")
- setfenv(Der, setmetatable({["Version"] = Version; ["StartUI"] = StartUI; ["PrintOutput"] = PrintOutput; ["InstallDir"] = InstallDir; ["shell"] = shell}, {__index = getfenv()}))
- ToB = Der()
- if ToB == true then
- PrintOutput("Stopping")
- return
- end ]]
- local function GetData(URL)
- local Handle = http.get(URL)
- if Handle then
- local Data = Handle.readAll()
- Handle.close()
- return Data
- else
- return nil
- end
- end
- StartUI:Draw()
- PrintOutput("Checking for updates")
- if not http then
- PrintOutput("HTTP not enabled, cannot check for updates or install necessary files")
- else
- local NVersion = GetData("https://raw.github.com/alakazard12/NovaAir/master/Version")
- if NVersion ~= Version then
- PrintOutput("Update available (" .. NVersion .. ")")
- local New = GetData("https://raw.github.com/alakazard12/NovaAir/master/NovaAir")
- local Prog = shell.getRunningProgram()
- local File = fs.open(Prog, "w")
- File.write(New)
- File.close()
- PrintOutput("Updated NovaAir")
- shell.run("/" .. Prog)
- return
- end
- if not fs.exists(InstallDirectory) then
- fs.makeDir(InstallDirectory)
- end
- local DFiles = {
- ["Cache"] = {
- };
- ["Pages"] = {
- ["home"] = {
- ["Version"] = "1.0";
- ["index"] = "https://raw.github.com/alakazard12/NovaAir/master/Pages/home/index";
- };
- ["server"] = {
- ["index"] = "https://raw.github.com/alakazard12/NovaAir/master/Pages/server/index";
- ["Version"] = "1.1.3";
- };
- ["search"] = {
- ["index"] = "https://raw.github.com/alakazard12/NovaAir/master/Pages/search/index";
- ["Version"] = "1.1.5";
- };
- ["help"] = {
- ["index"] = "https://raw.github.com/alakazard12/NovaAir/master/Pages/help/index";
- ["Version"] = "1.1";
- };
- ["pages"] = {
- ["index"] = "https://raw.github.com/alakazard12/NovaAir/master/Pages/pages/index";
- ["Version"] = "1.2";
- };
- };
- ["Servers"] = {
- };
- }
- local CheckDirectory
- function CheckDirectory(Path, Files, Name)
- for i,v in pairs(Files) do
- if type(v) == "table" then
- if not fs.exists(Path .. "/" .. i) then
- fs.makeDir(Path .. "/" .. i)
- end
- CheckDirectory(Path .. "/" .. i, v, i)
- elseif type(v) == "string" and i ~= "index" then
- if i == "Version" then
- if not fs.exists(Path .. "/" .. i) then
- local File = fs.open(Path .. "/" .. i, "w")
- File.write(v)
- File.close()
- else
- local File = fs.open(Path .. "/" .. i, "r")
- local FVersion = File.readAll()
- File.close()
- if FVersion ~= v then
- local Data = GetData(Files["index"])
- local File = fs.open(Path .. "/index", "w")
- File.write(Data)
- File.close()
- File = fs.open(Path .. "/" .. i, "w")
- File.write(v)
- File.close()
- PrintOutput("Updated " .. Name)
- end
- end
- if not fs.exists(Path .. "/index") then
- local File = fs.open(Path .. "/index", "w")
- local Data = GetData(Files["index"])
- File.write(Data)
- File.close()
- PrintOutput("Installed " .. Name)
- end
- end
- end
- end
- end
- CheckDirectory(InstallDirectory, DFiles)
- end
- PrintOutput("Opening modem")
- local HasModem
- for _,Side in pairs(rs.getSides()) do
- if peripheral.getType(Side) == "modem" then
- HasModem = Side
- peripheral.call(Side, "open", 8964)
- break
- end
- end
- if not HasModem then
- PrintOutput("No modem detected. Attach a modem and re-launch.")
- end
- if not tArgs[1] then
- PrintOutput("Click any key to continue")
- os.pullEventRaw("key")
- end
- if not HasModem then
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.black)
- term.clear()
- return
- end
- CheckFile = nil
- InstallFiles = nil
- Repo = nil
- PrintOutput = nil
- DownloadFile = nil
- OutputTexts = nil
- TopBorder = nil
- Output = nil
- Logo = nil
- StartUI = nil
- LogoImage = nil
- SyncCheck = nil
- CVersion = nil
- GetFile = nil
- Con = nil
- File = nil
- local MainUI = NewUI()
- MainUI:BackgroundColor(colors.lightGray)
- local Index
- local ABegin = MainUI:New("TextLabel")
- ABegin:Size(7, 1)
- ABegin:BackgroundColor(colors.white)
- ABegin:Text("Nova://")
- ABegin:TextColor(colors.black)
- local AInput = MainUI:New("TextBox")
- AInput:Size(W - 10, 1)
- AInput:Position(8, 1)
- AInput:Text("home")
- AInput:BackgroundColor(colors.white)
- AInput:TextColor(colors.black)
- AInput:Overlap(true)
- AInput:ActiveTextColor(colors.white)
- AInput:TextXAlignment(0)
- local function DrawIndex()
- if Index then
- Index:Destroy()
- end
- Index = MainUI:New("TextLabel")
- Index:Size(W, H - 1)
- Index:Position(1, 2)
- Index:BackgroundColor(colors.lightGray)
- end
- local function ErrorPage(Head, Error, Suggest)
- DrawIndex()
- local Title = Index:New("TextLabel")
- Title:Size(W, 3)
- Title:BackgroundColor(colors.gray)
- Title:TextColor(colors.black)
- Title:MultiLine(true)
- Title:Text(Head)
- local Err = Index:New("TextLabel")
- Err:Size(W, 3)
- Err:Position(1, 5)
- Err:ShowBackground(false)
- Err:TextColor(colors.red)
- Err:Text(Error)
- Err:MultiLine(true)
- local Sug = Index:New("TextLabel")
- Sug:Size(W, 3)
- Sug:ShowBackground(false)
- Sug:Position(1, 10)
- Sug:Text(Suggest)
- Sug:TextColor(colors.blue)
- Sug:MultiLine(true)
- Index:Draw()
- end
- local DrawPage
- function DrawPage(Text, Arg)
- DrawIndex()
- Index:Draw()
- if Text:sub(#Text, #Text) == " " then
- repeat
- Text = Text:sub(1, #Text - 1)
- until Text:sub(#Text, #Text) ~= " "
- end
- local Args = {}
- for Arg in Text:gmatch("([^/]+)") do
- table.insert(Args, Arg)
- end
- if #Args == 0 then
- Args[1] = "help"
- end
- MainUI:Output()
- local SiteName = Args[1]
- if fs.exists(InstallDir .. "/Pages/" .. Args[1]) then
- local File = InstallDir .. "/Pages/" .. Args[1]
- if #Args > 1 then
- table.remove(Args, 1)
- for _,Arg in pairs(Args) do
- File = File .. "/" .. Arg
- end
- if not fs.exists(File) then
- File = File .. "/index"
- end
- else
- File = File .. "/index"
- end
- if fs.exists(File) then
- local PageF = fs.open(File, "r")
- local Page, Error = loadstring(PageF.readAll(), SiteName)
- PageF.close()
- if not Page then
- ErrorPage("Hmm, looks like a built-in website crashed, that's odd", Error, "Report this error to alakazard12 so it can be fixed ASAP")
- return
- end
- local Env = {
- ["redirect"] = function(Link, Arg)
- if type(Link) ~= "string" then
- error("bad argument #1: string expected, got " .. type(Link), 2)
- end
- AInput:Text(Link)
- AInput:Draw()
- DrawPage(Link, Arg)
- end;
- ["shell"] = shell;
- ["Index"] = Index;
- ["Output"] = function(Arg)
- return MainUI:Output(Arg)
- end;
- ["ModemSide"] = HasModem;
- --[[["Listen"] = function()
- return MainUI:Listen()
- end;
- ["StopListen"] = function()
- return MainUI:StopListen()
- end; ]]
- ["Draw"] = function()
- return MainUI:Draw()
- end;
- }
- setmetatable(Env, {__index = _G})
- setfenv(Page, Env)
- MainUI:ErrorHandle(function(Error)
- ErrorPage("Hmm, looks like a built-in website crashed, that's odd", Error, "Report this error to alakazard12 so it can be fixed ASAP")
- end)
- local Co = coroutine.create(Page)
- local Success, Error
- if Arg then
- Success, Error = coroutine.resume(Co, Arg)
- else
- Success, Error = coroutine.resume(Co)
- end
- if Success == false then
- ErrorPage("Oh no, NovaAir just had an error!", Error, "Report this error to alakazard12 so it can be fixed ASAP")
- end
- MainUI:Output(function(Event, P1, P2, P3, P4, P5)
- if coroutine.status(Co) == "dead" then
- MainUI:Output()
- return
- end
- if Error then
- if Event == Error then
- Success, Error = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
- end
- else
- Success, Error = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
- end
- if Success == false then
- ErrorPage("Oh no, NovaAir just had an error!", Error, "Report this error to alakazard12 so it can be fixed ASAP")
- end
- end)
- --[[local Co = coroutine.create(Page)
- local EWant, Err
- EWant = coroutine.resume(Co)
- while true do
- if coroutine.status(Co) == "suspended" then
- local Event, P1, P2, P3, P4, P5 = coroutine.yield()
- if EWant then
- if Event == EWant then
- EWant, Err = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
- end
- else
- EWant, Err = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
- end
- elseif coroutine.status(Co) == "dead" then
- break
- end
- end]]
- end
- else
- if not HasModem then return end
- peripheral.call(HasModem, "transmit", 8964, os.getComputerID(), textutils.serialize({"NovaAir", "Find", Text}))
- local Timer = os.startTimer(0.2)
- MainUI:Output(function(Event, P1, P2, P3, P4, P5)
- if Event == "timer" and P1 == Timer then
- ErrorPage("NovaAir could not find the site you're looking for", "", "If you believe this is an error, contact the operator")
- elseif Event == "modem_message" then
- if P2 == 8964 then
- local Args = textutils.unserialize(P4)
- if type(Args) == "table" then
- if Args[1] == "NovaAir" then
- if Args[2] == "Site" then
- if Args[3] and Args[3]:lower() == Text:lower() and Args[4] then
- MainUI:Output()
- local Page, Error = loadstring(Args[4], SiteName)
- if not Page then
- ErrorPage("Oh no! The website has just crashed!", Error, "Report this error to the site operator so it can be fixed.")
- return
- end
- local Stop = false
- local allowed = {}
- local function RequestF(Req, Func, ...)
- if allowed[Func] == true then
- return Func(...)
- end
- Stop = true
- local Sac
- local OverF = MainUI:New("TextLabel")
- OverF:Text("")
- OverF:Size(51, 1)
- OverF:ZIndex(100)
- OverF:BackgroundColor(colors.red)
- local Text = OverF:New("TextLabel")
- Text:Size(29, 1)
- Text:ShowBackground(false)
- Text:Text(Req)
- Text:TextXAlignment(0)
- local Yes = OverF:New("TextButton")
- Yes:Size(10, 1)
- Yes:Position(31, 1)
- Yes:Text("[ Allow ]")
- Yes:ShowBackground(false)
- Yes:Button1Click(function()
- Sac = "yes"
- end)
- local No = OverF:New("TextButton")
- No:Size(10, 1)
- No:Position(41, 1)
- No:Text("[ Deny ]")
- No:ShowBackground(false)
- No:Button1Click(function()
- Sac = "no"
- end)
- OverF:Draw()
- repeat sleep(0) until Sac ~= nil
- OverF:Destroy()
- MainUI:Draw()
- Stop = false
- term.setCursorPos(1, 1)
- if Sac == "yes" then
- allowed[Func] = true
- return Func(...)
- else
- return
- end
- end
- local Env = {
- ["redirect"] = function(Link, Arg)
- if type(Link) ~= "string" then
- error("bad argument #1: string expected, got " .. type(Link), 2)
- end
- AInput:Text(Link)
- AInput:Draw()
- DrawPage(Link, Arg)
- end;
- ["Index"] = Index;
- ["Output"] = function(Arg)
- return MainUI:Output(Arg)
- end;
- ["ModemSide"] = HasModem;
- ["Draw"] = function()
- return MainUI:Draw()
- end;
- ["os"] = {};
- ["shell"] = {};
- ["fs"] = {};
- ["io"] = {};
- ["term"] = {};
- ["redstone"] = {};
- ["gps"] = {};
- ["keys"] = {};
- ["peripheral"] = {};
- ["bit"] = {};
- ["coroutine"] = {};
- ["disk"] = {};
- ["colors"] = {};
- ["colours"] = {};
- ["math"] = {};
- ["rednet"] = {};
- ["help"] = {};
- ["http"] = {};
- ["string"] = {};
- ["table"] = {};
- ["parallel"] = {};
- ["textutils"] = {};
- ["vector"] = {};
- ["paintutils"] = {};
- ["setfenv"] = function(...)
- return RequestF("Alow setfenv?", setfenv, ...)
- end;
- ["getfenv"] = function(...)
- return RequestF("Alow getfenv?", getfenv, ...)
- end;
- }
- for i,v in pairs(term) do
- Env.term[i] = v
- end
- for i,v in pairs(redstone) do
- Env.redstone[i] = v
- end
- for i,v in pairs(gps) do
- Env.gps[i] = v
- end
- for i,v in pairs(keys) do
- Env.keys[i] = v
- end
- for i,v in pairs(peripheral) do
- Env.peripheral[i] = v
- end
- for i,v in pairs(bit) do
- Env.bit[i] = v
- end
- for i,v in pairs(coroutine) do
- Env.coroutine[i] = v
- end
- for i,v in pairs(disk) do
- Env.disk[i] = v
- end
- for i,v in pairs(colors) do
- Env.colors[i] = v
- end
- for i,v in pairs(colours) do
- Env.colours[i] = v
- end
- for i,v in pairs(math) do
- Env.math[i] = v
- end
- for i,v in pairs(rednet) do
- Env.rednet[i] = v
- end
- for i,v in pairs(help) do
- Env.help[i] = v
- end
- for i,v in pairs(http) do
- Env.http[i] = v
- end
- for i,v in pairs(string) do
- Env.string[i] = v
- end
- for i,v in pairs(table) do
- Env.table[i] = v
- end
- for i,v in pairs(parallel) do
- Env.parallel[i] = v
- end
- for i,v in pairs(textutils) do
- Env.textutils[i] = v
- end
- for i,v in pairs(vector) do
- Env.vector[i] = v
- end
- for i,v in pairs(paintutils) do
- Env.paintutils[i] = v
- end
- Env.rs = Env.redstone
- local osblocked = {
- "run";
- "loadAPI";
- "unloadAPI";
- "shutdown";
- "reboot";
- }
- local shellblocked = {
- "exit";
- "setDir";
- "setPath";
- "setAlias";
- "clearAlias";
- "run";
- }
- local fsblocked = {
- "open";
- "makeDir";
- "move";
- "copy";
- "delete";
- }
- local ioblocked = {
- "open";
- }
- for i,v in pairs(os) do
- Env.os[i] = v
- end
- for i,v in pairs(osblocked) do
- Env.os[v] = function(...)
- return RequestF("Alow os." .. v .. "?", os[v], ...)
- end
- end
- for i,v in pairs(shell) do
- Env.shell[i] = v
- end
- for i,v in pairs(shellblocked) do
- Env.shell[v] = function(...)
- return RequestF("Alow shell." .. v .. "?", shell[v], ...)
- end
- end
- for i,v in pairs(fs) do
- Env.fs[i] = v
- end
- for i,v in pairs(fsblocked) do
- Env.fs[v] = function(...)
- return RequestF("Alow fs." .. v .. "?", fs[v], ...)
- end
- end
- for i,v in pairs(io) do
- Env.io[i] = v
- end
- for i,v in pairs(ioblocked) do
- Env.io[v] = function(...)
- return RequestF("Alow io." .. v .. "?", io[v], ...)
- end
- end
- Env.os.queueEvent = nil
- setmetatable(Env, {__metatable = "THIS S" .. "H" .. "I" .. "T IS LOCKED"})
- setfenv(Page, Env)
- MainUI:ErrorHandle(function(Error)
- ErrorPage("Oh no! The website has just crashed!", Error, "Report this error to the site operator so it can be fixed.")
- end)
- local Co = coroutine.create(Page)
- local Success, Error
- if Arg then
- Success, Error = coroutine.resume(Co, Arg)
- else
- Success, Error = coroutine.resume(Co)
- end
- if Success == false then
- ErrorPage("Oh no! The website has just crashed!", Error, "Report this error to the site operator so it can be fixed.")
- end
- MainUI:Output(function(Event, P1, P2, P3, P4, P5)
- if Stop == true then if Event ~= "timer" then return end end
- if coroutine.status(Co) == "dead" then
- MainUI:Output()
- return
- end
- if Error then
- if Event == Error then
- Success, Error = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
- end
- else
- Success, Error = coroutine.resume(Co, Event, P1, P2, P3, P4, P5)
- end
- if Success == false then
- ErrorPage("Oh no! The website has just crashed!", Error, "Report this error to the site operator so it can be fixed.")
- end
- end)
- end
- end
- end
- end
- end
- end
- end)
- end
- end
- AInput:EnterPress(function()
- DrawPage(AInput:GetText():lower())
- end)
- local AClose = MainUI:New("TextButton")
- AClose:Size(3, 1)
- AClose:Position(W - 2, 1)
- AClose:Text("X")
- AClose:BackgroundColor(colors.gray)
- AClose:TextColor(colors.black)
- AClose:Button1Click(function()
- MainUI:StopListen()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- end)
- MainUI:Draw()
- if tArgs[1] then
- AInput:Text(tArgs[1])
- AInput:Draw()
- local Pg = tArgs[1]
- table.remove(tArgs, 1)
- DrawPage(Pg, table.concat(tArgs, " "))
- else
- DrawPage("home")
- end
- MainUI:Listen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement