From c7e802839dc1b1e628aa7db69808b496744bfc70 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Mon, 5 Aug 2024 16:22:41 -0600 Subject: [PATCH] Use tween to fade BGM out and in for paging --- Parts/TazTech/SingleZoneStation.rbxm | Bin 191706 -> 192525 bytes Parts/TazTech/Station.rbxm | Bin 141608 -> 142404 bytes Scripts/ButtonLeds.lua | 215 +++++++++++++++++++++++++++ Scripts/SeparateLEDsStation.lua | 215 +++++++++++++++++++++++++++ 4 files changed, 430 insertions(+) create mode 100644 Scripts/ButtonLeds.lua create mode 100644 Scripts/SeparateLEDsStation.lua diff --git a/Parts/TazTech/SingleZoneStation.rbxm b/Parts/TazTech/SingleZoneStation.rbxm index 4d14ef90ed0de90ab1c4858a137df3bfe563393c..9c7f91a8474abbbda322a51f3a75ee185b53884a 100644 GIT binary patch delta 2398 zcmXX|4R90J5#D|GPSOcu$;QS88T>2=$XLD#Obm4^u(1tz_^|;40Yc%Bo~*;t-OcG_ z$4nbFvD;vGm=a)6$+#2gn8GwAFeK^ZuO(AM%5+FO&?m^# zJ>9*%y}fVueY<;C|2ARIhZFXeVbxRRKPtzw<%FFIGXR(=W?|fM%i@26n5(nt9o*ia zrLr6(K^BO|ip%v@LAORM)Ngd}dF1?&m&xS(ws*-? zVQ|;Gq$*Mf(yVV3nhTFo=z0(!1uU^ro1Z&`aO9Q64^_q&k3D;lAi->Y|J&rT(Cy;H zN9$iF^8wEoM~(J0DH)nMbO0@lQ~Bq=v9tlg;53n!6@r6gn1*z zRfG43f(v1pz@pSask#bgMcFZ^^gaprcWCP{5@rve15g69Sacd-0vf%FatUOFR`KSx z&%j}3f;mY(2Dgiqb|afhtL<7wH+t4N11YYq)D5oLVJ4I-fU!&^c6Wc zIcrU7Mh}lO-k0Ns^L;3dEd<<+t|C|<_I>~+sZ9`UYORN|&}L`}iE!T|bG1||21UD| zrC)cFQy>z{+9xSveH*2D!rNM)ZIb6xAfJ$!&=(}Q1|?lb(bb3;L4VU^m=p@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#}XF|E~5bxk((wzihYdo*RUyUbfwQdUt>B$s*11#rv}AiuB%@F^_w8A?R;1?kg^ zv{=Xi!^G1V(siS~A?S-5YO5$HN6;Y%2tNn$bpS7pz!EJSGd!!+h(bT5X+6l^g_N+A zI#5pyCt;1M$+4xttN`gBAlie_Nw-N|6lo3#z+cAJ0DXCTqd*q8sT|kI%BVs2v4J!Q zo7>gk2N*RE6H->fTtlaD6sM>g7NN8f?N9;uJIq&aU_M`i{6b)_qJ0Z2uUB+Uhjf!L zWCojGco@wxhICox)0~-%ta+9pCCM(Rp#h2B2FqNI>_o^TaEi&2&oiW)KnsCVLX)4{ z!eIevSfTj*TMG!e#5f`nxa6w$ne+E58;gDm?1q!B{6T$WQYN#3{MA(9dNgtN^+sg5=Wua9M+gTQI9tq1rH zNngWq6@)~Hx1p)&OWVZHtND`lQ z-ta{`JkhXkv*zvtFagFPZWFKrteHei9%kk(()^Q%=z_FcEV(CiF41VzwbnMmLU+j1+>2WIEb@3i}o;UglY)2VTOv60F0+XgFMRL1pB>PzL4|&qI+i3WXrma~XGs3Z9mb=W1 zV8~~*duZMJ^^m)?sML!9+X&=w(vKLP-Am-q);LF;wo*gao~HG=4Lxem)N6CkLGm&< z3mbvl;Kk#>)Iy|Dp|1L)4>`63+-krN%-cwkjbPb`>_Q83i-io@%q&C%W+{ULKqi2L z=F&O~JRljgMsvg~#Hn5rg~xWX-u?ulm5UXlmKLTzqG;|yO<+#jxlO|CDp^^>d29Us zRUDZDY11sDNE^aJ&oVt0RceE3Yeyxqi6Vz@b0oRmPJ%p4MlNMx)h{zhh>0p$2>iQOqF_aX**zPFPVk69ek;Ie+HT9^x`lP UXp(14M$GM?CcOvE!Xh%^KRzH<8UO$Q diff --git a/Scripts/ButtonLeds.lua b/Scripts/ButtonLeds.lua new file mode 100644 index 0000000..ac9c0d9 --- /dev/null +++ b/Scripts/ButtonLeds.lua @@ -0,0 +1,215 @@ +local system = script.Parent.Parent.Parent +local zones = {} +local mic = script.Parent["Panel Mic"].mic.AudioListener +local buttons = {} +local leds = {} +local ptt = false +pttButton = script.Parent["Panel Mic"].mic.CD +local selectedZones = {} +local tones = {} +local thisTimeout = nil +local TweenService = game:GetService("TweenService") + +function smoothTransition(startValue, endValue, duration, updateFunction) + -- 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() + end) +end + +function toggleZone(zoneNumber) + if ptt then return end -- We're transmitting, don't toggle zones + if selectedZones[zoneNumber] then + selectedZones[zoneNumber] = nil + leds[zoneNumber].Color = Color3.new(202/255, 203/255, 209/255) + leds[zoneNumber].Material = Enum.Material.SmoothPlastic + else + if zones[zoneNumber].ZoneInput.Wire.Connected then + -- Nothing, in use + else + selectedZones[zoneNumber] = zones[zoneNumber] + end + end +end + +function flashSelected() + local state = false + while true do + while not ptt do + for i,e in pairs(selectedZones) do + if state then + leds[i].Material = Enum.Material.SmoothPlastic + leds[i].Color = Color3.new(202/255, 203/255, 209/255) + else + leds[i].Material = Enum.Material.Neon + leds[i].Color = Color3.new(1,1,0) + end + end + state = not state + wait(.2) + end + wait() + end +end + +function checkZones() + while true do + for i,e in pairs(leds) do + if not selectedZones[e.Name] then + if zones[e.Name].ZoneInput.Wire.Connected then + e.Material = Enum.Material.Neon + e.Color = Color3.new(1,0,0) + else + e.Material = Enum.Material.SmoothPlastic + e.Color = Color3.new(202/255, 203/255, 209/255) + end + elseif not ptt and selectedZones[e.Name] and zones[e.Name].ZoneInput.Wire.Connected then + -- Someone else took the zone, drop it from selections + toggleZone(e.Name) + end + end + wait(0) + end +end +function checkReady() + local ready = true + while true do + if ptt then + ready = true + for i,e in pairs(selectedZones) do + print("checking " .. e.Name) + leds[e.Name].Material = Enum.Material.Neon + local thisTone = tones[e.PageTone.Value] + if thisTone.TimeLength == 0 then + -- Empty audio, stop playing it + thisTone:Stop() + end + if thisTone.IsPlaying then + leds[e.Name].Color = Color3.new(1,1,0) + ready = false + else + leds[e.Name].Color = Color3.new(0,1,0) + end + end + else + ready = false + end + wait() + end +end +function togglePTT() + print("toggling ptt") + if ptt then + ptt = false + print("off") + thisTimeout = nil + for i,e in pairs(selectedZones) 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 + local ready = false + for i,e in pairs(selectedZones) do + ready = true + print("we have a zone, continue") + end + if not ready then return end + ptt = true + for i,e in pairs(selectedZones) do + task.spawn(function() + local thisTone = tones[zones[e.Name].PageTone.Value] + smoothTransition(zones[e.Name].BGM.Volume, script.Parent.BGMDown.Value, 1, function(value) + zones[e.Name].BGM.Volume = value + end) + 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 + + +for i,e in ipairs(script.Parent.Buttons:GetChildren()) do + buttons[e.Name] = e + print("Adding button " .. e.Name) + e.CD.MouseClick:Connect(function() + toggleZone(e.Name) + print("button pressed " .. e.Name) + end) +end + +pttButton.MouseClick:Connect(function() + togglePTT() +end) + +for i,e in ipairs(script.Parent.Buttons:GetChildren()) do + leds[e.Name] = e +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(flashSelected) +task.spawn(checkReady) \ No newline at end of file diff --git a/Scripts/SeparateLEDsStation.lua b/Scripts/SeparateLEDsStation.lua new file mode 100644 index 0000000..8c33ff6 --- /dev/null +++ b/Scripts/SeparateLEDsStation.lua @@ -0,0 +1,215 @@ +local system = script.Parent.Parent.Parent +local zones = {} +local mic = script.Parent["Panel Mic"].mic.AudioListener +local buttons = {} +local leds = {} +local ptt = false +pttButton = script.Parent["Panel Mic"].mic.CD +local selectedZones = {} +local tones = {} +local thisTimeout = nil +local TweenService = game:GetService("TweenService") + +function smoothTransition(startValue, endValue, duration, updateFunction) + -- 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() + end) +end + +function toggleZone(zoneNumber) + if ptt then return end -- We're transmitting, don't toggle zones + if selectedZones[zoneNumber] then + selectedZones[zoneNumber] = nil + leds[zoneNumber].Color = Color3.new(202/255, 203/255, 209/255) + leds[zoneNumber].Material = Enum.Material.SmoothPlastic + else + if zones[zoneNumber].ZoneInput.Wire.Connected then + -- Nothing, in use + else + selectedZones[zoneNumber] = zones[zoneNumber] + end + end +end + +function flashSelected() + local state = false + while true do + while not ptt do + for i,e in pairs(selectedZones) do + if state then + leds[i].Material = Enum.Material.SmoothPlastic + leds[i].Color = Color3.new(202/255, 203/255, 209/255) + else + leds[i].Material = Enum.Material.Neon + leds[i].Color = Color3.new(1,1,0) + end + end + state = not state + wait(.2) + end + wait() + end +end + +function checkZones() + while true do + for i,e in pairs(leds) do + if not selectedZones[e.Name] then + if zones[e.Name].ZoneInput.Wire.Connected then + e.Material = Enum.Material.Neon + e.Color = Color3.new(1,0,0) + else + e.Material = Enum.Material.SmoothPlastic + e.Color = Color3.new(202/255, 203/255, 209/255) + end + elseif not ptt and selectedZones[e.Name] and zones[e.Name].ZoneInput.Wire.Connected then + -- Someone else took the zone, drop it from selections + toggleZone(e.Name) + end + end + wait(0) + end +end +function checkReady() + local ready = true + while true do + if ptt then + ready = true + for i,e in pairs(selectedZones) do + print("checking " .. e.Name) + leds[e.Name].Material = Enum.Material.Neon + local thisTone = tones[e.PageTone.Value] + if thisTone.TimeLength == 0 then + -- Empty audio, stop playing it + thisTone:Stop() + end + if thisTone.IsPlaying then + leds[e.Name].Color = Color3.new(1,1,0) + ready = false + else + leds[e.Name].Color = Color3.new(0,1,0) + end + end + else + ready = false + end + wait() + end +end +function togglePTT() + print("toggling ptt") + if ptt then + ptt = false + print("off") + thisTimeout = nil + for i,e in pairs(selectedZones) 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 + local ready = false + for i,e in pairs(selectedZones) do + ready = true + print("we have a zone, continue") + end + if not ready then return end + ptt = true + for i,e in pairs(selectedZones) do + task.spawn(function() + local thisTone = tones[zones[e.Name].PageTone.Value] + smoothTransition(zones[e.Name].BGM.Volume, script.Parent.BGMDown.Value, 1, function(value) + zones[e.Name].BGM.Volume = value + end) + 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 + + +for i,e in ipairs(script.Parent.Buttons:GetChildren()) do + buttons[e.Name] = e + print("Adding button " .. e.Name) + e.CD.MouseClick:Connect(function() + toggleZone(e.Name) + print("button pressed " .. e.Name) + end) +end + +pttButton.MouseClick:Connect(function() + togglePTT() +end) + +for i,e in ipairs(script.Parent.Leds:GetChildren()) do + leds[e.Name] = e +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(flashSelected) +task.spawn(checkReady) \ No newline at end of file