-- For advance computers else change colours to black and white!! -- Version 0.0.2 sleep(1) -- Wait some time so the portal can start. local file -- Local to put file names in. local w, h = term.getSize() -- Get screen height and width. local interface -- Local for the portal interface. local Monitor -- Local for the Monitor. local OldTerm -- Local to put in the terminal screen when switch to monitor local test -- Local just for testing stuff local MonitorState = "M" -- Local for the monitor state. M = monitor, T = Terminal local found = false -- Local for if something is found or not. local CLS = term.clear -- New command for clearing the complete screen. local setCurs = term.setCursorPos -- New command for setting the cursor position. local Loop = true -- Local for head menu to loop or end. for i,name in pairs(peripheral.getNames()) do -- Go through all attached things and get the names. for j,method in pairs(peripheral.getMethods(name)) do -- Go through all methods that are avadible. if (method == 'clear') then -- If found metod clear then do Monitor = peripheral.wrap(name) -- Set and warp local monitor to the real monitor. found = true -- Set local found to true. end -- end if statement if (found) then -- If local found is true then do. break -- Break the for ..... do. end -- end if statement. end -- end for ..... do. if (found) then -- If local found is true then do. break -- Break the for ..... do. end -- end if statement. end -- end for ..... do. local X, Y -- local for the height and width for the screen or monitor if MonitorState == "T" then -- If local monitorstate is T do. X, Y = term.getSize() -- Get screen height and width. elseif MonitorState == "M" and Monitor then -- Else if local monitorstate is M do. OldTerm = term.redirect(Monitor) -- Set the term screen in the local oldterm to not loose it, Monitor.setTextScale(1) -- Set the scale of the text on the screen X, Y = Monitor.getSize() -- Get screen height and width. end -- end if statement. local X2, Y2 = X / 2, Y /2 -- Some calculations for the screen and saved in the locals. local a = X + 1 - X2 -- Some calculations for the screen and saved in the locals. local b = Y + 1 - Y2 -- Some calculations for the screen and saved in the locals. local MenuScreen = window.create(term.current(),1,1,X2,Y) -- Make in screen a new window. MenuScreen.setBackgroundColour(colours.blue) -- Set background color in this window. MenuScreen.setTextColour(colours.white) -- Set text color in this window. MenuScreen.clear() -- Clear the window and put in that backgound color. local MenuScreenX, MenuScreenY = MenuScreen.getSize() -- Get window height and width. local MenuScreenX2, MenuScreenY2 = MenuScreenX/2, MenuScreenY/2 -- Some calculations for the window and saved in the locals. local DailScreen = window.create(term.current(),X2+1,1,a,Y2) -- Make in screen a new window. DailScreen.setBackgroundColour(colours.green) -- Set background color in this window. DailScreen.setTextColour(colours.black) -- Set text color in this window. DailScreen.clear() -- Clear the window and put in that backgound color. local DailScreenX, DailScreenY = DailScreen.getSize() -- Get window height and width. local DailScreenX2, DailScreenY2 = DailScreenX/2, DailScreenY/2 -- Some calculations for the window and saved in the locals. local IncomingScreen = window.create(term.current(),X2+1,Y2+1,a,b) -- Make in screen a new window. IncomingScreen.setBackgroundColour(colours.red) -- Set background color in this window. IncomingScreen.setTextColour(colours.black) -- Set text color in this window. IncomingScreen.clear() -- Clear the window and put in that backgound color. local IncomingScreenX, IncomingScreenY = IncomingScreen.getSize() -- Get window height and width. local IncomingScreenX2, IncomingScreenY2 = IncomingScreenX/2, IncomingScreenY/2 -- Some calculations for the window and saved in the locals. local Text = "" -- Local for text. local timer -- Local for a timer. local z -- Local for a line number. local Addresses = { -- Local for adresses to dail to. [1] = { Name = "Abydos", -- Name to dail to. Address = {26,6,14,31,11,29,0} -- ID (Address) to dail to, end with a 0 (zero) to start dailing. }, [2] = { Name = "Chulak", Address = {8,1,22,14,36,19,0} }, [3] = { Name = "Lantea", Address = {18,20,1,15,14,7,19,0} }, [4] = { Name = "Earth", Address = {16,23,32,12,19,15,18,22,0} -- own made potal, change me to ur own. }, [5] = { Name = "Space Fairy", Address = {35,27,26,29,34,25,23,31,0} -- Space station in orbid (Ad astra mod), change me to ur own or del me and make nether roof number 5. }, [6] = { Name = "Nether Roof", Address = {8,35,34,25,14,27,15,2,0} -- found nether roof portal. } } -- add your own adress to TXT or Press = in Menu, Or do it like her and change them. if fs.exists("Addresses.txt") then -- If file exists then do. file = fs.open("Addresses.txt", "r") -- Open the file. Addresses = textutils.unserialize(file.readAll()) -- Read the file and save it in the local Addresses. file.close() -- Close the file. else -- If file not exists then do. file = fs.open("Addresses.txt", "w") -- Make the file. file.write(textutils.serialize(Addresses)) -- Safe the local Addresses in the file. file.close() -- Close the file. end -- end if statement. found = false -- Set local found to false again. for i,name in pairs(peripheral.getNames()) do -- Go through all attached things and get the names. for j,method in pairs(peripheral.getMethods(name)) do -- Go through all methods that are avadible. if (method == 'getChevronsEngaged') then -- If found metod getVhevronsEngaged then do interface = peripheral.wrap(name) -- Set and warp local interface to the portal interface. found = true -- Set local found to true. end -- end if statement. if (found) then -- If local found is true then do. break -- Break the for ..... do. end -- end if statement. end -- end for ..... do. if (found) then -- If local found is true then do. break -- Break the for ..... do. end -- end if statement. end -- end for ..... do. local buttona = {} -- Local for Api Buttons. local color = { normale = { text = colors.white, background = colors.blue }, clicked = { text = colors.blue, background = colors.white } } -- Set some colors for the buttons. function classButton() -- Make the button Api. clsButton = {} clsButton.__index = clsButton -- failed table lookups on the instances should fallback to the class table, to get methods local self = setmetatable({}, clsButton) function clsButton.clearButtons(self) buttona = {} end -- Clear the local buttona function clsButton.setButton(self, name, func, xmin, xmax, ymin, ymax, state, extra) buttona[name] = {} buttona[name]["func"] = func buttona[name]["extra"] = extra buttona[name]["active"] = false buttona[name]["show"] = state buttona[name]["xmin"] = xmin buttona[name]["ymin"] = ymin buttona[name]["xmax"] = xmax buttona[name]["ymax"] = ymax end function clsButton.setButtonShow(self, name, data) buttona[name]["show"] = data end function clsButton.onScreen(self) local background local text for name,data in pairs(buttona) do if data["show"] then if term.isColor then if (data["active"]) then background = color.clicked.background text = color.clicked.text else background = color.normale.background text = color.normale.text end else if (data["active"]) then background = colors.white text = colors.black else background = colors.black text = colors.white end end term.setBackgroundColor(background) term.setTextColor(text) local yspot = math.floor((data["ymin"] + data["ymax"]) /2) local xspot = math.floor((data["xmax"] - data["xmin"] - string.len(name)) /2) +1 for j = data["ymin"], data["ymax"] do term.setCursorPos(data["xmin"]-2, j) if j == yspot then term.write(name) else for i = data["xmin"], data["xmax"] do term.write(" ") end end end term.setBackgroundColor(colors.black) term.setTextColor(colors.white) end end end function clsButton.toggleButton(self, name) buttona[name]["active"] = not buttona[name]["active"] clsButton.onScreen() end function clsButton.flashButton(self, name) clsButton.toggleButton(self, name) clsButton.onScreen(self) sleep(0.15) clsButton.toggleButton(self, name) clsButton.onScreen(self) end function clsButton.buttonPressed(self, x, y) for name, data in pairs(buttona) do if data["show"] then if y>=data["ymin"] and y <= data["ymax"] then if x>=data["xmin"] and x<= data["xmax"] then clsButton.flashButton(self,name) if data["extra"] then data["func"](data["extra"]) else data["func"]() end return true end end end end return false end return self end local Button = classButton() -- Set the button Api. function MakeButtons() -- To make the buttons. z = 2 for i in pairs(Addresses) do -- For the addresses z = z + 1 MenuScreen.setCursorPos(2, z) if i <= 9 then Text = string.format("%3i%s%s", i, " = ", Addresses[i].Name) -- Set text Button:setButton(Text, dial, 2, MenuScreenX - 1, z, z, true, Addresses[i]) -- Make a button with the text and use some locals to set heigh and width. (Text, function, xmin, xmax, ymin, ymax, Visable, extra for the funtion like Funtion -> Dail(extra -> addresses(1))). end -- This is for if there are more then 9 addresses. -- if i > 9 then -- if i == 10 then -- Text = string.format("%s%s%s", "A", " = ", Addresses[i].Name) -- Button:setButton(Text, dial, 2, MenuScreenX - 1, z, z, true, Addresses[i]) -- elseif i == 11 then -- Text = string.format("%s%s%s", "B", " = ", Addresses[i].Name) -- Button:setButton(Text, dial, 2, MenuScreenX - 1, z, z, true, Addresses[i]) -- end -- end end if Monitor then -- If monitor found do. MenuScreen.setCursorPos(2, z+2) Text = " M = Change Screen" Button:setButton(Text, ChangeMonitor, 2, MenuScreenX - 1, z+2, z+2, true) MenuScreen.setCursorPos(2, z+3) Text = " R = Reset" Button:setButton(Text, Resset, 2, MenuScreenX - 1, z+3, z+3, true) MenuScreen.setCursorPos(2, z+4) Text = " Q = Quit Program" Button:setButton(Text, Quitt, 2, MenuScreenX - 1, z+4, z+4, true) else -- If no monitor found do. MenuScreen.setCursorPos(2, z+3) Text = " R = Reset" Button:setButton(Text, Resset, 2, MenuScreenX - 1, z+3, z+3, true) MenuScreen.setCursorPos(2, z+4) Text = " Q = Quit Program" Button:setButton(Text, Quitt, 2, MenuScreenX - 1, z+4, z+4, true) end end function Buttonshow(What) -- To set a button to visable or not. for i in pairs(Addresses) do if i <= 9 then Text = string.format("%3i%s%s", i, " = ", Addresses[i].Name) Button:setButtonShow(Text, What) end end end function Recount() -- When change monitor to screen or back, it need to recount every thing. if MonitorState == "T" then X, Y = term.getSize() elseif MonitorState == "M" then Monitor.setTextScale(1) X, Y = Monitor.getSize() end X2, Y2 = X / 2, Y /2 a = X + 1 - X2 b = Y + 1 - Y2 MenuScreen.reposition(1,1,X2,Y,term.current()) MenuScreenX, MenuScreenY = MenuScreen.getSize() MenuScreenX2, MenuScreenY2 = MenuScreenX/2, MenuScreenY/2 DailScreen.reposition(X2+1,1,a,Y2,term.current()) DailScreenX, DailScreenY = DailScreen.getSize() DailScreenX2, DailScreenY2 = DailScreenX/2, DailScreenY/2 IncomingScreen.reposition(X2+1,Y2+1,a,b,term.current()) IncomingScreenX, IncomingScreenY = IncomingScreen.getSize() IncomingScreenX2, IncomingScreenY2 = IncomingScreenX/2, IncomingScreenY/2 end function ChangeMonitor() -- When change monitor to screen or back. if MonitorState == "T" and Monitor then term.setBackgroundColour(colours.black) CLS() OldTerm = term.redirect(Monitor) -- Set term in oldterm and change to monitor MonitorState = "M" Recount() term.setBackgroundColour(colours.blue) elseif MonitorState == "M" and Monitor then term.setBackgroundColour(colours.black) CLS() test = term.redirect(OldTerm) -- Set monitor in test and change back to term MonitorState = "T" Recount() term.setBackgroundColour(colours.blue) end end function SaveFile() -- Save the adresses in a file file = fs.open("Addresses.txt", "w") file.write(textutils.serialize(Addresses)) file.close() end function dial(address) -- Dial to the gate local a = address.Address local addressLength = #a local start = interface.getChevronsEngaged() + 1 Buttonshow(false) MenuScreen.clear() term.setBackgroundColour(colours.green) term.setTextColour(colours.black) DailScreen.clear() for chevron = start,addressLength,1 do local symbol = address.Address[chevron] if chevron % 2 == 0 then interface.rotateClockwise(symbol) else interface.rotateAntiClockwise(symbol) end DailScreen.clear() DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1) print("Dailing:",address.Name) DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2) print("Symbol:",chevron," = ",symbol) DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 + 1) print("State: Locating") while(not interface.isCurrentSymbol(symbol)) do sleep(0) end if interface.raiseChevron() == 11 then DailScreen.clear() DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1) print("Dailing:",address.Name) DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2) print("Symbol:",chevron," = ",symbol) DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 + 1) print("State: Lock On") sleep(1) end if interface.lowerChevron() == 1 then DailScreen.clear() DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1) print("Dailing:",address.Name) DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2) print("Symbol:",chevron," = ",symbol) DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 + 1) print("State: Locked") sleep(1) end if chevron == addressLength then DailScreen.clear() DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1) print("Opening portal to:") DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2) print(address.Name) sleep(3) DailScreen.clear() DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1) print("Portal Open to") DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2) print(address.Name) term.setBackgroundColour(colours.red) IncomingScreen.clear() IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 - 1) print("Incoming Portal from ") IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2) print("?") IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 + 1) print("Portal Open True") while interface.isStargateConnected() do timer = os.startTimer(3) local Event, p1, p2, p3, p4, p5 = os.pullEvent() if Event == "timer" then sleep(0) elseif Event == "key" then if p1 == keys.zero or p1 == keys.numPad0 then interface.disconnectStargate() end end end end end term.setBackgroundColour(colours.blue) term.setTextColour(colours.white) end function Incoming() -- On incoming wormhole term.setBackgroundColour(colours.red) term.setTextColour(colours.black) MenuScreen.clear() IncomingScreen.clear() IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 - 1) print("Incoming Portal from ") IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2) print("?") IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 + 1) print("Portal Open True") while interface.isStargateConnected() do timer = os.startTimer(1) local Event, p1, p2, p3, p4, p5 = os.pullEvent() if Event == "timer" then sleep(0) elseif Event == "key" then if p1 == keys.zero or p1 == keys.numPad0 then interface.disconnectStargate() -- close the gate end end end IncomingScreen.clear() term.setBackgroundColour(colours.blue) term.setTextColour(colours.white) CLS() end function AddAddress() -- Add address CLS() setCurs(1,Y2) term.write("Name: ") local name = io.read() CLS() setCurs(1,Y2) term.write("Close with a zero") setCurs(1,Y2+1) term.write("Adress A:") local A = tonumber(io.read()) local B local C local D local E local F local G local H local I if A ~= 0 and A ~= nil then CLS() setCurs(1,Y2) term.write("Close with a zero") setCurs(1,Y2+1) term.write("Adress B:") B = tonumber(io.read()) end if B ~= 0 and B ~= nil then CLS() setCurs(1,Y2) term.write("Close with a zero") setCurs(1,Y2+1) term.write("Adress C:") C = tonumber(io.read()) end if C ~= 0 and C ~= nil then CLS() setCurs(1,Y2) term.write("Close with a zero") setCurs(1,Y2+1) term.write("Adress D:") D = tonumber(io.read()) end if D ~= 0 and D ~= nil then CLS() setCurs(1,Y2) term.write("Close with a zero") setCurs(1,Y2+1) term.write("Adress E:") E = tonumber(io.read()) end if E ~= 0 and E ~= nil then CLS() setCurs(1,Y2) term.write("Close with a zero") setCurs(1,Y2+1) term.write("Adress F:") F = tonumber(io.read()) end if F ~= 0 and F ~= nil then CLS() setCurs(1,Y2) term.write("Close with a zero") setCurs(1,Y2+1) term.write("Adress G:") G = tonumber(io.read()) end if G ~= 0 and G ~= nil then CLS() setCurs(1,Y2) term.write("Close with a zero") setCurs(1,Y2+1) term.write("Adress H:") H = tonumber(io.read()) end if H ~= 0 and H ~= nil then CLS() setCurs(1,Y2) term.write("Close with a zero") setCurs(1,Y2+1) term.write("Adress I:") I = tonumber(io.read()) end local Data = { Name = tostring(name), Address = {A, B, C, D, E, F, G, H, I} } table.insert(Addresses, Data) SaveFile() end function Resset() -- Reset the gate. Like if crashed while dialing. Buttonshow(false) MenuScreen.clear() interface.lowerChevron() sleep(1) interface.rotateClockwise(0) while(not interface.isCurrentSymbol(0)) do sleep(0) end interface.raiseChevron() sleep(1) interface.lowerChevron() sleep(1) if interface.isStargateConnected() then interface.disconnectStargate() end interface.lowerChevron() sleep(1) interface.rotateClockwise(0) while(not interface.isCurrentSymbol(0)) do sleep(0) end interface.raiseChevron() sleep(1) interface.lowerChevron() sleep(1) if interface.isStargateConnected() then interface.disconnectStargate() end term.setBackgroundColour(colours.blue) term.setTextColour(colours.white) end function Quitt() -- Quit the program and reboot the computer Loop = false CLS() setCurs(1, 1) end MakeButtons() -- Go to and do CLS() MenuScreen.clear() while Loop do timer = os.startTimer(1) -- Start a timer term.setBackgroundColour(colours.blue) term.setTextColour(colours.white) MenuScreen.setCursorPos(2, 1) print("Awaiting input:") Button:onScreen() term.setBackgroundColour(colours.green) term.setTextColour(colours.black) DailScreen.clear() DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1) print("Dailing:") DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2) print("Symbol:") DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 + 1) print("State:") term.setBackgroundColour(colours.red) term.setTextColour(colours.black) IncomingScreen.clear() IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 - 1) print("Incoming Portal from ") IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2) print("?") IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 + 1) print("Portal Open False") term.setBackgroundColour(colours.blue) term.setTextColour(colours.white) local Event, p1, p2, p3, p4, p5 = os.pullEvent() if Event == "key" then -- wWen a key is pressed MenuScreen.clear() if p1 == keys.one or p1 == keys.numPad1 then -- Dial to dial(Addresses[1]) elseif p1 == keys.two or p1 == keys.numPad2 then -- Dial to dial(Addresses[2]) elseif p1 == keys.three or p1 == keys.numPad3 then -- Dial to dial(Addresses[3]) elseif p1 == keys.four or p1 == keys.numPad4 then -- Dial to dial(Addresses[4]) elseif p1 == keys.five or p1 == keys.numPad5 then -- Dial to dial(Addresses[5]) elseif p1 == keys.six or p1 == keys.numPad6 then -- Dial to dial(Addresses[6]) -- elseif p1 == keys.a then -- Dial to -- dial(Addresses[10]) elseif p1 == keys.m and Monitor then -- Change to monitor or back to terminal ChangeMonitor() elseif p1== keys.equals then -- Add address AddAddress() elseif p1 == keys.q then -- Quit Quitt() elseif p1 == keys.r then -- Reset Resset() elseif p1 == keys.zero or p1 == keys.numPad0 then -- Dissconnect interface.disconnectStargate() end Buttonshow(true) DailScreen.clear() CLS() elseif Event == "mouse_click" and MonitorState == "T" then -- For the buttons when clicked on them MenuScreen.clear() local Buton, MX, MY = p1, p2, p3 Button:buttonPressed(MX, MY) Buttonshow(true) DailScreen.clear() CLS() elseif Event == "monitor_touch" and MonitorState == "M" then -- For the buttons when clicked on them MenuScreen.clear() local Buton, MX, MY = p1, p2, p3 Button:buttonPressed(MX, MY) Buttonshow(true) DailScreen.clear() CLS() elseif Event == "timer" then -- when the timer expires if interface.isStargateConnected() == true then Buttonshow(false) Incoming() Buttonshow(true) end sleep(0) end end os.reboot()