Skip to content

Commit

Permalink
Potentially fix #21
Browse files Browse the repository at this point in the history
Still needs to be tested
  • Loading branch information
parker02311 committed Oct 5, 2024
1 parent 48a8980 commit d36f0ba
Showing 1 changed file with 46 additions and 44 deletions.
90 changes: 46 additions & 44 deletions src/ExportTemplates/EVCPlugin.luau
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ local function registerRotator(lightName: string)
motor.Parent = motorPart

for i, v in pairs(lightParts[lightName]:GetChildren()) do
if v:IsA("WeldConstraint") and v.Part1 == car.DriveSeat then
v:Destroy()
end
end
if v:IsA("WeldConstraint") and v.Part1 == car.DriveSeat then
v:Destroy()
end
end

for i, v in pairs(car.DriveSeat:GetChildren()) do
if v:IsA("Weld") and v.Part1 == lightParts[lightName] then
Expand Down Expand Up @@ -579,7 +579,9 @@ for _, func in pairs(moduleStore:GetChildren()) do
if faderTable.run == false then
break
elseif lights[lightName].running_module == patternModule and lightParts[lightName] then
if hasBeenOverridden == true then hasBeenOverridden = false end
if hasBeenOverridden == true then
hasBeenOverridden = false
end
if faderTable.currentRunner >= rawlen(lightData) then
faderTable.currentRunner = 1
else
Expand Down Expand Up @@ -645,7 +647,7 @@ for _, func in pairs(moduleStore:GetChildren()) do
end
end
end

for _, lighto in pairs(fader.lightos) do
lighto.ImageTransparency = lighto:GetAttribute("defaultTransparency")
end
Expand Down Expand Up @@ -989,7 +991,7 @@ local function playStopModified(name, modifiedName)
end
end

local function playSiren(name)
local function stopSiren(name)
if soundPart == nil then
return
end
Expand All @@ -1005,45 +1007,21 @@ local function playSiren(name)
if sirenData.overrideOtherSounds then
if sirenData._type == "hold" then
for _, v in pairs(soundPart:GetChildren()) do
if v:IsA("Sound") and v ~= sound then
if v:GetAttribute("OriginalVolume") == nil then
v:SetAttribute("OriginalVolume", v.Volume)
end
v.Volume = 0
end
end
else
for _, v in pairs(soundPart:GetChildren()) do
if v:IsA("Sound") and v ~= sound then
v:Stop()
if v:IsA("Sound") and v ~= sound and v:GetAttribute("OriginalVolume") then
v.Volume = v:GetAttribute("OriginalVolume")
end
end
end
end

local originalVolume = sound:GetAttribute("OriginalVolume")
if typeof(originalVolume) == "number" then
sound.Volume = originalVolume
end
sound:Play()
sound:Stop()

if pluginSettings.Overrides.Sirens[sirenData.name] ~= nil then
if typeof(pluginSettings.Overrides.Sirens[sirenData.name]) == "string" then
lightbar:SetAttribute(pluginSettings.Overrides.Sirens[sirenData.name], 1)
lightbar:SetAttribute(pluginSettings.Overrides.Sirens[sirenData.name], 0)
elseif typeof(pluginSettings.Overrides.Sirens[sirenData.name]) == "table" then
local dependency = lightbar:GetAttribute(pluginSettings.Overrides.Sirens[sirenData.name][2])
if typeof(dependency) ~= "number" then
return
end
local dependencyPattern = pluginSettings.Overrides.Sirens[sirenData.name][3]
if dependencyPattern == nil then
dependencyPattern = 1
end
lightbar:SetAttribute(`should{pluginSettings.Overrides.Sirens[sirenData.name][1]}`, true)
lightbar:SetAttribute(
pluginSettings.Overrides.Sirens[sirenData.name][1],
if dependency > dependencyPattern - 1 then 1 else 0
)
lightbar:SetAttribute(`should{pluginSettings.Overrides.Sirens[sirenData.name][1]}`, false)
lightbar:SetAttribute(pluginSettings.Overrides.Sirens[sirenData.name][1], 0)
end
end

Expand All @@ -1054,7 +1032,7 @@ local function playSiren(name)
end
end

local function stopSiren(name)
local function playSiren(name)
if soundPart == nil then
return
end
Expand All @@ -1070,21 +1048,45 @@ local function stopSiren(name)
if sirenData.overrideOtherSounds then
if sirenData._type == "hold" then
for _, v in pairs(soundPart:GetChildren()) do
if v:IsA("Sound") and v ~= sound and v:GetAttribute("OriginalVolume") then
v.Volume = v:GetAttribute("OriginalVolume")
if v:IsA("Sound") and v ~= sound and sirensByName[v.Name] then
if v:GetAttribute("OriginalVolume") == nil then
v:SetAttribute("OriginalVolume", v.Volume)
end
v.Volume = 0
end
end
else
for _, v in pairs(soundPart:GetChildren()) do
if v:IsA("Sound") and v ~= sound and sirensByName[v.Name] then
stopSiren(v.Name)
end
end
end
end

sound:Stop()
local originalVolume = sound:GetAttribute("OriginalVolume")
if typeof(originalVolume) == "number" then
sound.Volume = originalVolume
end
sound:Play()

if pluginSettings.Overrides.Sirens[sirenData.name] ~= nil then
if typeof(pluginSettings.Overrides.Sirens[sirenData.name]) == "string" then
lightbar:SetAttribute(pluginSettings.Overrides.Sirens[sirenData.name], 0)
lightbar:SetAttribute(pluginSettings.Overrides.Sirens[sirenData.name], 1)
elseif typeof(pluginSettings.Overrides.Sirens[sirenData.name]) == "table" then
lightbar:SetAttribute(`should{pluginSettings.Overrides.Sirens[sirenData.name][1]}`, false)
lightbar:SetAttribute(pluginSettings.Overrides.Sirens[sirenData.name][1], 0)
local dependency = lightbar:GetAttribute(pluginSettings.Overrides.Sirens[sirenData.name][2])
if typeof(dependency) ~= "number" then
return
end
local dependencyPattern = pluginSettings.Overrides.Sirens[sirenData.name][3]
if dependencyPattern == nil then
dependencyPattern = 1
end
lightbar:SetAttribute(`should{pluginSettings.Overrides.Sirens[sirenData.name][1]}`, true)
lightbar:SetAttribute(
pluginSettings.Overrides.Sirens[sirenData.name][1],
if dependency > dependencyPattern - 1 then 1 else 0
)
end
end

Expand Down

0 comments on commit d36f0ba

Please sign in to comment.