mawesome4ever

Untitled

Jun 13th, 2021 (edited)
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.23 KB | None | 0 0
  1. --variables
  2. local output = GetPartFromPort(13, "Speaker")
  3. local input = GetPartFromPort(14, "Microphone")
  4. local Sections = {
  5.     {["Side"] = 1; ["TVSi"] = GetPartFromPort(8, "Screen"); ["TVMi"] = GetPartFromPort(7, "Screen"); ["TP"] = GetPartFromPort(9, "Teleporter"); TeleportInProgress = false; },
  6.     {["Side"] = 2; ["TVSi"] = GetPartFromPort(6, "Screen"); ["TVMi"] = GetPartFromPort(5, "Screen"); ["TP"] = GetPartFromPort(10, "Teleporter"); TeleportInProgress = false; },
  7.     {["Side"] = 3; ["TVSi"] = GetPartFromPort(3, "Screen"); ["TVMi"] = GetPartFromPort(4, "Screen");  ["TP"] = GetPartFromPort(11, "Teleporter"); TeleportInProgress = false; },
  8.     {["Side"] = 4; ["TVSi"] = GetPartFromPort(1, "Screen"); ["TVMi"] =  GetPartFromPort(2, "Screen"); ["TP"] = GetPartFromPort(12, "Teleporter"); TeleportInProgress = false; }
  9. }
  10. local wordsToListenFor = {}
  11. local Coordinates      = {}
  12. local LastSpoke
  13. --Clears the screen of elements for all the screens
  14. for i, Section in ipairs(Sections) do
  15.     if Section.TVSi then
  16.         Section.TVSi:ClearElements()
  17.     end
  18.     if Section.TVMi then
  19.         Section.TVMi:ClearElements()
  20.     end
  21. end
  22. --Helper Functions
  23. local function FormattedLabel(Text,Size,Position)
  24.     local textLabel = {}
  25.     textLabel.Text = Text or ""
  26.     textLabel.Size = Size or UDim2.new(1,0,1,0)
  27.     textLabel.Position = Position or UDim2.new(0,0,0,0)
  28.     textLabel.Font = Enum.Font.SciFi
  29.     textLabel.TextColor3 = Color3.fromRGB(129, 202, 158)
  30.     textLabel.TextXAlignment = Enum.TextXAlignment.Center
  31.     textLabel.TextYAlignment = Enum.TextYAlignment.Center
  32.     textLabel.TextWrapped = true
  33.     textLabel.TextScaled = true
  34.     textLabel.BackgroundColor3 = Color3.fromRGB(0,0,0)
  35.     textLabel.LayoutOrder = AllTexts
  36.     textLabel.BackgroundTransparency = 0.5
  37.     return textLabel
  38. end
  39. local function Chatted(Player, WithText)
  40.     local PotentialCoord = string.split(WithText, ",")
  41.     if #PotentialCoord > 3 and type(tonumber(PotentialCoord[1]))=="number" and type(tonumber(PotentialCoord[2]))=="number" and type(tonumber(PotentialCoord[3]))=="number" then
  42.         for _,Section in ipairs(Sections) do
  43.             if Section.TeleportData and Section.TeleportData.From == Player then
  44.                 output:Chat(Player.." your teleport is waiting on sec "..Section.Side)
  45.                 LastSpoke = tick()
  46.                 return
  47.             end
  48.         end
  49.         table.insert(Coordinates, {From = Player, Coord = PotentialCoord})
  50.     end
  51. end
  52. input:ConnectToEvent("Chatted", Chatted)
  53. --Animates two elements at the same time, this so elements on both screens are animated
  54. local function Animate(Element1, Element2, Property, ToProp, Duration)
  55.     for i=0, 1,Duration/100 do
  56.         Element1[Property] = Element1[Property]:Lerp(ToProp, i)
  57.         Element2[Property] = Element2[Property]:Lerp(ToProp, i)
  58.     end
  59. end
  60. --creates an element on both screens inside a section
  61. local function Create(InSec, Element, Props)
  62.     local el1 = InSec.TVSi:CreateElement(Element, Props)
  63.     local el2 = InSec.TVMi:CreateElement(Element, Props)
  64.     return el1, el2
  65. end
  66. local function UpdateStatus(InSec, WithText, andText)
  67.     InSec.Status1.Text = WithText or ""
  68.     InSec.Status2.Text = WithText or ""
  69.     if andText then
  70.         InSec.Uni[1][1].Text, InSec.Uni[1][2].Text = andText[1], andText[1]
  71.         InSec.Uni[2][1].Text, InSec.Uni[2][2].Text = andText[2], andText[2]
  72.         InSec.Sys[1][1].Text, InSec.Sys[1][2].Text = andText[3], andText[3]
  73.         InSec.Sys[2][1].Text, InSec.Sys[2][2].Text = andText[4], andText[4]
  74.     end
  75. end
  76. output:Chat("Creating side text")
  77. LastSpoke = tick()
  78. --Runs a side check, make sure everything is connected properly
  79. for _, Section in ipairs(Sections) do
  80.     if Section.TVSi then
  81.         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)))
  82.         Section.SideTextS = UI
  83.     end
  84.     if Section.TVMi  then
  85.         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)))
  86.         Section.SideTextM = UI2
  87.     end
  88. end
  89. for _, Section in ipairs(Sections) do
  90.     Animate(Section.SideTextM, Section.SideTextS, "Size", UDim2.new(0.4,0,0.3,0), 2)
  91.     Animate(Section.SideTextM, Section.SideTextS, "Position", UDim2.new(0.6,0,0.7,0), 2)
  92.     Section.SideTextS.Text = "Sect: "..Section.Side
  93.     Section.SideTextM.Text = "Sect: "..Section.Side
  94. end
  95. for _, Section in ipairs(Sections) do
  96.     local El1, El2 = Create(Section, "TextLabel", FormattedLabel("No Coordinates Provided", UDim2.new(1,0,0.4,0),UDim2.new(0,0,0,0)))
  97.     local El3, El4 = Create(Section, "TextLabel", FormattedLabel("", UDim2.new(0.25,0,0.4,0),UDim2.new(0,0,0.4,0)))
  98.     local El5, El6 = Create(Section, "TextLabel", FormattedLabel("", UDim2.new(0.25,0,0.4,0),UDim2.new(0.25,0,0.4,0)))
  99.     local El7, El8 = Create(Section, "TextLabel", FormattedLabel("", UDim2.new(0.25,0,0.4,0),UDim2.new(0.50,0,0.4,0)))
  100.     local El9, El10 = Create(Section, "TextLabel", FormattedLabel("", UDim2.new(0.25,0,0.4,0),UDim2.new(0.75,0,0.4,0)))
  101.     Section.Status1 = El1
  102.     Section.Status2 = El2
  103.     Section.Uni = {{El3, El4}, {El5, El6}}
  104.     Section.Sys = {{El7, El8}, {El9, El10}}
  105. end
  106. output:Chat("Waiting for coordinates...")
  107. --
  108. LastSpoke = tick()
  109. while true do
  110.     wait()
  111.     local function Loop(List, AtInd)
  112.         if AtInd > #List then return end
  113.         local Sec = List[AtInd]
  114.         if not Sec.TeleportInProgress and Coordinates[1] then
  115.             Sec.TeleportInProgress = true
  116.             Sec.TeleportData = Coordinates[1]
  117.             Sec.TP:Configure({Coordinates = Coordinates[1]["Coord"][1]..", "..Coordinates[1]["Coord"][2]..", "..Coordinates[1]["Coord"][3]..", "..Coordinates[1]["Coord"][4]})
  118.             table.remove(Coordinates, 1)
  119.             UpdateStatus(Sec, "Teleporting "..Sec.TeleportData.From.."To", Sec.TeleportData.Coord)
  120.             Sec.TPAt      = tick()+11
  121.             output:Chat("Assigned "..Sec.TeleportData.From.." to sec "..Sec.Side)
  122.             LastSpoke = tick()
  123.         end
  124.         if Sec.TeleportInProgress then
  125.             if tick() < Sec.TPAt then
  126.                 UpdateStatus(Sec, "TP in "..math.floor(Sec.TPAt-tick()))
  127.             else
  128.                 Sec.TP:Trigger()
  129.                 Sec.TP:Configure({Coordinates = ""})
  130.                 Sec.TeleportInProgress = false
  131.                 Sec.TPAt = nil
  132.                 Sec.TeleportData = nil
  133.                 UpdateStatus(Sec, "No Coordinates Provided ", {"","","",""})
  134.             end
  135.         end
  136.         Loop(List, AtInd+1)
  137.     end
  138.     Loop(Sections, 1)
  139.     if tick()-LastSpoke > 15 then
  140.         output:Chat("Waiting for coordinates...")
  141.         LastSpoke = tick()
  142.     end
  143. end
Add Comment
Please, Sign In to add comment