Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --variables
- local output = GetPartFromPort(13, "Speaker")
- local input = GetPartFromPort(14, "Microphone")
- local Sections = {
- {["Side"] = 1; ["TVSi"] = GetPartFromPort(8, "Screen"); ["TVMi"] = GetPartFromPort(7, "Screen"); ["TP"] = GetPartFromPort(9, "Teleporter"); TeleportInProgress = false; },
- {["Side"] = 2; ["TVSi"] = GetPartFromPort(6, "Screen"); ["TVMi"] = GetPartFromPort(5, "Screen"); ["TP"] = GetPartFromPort(10, "Teleporter"); TeleportInProgress = false; },
- {["Side"] = 3; ["TVSi"] = GetPartFromPort(3, "Screen"); ["TVMi"] = GetPartFromPort(4, "Screen"); ["TP"] = GetPartFromPort(11, "Teleporter"); TeleportInProgress = false; },
- {["Side"] = 4; ["TVSi"] = GetPartFromPort(1, "Screen"); ["TVMi"] = GetPartFromPort(2, "Screen"); ["TP"] = GetPartFromPort(12, "Teleporter"); TeleportInProgress = false; }
- }
- local wordsToListenFor = {}
- local Coordinates = {}
- local LastSpoke
- --Clears the screen of elements for all the screens
- for i, Section in ipairs(Sections) do
- if Section.TVSi then
- Section.TVSi:ClearElements()
- end
- if Section.TVMi then
- Section.TVMi:ClearElements()
- end
- end
- --Helper Functions
- local function FormattedLabel(Text,Size,Position)
- local textLabel = {}
- textLabel.Text = Text or ""
- textLabel.Size = Size or UDim2.new(1,0,1,0)
- textLabel.Position = Position or UDim2.new(0,0,0,0)
- textLabel.Font = Enum.Font.SciFi
- textLabel.TextColor3 = Color3.fromRGB(129, 202, 158)
- textLabel.TextXAlignment = Enum.TextXAlignment.Center
- textLabel.TextYAlignment = Enum.TextYAlignment.Center
- textLabel.TextWrapped = true
- textLabel.TextScaled = true
- textLabel.BackgroundColor3 = Color3.fromRGB(0,0,0)
- textLabel.LayoutOrder = AllTexts
- textLabel.BackgroundTransparency = 0.5
- return textLabel
- end
- local function Chatted(Player, WithText)
- local PotentialCoord = string.split(WithText, ",")
- if #PotentialCoord > 3 and type(tonumber(PotentialCoord[1]))=="number" and type(tonumber(PotentialCoord[2]))=="number" and type(tonumber(PotentialCoord[3]))=="number" then
- for _,Section in ipairs(Sections) do
- if Section.TeleportData and Section.TeleportData.From == Player then
- output:Chat(Player.." your teleport is waiting on sec "..Section.Side)
- LastSpoke = tick()
- return
- end
- end
- table.insert(Coordinates, {From = Player, Coord = PotentialCoord})
- end
- end
- input:ConnectToEvent("Chatted", Chatted)
- --Animates two elements at the same time, this so elements on both screens are animated
- local function Animate(Element1, Element2, Property, ToProp, Duration)
- for i=0, 1,Duration/100 do
- Element1[Property] = Element1[Property]:Lerp(ToProp, i)
- Element2[Property] = Element2[Property]:Lerp(ToProp, i)
- end
- end
- --creates an element on both screens inside a section
- local function Create(InSec, Element, Props)
- local el1 = InSec.TVSi:CreateElement(Element, Props)
- local el2 = InSec.TVMi:CreateElement(Element, Props)
- return el1, el2
- end
- local function UpdateStatus(InSec, WithText, andText)
- InSec.Status1.Text = WithText or ""
- InSec.Status2.Text = WithText or ""
- if andText then
- InSec.Uni[1][1].Text, InSec.Uni[1][2].Text = andText[1], andText[1]
- InSec.Uni[2][1].Text, InSec.Uni[2][2].Text = andText[2], andText[2]
- InSec.Sys[1][1].Text, InSec.Sys[1][2].Text = andText[3], andText[3]
- InSec.Sys[2][1].Text, InSec.Sys[2][2].Text = andText[4], andText[4]
- end
- end
- output:Chat("Creating side text")
- LastSpoke = tick()
- --Runs a side check, make sure everything is connected properly
- for _, Section in ipairs(Sections) do
- if Section.TVSi then
- local UI = Section.TVSi:CreateElement("TextLabel", FormattedLabel("This is Screen side \n "..tostring(Section.Side).." on the side", UDim2.new(1,0,1,0), UDim2.new(0,0,0,0)))
- Section.SideTextS = UI
- end
- if Section.TVMi then
- local UI2 = Section.TVMi:CreateElement("TextLabel", FormattedLabel("This is Screen side \n "..tostring(Section.Side).." in the middle", UDim2.new(1,0,1,0), UDim2.new(0,0,0,0)))
- Section.SideTextM = UI2
- end
- end
- for _, Section in ipairs(Sections) do
- Animate(Section.SideTextM, Section.SideTextS, "Size", UDim2.new(0.4,0,0.3,0), 2)
- Animate(Section.SideTextM, Section.SideTextS, "Position", UDim2.new(0.6,0,0.7,0), 2)
- Section.SideTextS.Text = "Sect: "..Section.Side
- Section.SideTextM.Text = "Sect: "..Section.Side
- end
- for _, Section in ipairs(Sections) do
- local El1, El2 = Create(Section, "TextLabel", FormattedLabel("No Coordinates Provided", UDim2.new(1,0,0.4,0),UDim2.new(0,0,0,0)))
- local El3, El4 = Create(Section, "TextLabel", FormattedLabel("", UDim2.new(0.25,0,0.4,0),UDim2.new(0,0,0.4,0)))
- local El5, El6 = Create(Section, "TextLabel", FormattedLabel("", UDim2.new(0.25,0,0.4,0),UDim2.new(0.25,0,0.4,0)))
- local El7, El8 = Create(Section, "TextLabel", FormattedLabel("", UDim2.new(0.25,0,0.4,0),UDim2.new(0.50,0,0.4,0)))
- local El9, El10 = Create(Section, "TextLabel", FormattedLabel("", UDim2.new(0.25,0,0.4,0),UDim2.new(0.75,0,0.4,0)))
- Section.Status1 = El1
- Section.Status2 = El2
- Section.Uni = {{El3, El4}, {El5, El6}}
- Section.Sys = {{El7, El8}, {El9, El10}}
- end
- output:Chat("Waiting for coordinates...")
- --
- LastSpoke = tick()
- while true do
- wait()
- local function Loop(List, AtInd)
- if AtInd > #List then return end
- local Sec = List[AtInd]
- if not Sec.TeleportInProgress and Coordinates[1] then
- Sec.TeleportInProgress = true
- Sec.TeleportData = Coordinates[1]
- Sec.TP:Configure({Coordinates = Coordinates[1]["Coord"][1]..", "..Coordinates[1]["Coord"][2]..", "..Coordinates[1]["Coord"][3]..", "..Coordinates[1]["Coord"][4]})
- table.remove(Coordinates, 1)
- UpdateStatus(Sec, "Teleporting "..Sec.TeleportData.From.."To", Sec.TeleportData.Coord)
- Sec.TPAt = tick()+11
- output:Chat("Assigned "..Sec.TeleportData.From.." to sec "..Sec.Side)
- LastSpoke = tick()
- end
- if Sec.TeleportInProgress then
- if tick() < Sec.TPAt then
- UpdateStatus(Sec, "TP in "..math.floor(Sec.TPAt-tick()))
- else
- Sec.TP:Trigger()
- Sec.TP:Configure({Coordinates = ""})
- Sec.TeleportInProgress = false
- Sec.TPAt = nil
- Sec.TeleportData = nil
- UpdateStatus(Sec, "No Coordinates Provided ", {"","","",""})
- end
- end
- Loop(List, AtInd+1)
- end
- Loop(Sections, 1)
- if tick()-LastSpoke > 15 then
- output:Chat("Waiting for coordinates...")
- LastSpoke = tick()
- end
- end
Add Comment
Please, Sign In to add comment