diff --git a/src/server/main/Tags.lua b/src/server/main/Tags.lua index 6c2dafd..00e9188 100644 --- a/src/server/main/Tags.lua +++ b/src/server/main/Tags.lua @@ -60,13 +60,17 @@ export type LanternsTree = { [Enums.ElevatorValues]: Lanterns } +export type LightSwitchProperties = { + Switch: Instance?, + Lights: {Instance}?, + Prompt: ProximityPrompt?, + ClickSound: Sound?, + ColorActivated: Color3?, + ColorDeactivated: Color3? +} + export type LightSwitchTree = { - [string]: { - Switch: Instance?, - Lights: {Instance}?, - Prompt: ProximityPrompt?, - ClickSound: Sound? - } + [string]: LightSwitchProperties } export type InteractablesTree = { @@ -226,7 +230,9 @@ function Tags:__Interactables() local InteractObjectLocation = Split[3] if InteractHint == "Interact" then - Interactables.LightSwitches[InteractObjectLocation] = {} + if not Interactables.LightSwitches[InteractObjectLocation] then + Interactables.LightSwitches[InteractObjectLocation] = {} + end if InteractType == Enums.Interactables.LightSwitch then local ptr = Interactables.LightSwitches[InteractObjectLocation] @@ -246,6 +252,25 @@ function Tags:__Interactables() ClickSound.SoundId = Tags.LightSwitchActivateSoundId ClickSound.Parent = Switch + local ActivatedColor: Color3 = Switch:GetAttribute("Activated") + local DeactivatedColor: Color3 = Switch:GetAttribute("Deactivated") + if ActivatedColor then + ptr.ColorActivated = ActivatedColor + Switch:SetAttribute("Activated", nil) + + print(`LightSwitch: [{Switch}] "Activated" -> "{Switch:GetAttribute("Activated")}"`) + else + warn(`LightSwitch: [{Switch}] Light switch bounded, but it does not have the ActivatedColor attribute set`) + end + if DeactivatedColor then + ptr.ColorDeactivated = DeactivatedColor + Switch:SetAttribute("Deactivated", nil) + + print(`LightSwitch: [{Switch}] "Deactivated" -> "{Switch:GetAttribute("Deactivated")}"`) + else + warn(`LightSwitch: [{Switch}] Light switch bounded, but it does not have the DeactivatedColor attribute set`) + end + ptr.Switch = Switch ptr.Prompt = Prompt ptr.ClickSound = ClickSound @@ -253,7 +278,7 @@ function Tags:__Interactables() local ptr = Interactables.LightSwitches[InteractObjectLocation] if type(Inst) == "table" then - ptr.Lights = table.clone(Inst) + ptr.Lights = Inst else ptr.Lights = {} table.insert(ptr.Lights :: {Instance}, Inst) diff --git a/src/server/main/init.server.lua b/src/server/main/init.server.lua index 1c5d75c..4166d0b 100644 --- a/src/server/main/init.server.lua +++ b/src/server/main/init.server.lua @@ -12,6 +12,7 @@ local Otis1960_Module = require(Elevators:WaitForChild("Otis1960")) local Map = script:WaitForChild("Map") local LightSwitchesConstructor = require(Map:WaitForChild("LightSwitches")) +local PromptsConstructor = require(Map:WaitForChild("Prompts")) local TagsModule = require(script:WaitForChild("Tags")) local HideEditorEntities = require(script:WaitForChild("EditorEntities")) @@ -33,6 +34,40 @@ Workspace_Stuff() local Interactables = TagsConstructor:__Interactables() print("[DEBUG] Interactables=", Interactables) +--Temporary +for _, LightProperties in Interactables.LightSwitches do + if LightProperties.Prompt and LightProperties.Switch then + local Prompt = PromptsConstructor.constructor(LightProperties.Prompt, LightProperties.Switch) + local Enabled = false + + if LightProperties.ColorDeactivated and LightProperties.ColorActivated and LightProperties.Prompt and LightProperties.Lights then + Prompt:AddHookTriggered(function(_Player: Player) + Enabled = not Enabled + --*Light switch animation* + if LightProperties.ClickSound then + LightProperties.ClickSound:Play() + end + + for n: number = 1, #LightProperties.Lights do + local LightObj = LightProperties.Lights[n] + LightObj.PointLight.Enabled = Enabled + + if Enabled then + LightObj.Color = LightProperties.ColorActivated + LightObj.Material = Enum.Material.Neon + else + LightObj.Color = LightProperties.ColorDeactivated + LightObj.Material = Enum.Material.SmoothPlastic + end + end + end) + else + warn("failed") + end + end +end +-- + --local LightSwitches = LightSwitchesConstructor.constructor(Interactables.LightSwitches) --Start the elevators