From d0418a3e8278da3298def60ac46d24889855c14e Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Fri, 9 Aug 2024 00:21:31 -0600 Subject: [PATCH] Big update - Updated ALL models to use the new wait for bgm fadeout - Finally update raw lua scripts, sorry --- Parts/Stations/AllZoneStation.TazTech.rbxm | Bin 192658 -> 192758 bytes Parts/Stations/FancyStation.Bryce.rbxm | Bin 216458 -> 216538 bytes Parts/Stations/SingleZoneStation.TazTech.rbxm | Bin 192607 -> 192645 bytes Parts/Stations/Station.TazTech.rbxm | Bin 142513 -> 142503 bytes Scripts/AllZones.lua | 172 ++++++++++++++++++ Scripts/ButtonLeds.lua | 10 +- Scripts/SeparateLEDsStation.lua | 10 +- Scripts/SingleStation.lua | 152 ++++++++++++++++ 8 files changed, 341 insertions(+), 3 deletions(-) create mode 100644 Scripts/AllZones.lua create mode 100644 Scripts/SingleStation.lua diff --git a/Parts/Stations/AllZoneStation.TazTech.rbxm b/Parts/Stations/AllZoneStation.TazTech.rbxm index 2e2886c6c92f5e5478bd71fce9454b66b715c717..50599854320b4a9bbb5b714f737b4bb1f7ce9e61 100644 GIT binary patch delta 1505 zcmWNRe{36f8OERYz5Cwz&P^{)yRA*v?rWE|c58cf(xy#Oph=uX5l!nQS<2RJ^c0`% zTkJc}J}(988K9~=~QX_!G=HrilBmN2#sn&qCYk<0RuE`z{FB%8=5wi z`{#Z1{`bBgJLuksPz*Sim0`}%>DX}nH$+4bC3^~=Qf)9TvpnXA0HXC6fv_%e76Y60C>ud*E6LKq=&5gW`C zpcoaVys}>b1wahj^$Eo{`Ydp9c6RZ<$ zOg&6=AKfP_zFk|S{ga{GQ1}D7Wn`ZFA0L5sn0SWyAe8f@{Iz@I8gCW9;9KO!-Tv#m zZ|g~xc5S`7_BckD+@Sgu5 za)NnQw|C#X&Y$Z%v9I8?f~J3L1N3E;T7o}IeMUy1KJjQWCEH%${z~0o?gmXOlcwX9 zvf}JQ)md1)-}ju>0`6I=x;5vI!j~mKeEuDQRn;)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7f7bf11 --- /dev/null +++ b/Scripts/AllZones.lua @@ -0,0 +1,172 @@ +local system = script.Parent.Parent.Parent +local zones = {} +local mic = script.Parent.WallMic["Mic Enclosure"].AudioListener +local buttons = {} +local led = script.Parent.LED +local ptt = false +pttButton = script.Parent.WallMic["Mic Enclosure"].CD +local tones = {} +local thisTimeout = nil +local systemReady = true +local systemOverride = script.Parent.override.Value +local TweenService = game:GetService("TweenService") +local waiting = false + +function smoothTransition(startValue, endValue, duration, updateFunction) + local finished = false + -- Create a temporary NumberValue to tween + local numberValue = Instance.new("NumberValue") + numberValue.Value = startValue + + -- Create TweenInfo + local tweenInfo = TweenInfo.new( + duration, -- Duration of the tween + Enum.EasingStyle.Linear, -- Easing style + Enum.EasingDirection.InOut, -- Easing direction + 0, -- Number of times to repeat + false, -- Whether to reverse the tween + 0 -- Delay time before starting the tween + ) + + -- Create tween goal + local tweenGoal = {Value = endValue} + + -- Create the tween + local tween = TweenService:Create(numberValue, tweenInfo, tweenGoal) + + -- Connect the update function to the Changed event + local connection + connection = numberValue.Changed:Connect(function() + -- Call the update function with the current value + updateFunction(numberValue.Value) + end) + + -- Play the tween + tween:Play() + + -- Cleanup after tween completes + tween.Completed:Connect(function() + -- Ensure the final value is set to endValue + updateFunction(endValue) + -- Disconnect the event and remove the NumberValue instance + connection:Disconnect() + numberValue:Destroy() + finished = true + end) + repeat wait() until finished + finished = false +end + +function checkZones() + while true do + systemReady = true + for i,e in pairs(zones) do + if e.ZoneInput.Wire.Connected then + if not systemOverride then + systemReady = false + end + end + end + if not ptt then + if not systemReady then + led.Material = Enum.Material.Neon + led.Color = Color3.new(1,0,0) + else + led.Material = Enum.Material.SmoothPlastic + led.Color = Color3.new(202/255, 203/255, 209/255) + end + end + wait(0) + end +end +function checkReady() + while true do + ready = true + for i,e in pairs(zones) do + local thisTone = tones[e.PageTone.Value] + if thisTone.TimeLength == 0 then + -- Empty audio, stop playing it + thisTone:Stop() + end + if thisTone.IsPlaying or waiting then + ready = false + end + end + if ready and ptt then + -- set led to green + led.Material = Enum.Material.Neon + led.Color = Color3.new(0,1,0) + elseif ptt then + -- set led to solid yellow + led.Material = Enum.Material.Neon + led.Color = Color3.new(1,1,0) + end + wait() + end +end +function togglePTT() + print(ready) + print("toggling ptt") + if ptt then + ptt = false + print("off") + thisTimeout = nil + for i,e in pairs(zones) do + task.spawn(function() + local thisTone = tones[zones[e.Name].EndTone.Value] + zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + zones[e.Name].ZoneInput.Wire.SourceInstance = nil + smoothTransition(zones[e.Name].BGM.Volume,script.Parent.BGMUp.Value, 1, function(value) + zones[e.Name].BGM.Volume = value + end) + end) + end + else + if not systemReady then return end + ptt = true + for i,e in pairs(zones) do + task.spawn(function() + local thisTone = tones[zones[e.Name].PageTone.Value] + waiting = true + smoothTransition(zones[e.Name].BGM.Volume, script.Parent.BGMDown.Value, 1, function(value) + zones[e.Name].BGM.Volume = value + end) + waiting = false + zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + if(ptt) then + -- We havent stopped PTT before page tone done, hit it + zones[e.Name].ZoneInput.Wire.SourceInstance = script.Parent.StationOutput + thisTimeout = math.random(1,1000000) + task.spawn(function() + local myTimeout = tonumber(tostring(thisTimeout)) + wait(script.Parent.TimeoutSeconds.Value) + if myTimeout == thisTimeout then + togglePTT() + end + end) + end + end) + end + end + +end + + +pttButton.MouseClick:Connect(function() + togglePTT() +end) + +for i,e in ipairs(system.Zones:GetChildren()) do + zones[e.Name] = e +end + +for i,e in ipairs(system.Tones:GetChildren()) do + tones[e.Name] = e +end + +task.spawn(checkZones) +task.spawn(checkReady) \ No newline at end of file diff --git a/Scripts/ButtonLeds.lua b/Scripts/ButtonLeds.lua index ac9c0d9..93457eb 100644 --- a/Scripts/ButtonLeds.lua +++ b/Scripts/ButtonLeds.lua @@ -8,9 +8,11 @@ pttButton = script.Parent["Panel Mic"].mic.CD local selectedZones = {} local tones = {} local thisTimeout = nil +local waiting = false local TweenService = game:GetService("TweenService") function smoothTransition(startValue, endValue, duration, updateFunction) + local finished = false -- Create a temporary NumberValue to tween local numberValue = Instance.new("NumberValue") numberValue.Value = startValue @@ -48,7 +50,10 @@ function smoothTransition(startValue, endValue, duration, updateFunction) -- Disconnect the event and remove the NumberValue instance connection:Disconnect() numberValue:Destroy() + finished = true end) + repeat wait() until finished + finished = false end function toggleZone(zoneNumber) @@ -118,7 +123,7 @@ function checkReady() -- Empty audio, stop playing it thisTone:Stop() end - if thisTone.IsPlaying then + if waiting or thisTone.IsPlaying then leds[e.Name].Color = Color3.new(1,1,0) ready = false else @@ -139,6 +144,7 @@ function togglePTT() thisTimeout = nil for i,e in pairs(selectedZones) do task.spawn(function() + toggleZone(e.Name) local thisTone = tones[zones[e.Name].EndTone.Value] zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone thisTone:Play() @@ -160,9 +166,11 @@ function togglePTT() for i,e in pairs(selectedZones) do task.spawn(function() local thisTone = tones[zones[e.Name].PageTone.Value] + waiting = true smoothTransition(zones[e.Name].BGM.Volume, script.Parent.BGMDown.Value, 1, function(value) zones[e.Name].BGM.Volume = value end) + waiting = false zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone thisTone:Play() wait(thisTone.TimeLength) diff --git a/Scripts/SeparateLEDsStation.lua b/Scripts/SeparateLEDsStation.lua index 8c33ff6..e1c7f54 100644 --- a/Scripts/SeparateLEDsStation.lua +++ b/Scripts/SeparateLEDsStation.lua @@ -9,8 +9,9 @@ local selectedZones = {} local tones = {} local thisTimeout = nil local TweenService = game:GetService("TweenService") - +local waiting = false function smoothTransition(startValue, endValue, duration, updateFunction) + local finished = false -- Create a temporary NumberValue to tween local numberValue = Instance.new("NumberValue") numberValue.Value = startValue @@ -48,7 +49,10 @@ function smoothTransition(startValue, endValue, duration, updateFunction) -- Disconnect the event and remove the NumberValue instance connection:Disconnect() numberValue:Destroy() + finished = true end) + repeat wait() until finished + finished = false end function toggleZone(zoneNumber) @@ -118,7 +122,7 @@ function checkReady() -- Empty audio, stop playing it thisTone:Stop() end - if thisTone.IsPlaying then + if waiting or thisTone.IsPlaying then leds[e.Name].Color = Color3.new(1,1,0) ready = false else @@ -160,9 +164,11 @@ function togglePTT() for i,e in pairs(selectedZones) do task.spawn(function() local thisTone = tones[zones[e.Name].PageTone.Value] + waiting = true smoothTransition(zones[e.Name].BGM.Volume, script.Parent.BGMDown.Value, 1, function(value) zones[e.Name].BGM.Volume = value end) + waiting = false zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone thisTone:Play() wait(thisTone.TimeLength) diff --git a/Scripts/SingleStation.lua b/Scripts/SingleStation.lua new file mode 100644 index 0000000..cc4ac67 --- /dev/null +++ b/Scripts/SingleStation.lua @@ -0,0 +1,152 @@ +local system = script.Parent.Parent.Parent +local mic = script.Parent.WallMic["Mic Enclosure"].AudioListener +local buttons = {} +local led = script.Parent.LED +local ptt = false +pttButton = script.Parent.WallMic["Mic Enclosure"].CD +local zones = {} +local tones = {} +local thisTimeout = nil +local TweenService = game:GetService("TweenService") +local waiting = false + +function smoothTransition(startValue, endValue, duration, updateFunction) + local finished = false + -- Create a temporary NumberValue to tween + local numberValue = Instance.new("NumberValue") + numberValue.Value = startValue + + -- Create TweenInfo + local tweenInfo = TweenInfo.new( + duration, -- Duration of the tween + Enum.EasingStyle.Linear, -- Easing style + Enum.EasingDirection.InOut, -- Easing direction + 0, -- Number of times to repeat + false, -- Whether to reverse the tween + 0 -- Delay time before starting the tween + ) + + -- Create tween goal + local tweenGoal = {Value = endValue} + + -- Create the tween + local tween = TweenService:Create(numberValue, tweenInfo, tweenGoal) + + -- Connect the update function to the Changed event + local connection + connection = numberValue.Changed:Connect(function() + -- Call the update function with the current value + updateFunction(numberValue.Value) + end) + + -- Play the tween + tween:Play() + + -- Cleanup after tween completes + tween.Completed:Connect(function() + -- Ensure the final value is set to endValue + updateFunction(endValue) + -- Disconnect the event and remove the NumberValue instance + connection:Disconnect() + numberValue:Destroy() + finished = true + end) + repeat wait() until finished + finished = false +end + +for i, e in ipairs(system.Tones:GetChildren()) do tones[e.Name] = e end +for i, e in ipairs(system.Zones:GetChildren()) do zones[e.Name] = e end +local zone = zones[script.Parent.Zone.Value] + +function checkZones() + while true do + if zone.ZoneInput.Wire.Connected and not ptt then + led.Material = Enum.Material.Neon + led.Color = Color3.new(1, 0, 0) + elseif not ptt then + led.Material = Enum.Material.SmoothPlastic + led.Color = Color3.new(163/255, 162/255, 165/255) + end + wait(0) + end +end +function checkReady() + local ready = true + while true do + if ptt then + ready = true + + -- print("checking " .. zone) + led.Material = Enum.Material.Neon + local thisTone = tones[zone.PageTone.Value] + if thisTone.TimeLength == 0 then + -- Empty audio, stop playing it + thisTone:Stop() + end + if waiting or thisTone.IsPlaying then + led.Color = Color3.new(1, 1, 0) + ready = false + else + led.Color = Color3.new(0, 1, 0) + end + else + ready = false + end + wait() + end +end + + + +function togglePTT() + + -- print("toggling ptt") + if ptt then + ptt = false + thisTimeout = nil + -- print("off") + task.spawn(function() + local thisTone = tones[zone.EndTone.Value] + zone.ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + zone.ZoneInput.Wire.SourceInstance = nil + smoothTransition(zone.BGM.Volume, script.Parent.BGMUp.Value, 1, function(value) + zone.BGM.Volume = value + end) + end) + else + if zone.ZoneInput.Wire.Connected then return end + ptt = true + task.spawn(function() + local thisTone = tones[zone.PageTone.Value] + waiting = true + smoothTransition(zone.BGM.Volume, script.Parent.BGMDown.Value, 1, function(value) + zone.BGM.Volume = value + end) + waiting = false + zone.ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + if (ptt) then + -- We havent stopped PTT before page tone done, hit it + zone.ZoneInput.Wire.SourceInstance = script.Parent.StationOutput + thisTimeout = math.random(1, 1000000) + task.spawn(function() + local myTimeout = tonumber(tostring(thisTimeout)) + wait(script.Parent.TimeoutSeconds.Value) + if myTimeout == thisTimeout then + togglePTT() + end + end) + end + end) + end + +end + +pttButton.MouseClick:Connect(function() togglePTT() end) + +task.spawn(checkReady) +task.spawn(checkZones) \ No newline at end of file