diff --git a/sourcemap.json b/sourcemap.json index 7634aae..8f21efa 100644 --- a/sourcemap.json +++ b/sourcemap.json @@ -1 +1 @@ -{"name":"ElevatorGame","className":"DataModel","filePaths":["default.project.json"],"children":[{"name":"ReplicatedFirst","className":"ReplicatedFirst","children":[{"name":"intro","className":"LocalScript","filePaths":["src/load\\intro\\init.client.lua"],"children":[{"name":"IntroGui","className":"ModuleScript","filePaths":["src/load\\intro\\IntroGui.lua"]}]}]},{"name":"ReplicatedStorage","className":"ReplicatedStorage","children":[{"name":"Algebra","className":"ModuleScript","filePaths":["src/shared\\Algebra.lua"]},{"name":"Client","className":"Folder","children":[{"name":"Camera","className":"ModuleScript","filePaths":["src/shared\\Client\\Camera.lua"]},{"name":"KeyBinds","className":"ModuleScript","filePaths":["src/shared\\Client\\KeyBinds.lua"]}]},{"name":"Delta","className":"ModuleScript","filePaths":["src/shared\\Delta.lua"]},{"name":"Enums","className":"ModuleScript","filePaths":["src/shared\\Enums.lua"]},{"name":"Property","className":"ModuleScript","filePaths":["src/shared\\Property.lua"]},{"name":"Server","className":"Folder","children":[{"name":"holder","className":"ModuleScript","filePaths":["src/shared\\Server\\holder.lua"]}]},{"name":"Tween","className":"ModuleScript","filePaths":["src/shared\\Tween.lua"]}]},{"name":"ServerScriptService","className":"ServerScriptService","children":[{"name":"rapid/server","className":"Actor","children":[{"name":"main","className":"Script","filePaths":["src/server\\main\\init.server.lua"],"children":[{"name":"EditorEntities","className":"ModuleScript","filePaths":["src/server\\main\\EditorEntities.lua"]},{"name":"Elevators","className":"Folder","children":[{"name":"Buttons","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Buttons.lua"]},{"name":"Floors","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Floors.lua"]},{"name":"Lanterns","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Lanterns.lua"]},{"name":"Mover","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Mover.lua"]},{"name":"Otis1960","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\init.lua"],"children":[{"name":"Doors","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\Doors.lua"]},{"name":"Leveling","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\Leveling.lua"]},{"name":"MovingObjects","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\MovingObjects.lua"]}]},{"name":"TractionRopes","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\TractionRopes.lua"]}]},{"name":"Lighting","className":"ModuleScript","filePaths":["src/server\\main\\Lighting\\init.lua"]},{"name":"Map","className":"Folder","children":[{"name":"Interactions","className":"Folder","children":[{"name":"LightSwitches","className":"ModuleScript","filePaths":["src/server\\main\\Map\\Interactions\\LightSwitches.lua"]}]},{"name":"Prompts","className":"ModuleScript","filePaths":["src/server\\main\\Map\\Prompts.lua"]}]},{"name":"PlayerAdded","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\init.lua"],"children":[{"name":"Character","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\init.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\Actions.lua"]},{"name":"Flashlight","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\Flashlight.lua"]},{"name":"Shadows","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\Shadows.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\SpineKinematics.lua"]}]},{"name":"Users","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Users.lua"]}]},{"name":"StarterPlayer","className":"ModuleScript","filePaths":["src/server\\main\\StarterPlayer.lua"]},{"name":"Tags","className":"ModuleScript","filePaths":["src/server\\main\\Tags.lua"]},{"name":"Workspace","className":"ModuleScript","filePaths":["src/server\\main\\Workspace.lua"]}]}]}]},{"name":"StarterPlayer","className":"StarterPlayer","children":[{"name":"StarterPlayerScripts","className":"StarterPlayerScripts","children":[{"name":"rapid/client","className":"Folder","children":[{"name":"Player","className":"LocalScript","filePaths":["src/client\\init.client.lua"],"children":[{"name":"Character","className":"ModuleScript","filePaths":["src/client\\Character\\init.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/client\\Character\\Actions.lua"]},{"name":"Camera","className":"ModuleScript","filePaths":["src/client\\Character\\Camera\\init.lua"],"children":[{"name":"Bobbing","className":"ModuleScript","filePaths":["src/client\\Character\\Camera\\Bobbing.lua"]}]},{"name":"Humanoid","className":"ModuleScript","filePaths":["src/client\\Character\\Humanoid.lua"]},{"name":"HumanoidRootPart","className":"ModuleScript","filePaths":["src/client\\Character\\HumanoidRootPart.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/client\\Character\\SpineKinematics.lua"]}]},{"name":"CoreGuis","className":"ModuleScript","filePaths":["src/client\\CoreGuis.lua"]},{"name":"GuiService","className":"ModuleScript","filePaths":["src/client\\GuiService.lua"]},{"name":"Mouse","className":"ModuleScript","filePaths":["src/client\\Mouse.lua"]},{"name":"UI","className":"Folder","children":[{"name":"Crosshair","className":"ModuleScript","filePaths":["src/client\\UI\\Crosshair.lua"]},{"name":"Health","className":"ModuleScript","filePaths":["src/client\\UI\\Health.lua"]},{"name":"Vignette","className":"ModuleScript","filePaths":["src/client\\UI\\Vignette.lua"]}]}]}]}]}]}]} \ No newline at end of file +{"name":"ElevatorGame","className":"DataModel","filePaths":["default.project.json"],"children":[{"name":"ReplicatedFirst","className":"ReplicatedFirst","children":[{"name":"intro","className":"LocalScript","filePaths":["src/load\\intro\\init.client.lua"],"children":[{"name":"IntroGui","className":"ModuleScript","filePaths":["src/load\\intro\\IntroGui.lua"]}]}]},{"name":"ReplicatedStorage","className":"ReplicatedStorage","children":[{"name":"Algebra","className":"ModuleScript","filePaths":["src/shared\\Algebra.lua"]},{"name":"Client","className":"Folder","children":[{"name":"Camera","className":"ModuleScript","filePaths":["src/shared\\Client\\Camera.lua"]},{"name":"KeyBinds","className":"ModuleScript","filePaths":["src/shared\\Client\\KeyBinds.lua"]}]},{"name":"Delta","className":"ModuleScript","filePaths":["src/shared\\Delta.lua"]},{"name":"Enums","className":"ModuleScript","filePaths":["src/shared\\Enums.lua"]},{"name":"Property","className":"ModuleScript","filePaths":["src/shared\\Property.lua"]},{"name":"Server","className":"Folder","children":[{"name":"holder","className":"ModuleScript","filePaths":["src/shared\\Server\\holder.lua"]}]},{"name":"Tween","className":"ModuleScript","filePaths":["src/shared\\Tween.lua"]}]},{"name":"ServerScriptService","className":"ServerScriptService","children":[{"name":"rapid/server","className":"Actor","children":[{"name":"main","className":"Script","filePaths":["src/server\\main\\init.server.lua"],"children":[{"name":"Elevators","className":"Folder","children":[{"name":"Buttons","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Buttons.lua"]},{"name":"Floors","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Floors.lua"]},{"name":"Lanterns","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Lanterns.lua"]},{"name":"Mover","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Mover.lua"]},{"name":"Otis1960","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\init.lua"],"children":[{"name":"Doors","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\Doors.lua"]},{"name":"Leveling","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\Leveling.lua"]},{"name":"MovingObjects","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\MovingObjects.lua"]}]},{"name":"TractionRopes","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\TractionRopes.lua"]}]},{"name":"Lighting","className":"ModuleScript","filePaths":["src/server\\main\\Lighting\\init.lua"]},{"name":"Load","className":"Folder","children":[{"name":"EditorEntities","className":"ModuleScript","filePaths":["src/server\\main\\Load\\EditorEntities.lua"]},{"name":"StarterPlayer","className":"ModuleScript","filePaths":["src/server\\main\\Load\\StarterPlayer.lua"]},{"name":"Tags","className":"ModuleScript","filePaths":["src/server\\main\\Load\\Tags\\init.lua"],"children":[{"name":"Lights","className":"ModuleScript","filePaths":["src/server\\main\\Load\\Tags\\Lights.lua"]}]},{"name":"Workspace","className":"ModuleScript","filePaths":["src/server\\main\\Load\\Workspace.lua"]}]},{"name":"Map","className":"Folder","children":[{"name":"Interactions","className":"Folder","children":[{"name":"LightSwitches","className":"ModuleScript","filePaths":["src/server\\main\\Map\\Interactions\\LightSwitches.lua"]}]},{"name":"Prompts","className":"ModuleScript","filePaths":["src/server\\main\\Map\\Prompts.lua"]}]},{"name":"PlayerAdded","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\init.lua"],"children":[{"name":"Character","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\init.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\Actions.lua"]},{"name":"Flashlight","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\Flashlight.lua"]},{"name":"Shadows","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\Shadows.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Character\\SpineKinematics.lua"]}]},{"name":"Users","className":"ModuleScript","filePaths":["src/server\\main\\PlayerAdded\\Users.lua"]}]}]}]}]},{"name":"StarterPlayer","className":"StarterPlayer","children":[{"name":"StarterPlayerScripts","className":"StarterPlayerScripts","children":[{"name":"rapid/client","className":"Folder","children":[{"name":"Player","className":"LocalScript","filePaths":["src/client\\init.client.lua"],"children":[{"name":"Character","className":"ModuleScript","filePaths":["src/client\\Character\\init.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/client\\Character\\Actions.lua"]},{"name":"Camera","className":"ModuleScript","filePaths":["src/client\\Character\\Camera\\init.lua"],"children":[{"name":"Bobbing","className":"ModuleScript","filePaths":["src/client\\Character\\Camera\\Bobbing.lua"]}]},{"name":"Humanoid","className":"ModuleScript","filePaths":["src/client\\Character\\Humanoid.lua"]},{"name":"HumanoidRootPart","className":"ModuleScript","filePaths":["src/client\\Character\\HumanoidRootPart.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/client\\Character\\SpineKinematics.lua"]}]},{"name":"CoreGuis","className":"ModuleScript","filePaths":["src/client\\CoreGuis.lua"]},{"name":"GuiService","className":"ModuleScript","filePaths":["src/client\\GuiService.lua"]},{"name":"Mouse","className":"ModuleScript","filePaths":["src/client\\Mouse.lua"]},{"name":"UI","className":"Folder","children":[{"name":"Crosshair","className":"ModuleScript","filePaths":["src/client\\UI\\Crosshair.lua"]},{"name":"Health","className":"ModuleScript","filePaths":["src/client\\UI\\Health.lua"]},{"name":"Vignette","className":"ModuleScript","filePaths":["src/client\\UI\\Vignette.lua"]}]}]}]}]}]}]} \ No newline at end of file diff --git a/src/server/main/Elevators/Buttons.lua b/src/server/main/Elevators/Buttons.lua index 1dfc748..967fa2c 100644 --- a/src/server/main/Elevators/Buttons.lua +++ b/src/server/main/Elevators/Buttons.lua @@ -4,8 +4,9 @@ local ElevatorsDir = script.Parent local MainDir = ElevatorsDir.Parent +local LoadDir = MainDir:WaitForChild("Load") -local Tags = require(MainDir:WaitForChild("Tags")) +local Tags = require(LoadDir:WaitForChild("Tags")) local Storage = game:GetService("ReplicatedStorage") local Enums = require(Storage:WaitForChild("Enums")) @@ -26,7 +27,6 @@ type Impl_Constructor = { } & Impl_Static_Props type Impl_Static_Props = { - ButtonEnum: any, DefaultMaxActivationDistance: number, DefaultHoldDuration: number } @@ -159,6 +159,7 @@ function ButtonsModule:AestheticActivateButton(Button, ActivatedState, Activated Button.Position+=LookVec task.wait(.30) + if Glass then Glass.Position-=LookVec end diff --git a/src/server/main/Elevators/Lanterns.lua b/src/server/main/Elevators/Lanterns.lua index 7cbe883..1f97392 100644 --- a/src/server/main/Elevators/Lanterns.lua +++ b/src/server/main/Elevators/Lanterns.lua @@ -3,11 +3,12 @@ --!strict local ElevatorDir = script.Parent -local MainDir = ElevatorDir.Parent +local MainDir = ElevatorDir.Parent +local LoadDir = MainDir:WaitForChild("Load") local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage") local Tween = require(Storage:WaitForChild("Tween")) -local Tags = require(MainDir:WaitForChild("Tags")) +local Tags = require(LoadDir:WaitForChild("Tags")) local Enums = require(Storage:WaitForChild("Enums")) type rbxassetid = string @@ -88,7 +89,7 @@ function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern) if IsDirectionLantern then self.AudioChimeDirection:Play() else - Tween.Completed:Connect(function() + Tween.Completed:Once(function() self.AudioChimeLanding:Play() end) end diff --git a/src/server/main/Elevators/Otis1960/init.lua b/src/server/main/Elevators/Otis1960/init.lua index 8fce975..37605a9 100644 --- a/src/server/main/Elevators/Otis1960/init.lua +++ b/src/server/main/Elevators/Otis1960/init.lua @@ -4,6 +4,7 @@ local Elevators = script.Parent local MainDir = Elevators.Parent +local LoadDir = MainDir:WaitForChild("Load") local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage") local RS: RunService = game:GetService("RunService") @@ -20,7 +21,7 @@ local TractionRopes = require(Elevators:WaitForChild("TractionRopes")) local Lanterns = require(Elevators:WaitForChild("Lanterns")) local PromptModule = require(MainDir:WaitForChild("Map"):WaitForChild("Prompts")) -local Tags = require(MainDir:WaitForChild("Tags")) +local Tags = require(LoadDir:WaitForChild("Tags")) type rbxassetid = string diff --git a/src/server/main/EditorEntities.lua b/src/server/main/Load/EditorEntities.lua similarity index 100% rename from src/server/main/EditorEntities.lua rename to src/server/main/Load/EditorEntities.lua diff --git a/src/server/main/StarterPlayer.lua b/src/server/main/Load/StarterPlayer.lua similarity index 100% rename from src/server/main/StarterPlayer.lua rename to src/server/main/Load/StarterPlayer.lua diff --git a/src/server/main/Load/Tags/Lights.lua b/src/server/main/Load/Tags/Lights.lua new file mode 100644 index 0000000..8433a82 --- /dev/null +++ b/src/server/main/Load/Tags/Lights.lua @@ -0,0 +1,108 @@ +--!optimize 2 +--!native +--!strict + +type rbxassetid = string + +type LightProperties = { + MaxLightSwitchActivationDistance: number, + MaxLightSwitchHoldDuration: number, + LightSwitchActivateSoundId: rbxassetid +} + +type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor)) +type Impl_Constructor = { + __index: Impl_Constructor, + constructor: Constructor_Fun, + --Class functions + Functionality: (self: ClassConstructor, DefinedProperties: LightProperties?) -> LightAddresses +} & Impl_Static_Props + +type Impl_Static_Props = { + StaticMaxLightSwitchActivationDistance: number, + StaticMaxLightSwitchHoldDuration: number, + StaticLightSwitchActivateSoundId: rbxassetid +} + +type Constructor_Fun = (Switch: BasePart) -> ClassConstructor +type Constructor_Return_Props = { + Switch: BasePart +} + +export type LightAddresses = { + Attachment: Attachment?, + Prompt: ProximityPrompt?, + ClickSound: Sound?, + ColorActivated: Color3?, + ColorDeactivated: Color3?, + ActivatedMaterial: string?, + DeactivatedMaterial: string?, + Enabled: boolean? +} + +local Lights = {} :: Impl_Constructor +Lights.__index = Lights + +Lights.StaticMaxLightSwitchActivationDistance = 3 +Lights.StaticMaxLightSwitchHoldDuration = .15 +Lights.StaticLightSwitchActivateSoundId = "rbxassetid://156286438" + +function Lights.constructor(Switch) + return setmetatable({ + Switch = Switch + }, Lights) +end + +function Lights:Functionality(DefinedProperties) + local LightAddresses = {} :: LightAddresses + + local LightProperties = { + MaxLightSwitchActivationDistance = Lights.StaticMaxLightSwitchActivationDistance, + MaxLightSwitchHoldDuration = Lights.StaticMaxLightSwitchHoldDuration, + LightSwitchActivateSoundId = Lights.StaticLightSwitchActivateSoundId, + } + if DefinedProperties then + if DefinedProperties.MaxLightSwitchActivationDistance then + LightProperties.MaxLightSwitchActivationDistance = DefinedProperties.MaxLightSwitchActivationDistance + end + if DefinedProperties.MaxLightSwitchHoldDuration then + LightProperties.MaxLightSwitchHoldDuration = DefinedProperties.MaxLightSwitchHoldDuration + end + if DefinedProperties.LightSwitchActivateSoundId then + LightProperties.LightSwitchActivateSoundId = DefinedProperties.LightSwitchActivateSoundId + end + end + + local Attachment = Instance.new("Attachment") :: Attachment + Attachment.Parent = self.Switch + + local Prompt = Instance.new("ProximityPrompt") :: ProximityPrompt + Prompt.ObjectText = "Light" + Prompt.MaxActivationDistance = LightProperties.MaxLightSwitchActivationDistance + Prompt.HoldDuration = LightProperties.MaxLightSwitchHoldDuration + Prompt.Parent = Attachment + + local ClickSound = Instance.new("Sound") :: Sound + ClickSound.Volume = .1 + ClickSound.SoundId = LightProperties.LightSwitchActivateSoundId + ClickSound.Parent = self.Switch + + LightAddresses.ColorActivated = self.Switch:GetAttribute("Activated") + LightAddresses.ColorDeactivated = self.Switch:GetAttribute("Deactivated") + LightAddresses.ActivatedMaterial = self.Switch:GetAttribute("ActivatedMaterial") + LightAddresses.DeactivatedMaterial = self.Switch:GetAttribute("DeactivatedMaterial") + LightAddresses.Enabled = self.Switch:GetAttribute("Enabled") + LightAddresses.Attachment = Attachment + LightAddresses.Prompt = Prompt + LightAddresses.ClickSound = ClickSound + + self.Switch:SetAttribute("Activated", nil) + self.Switch:SetAttribute("Deactivated", nil) + self.Switch:SetAttribute("Enabled", nil) + self.Switch:SetAttribute("ActivatedMaterial", nil) + self.Switch:SetAttribute("DeactivatedMaterial", nil) + + return LightAddresses +end + +return Lights \ No newline at end of file diff --git a/src/server/main/Tags.lua b/src/server/main/Load/Tags/init.lua similarity index 76% rename from src/server/main/Tags.lua rename to src/server/main/Load/Tags/init.lua index c6bb3b5..957cb3d 100644 --- a/src/server/main/Tags.lua +++ b/src/server/main/Load/Tags/init.lua @@ -4,10 +4,11 @@ local CS = game:GetService("CollectionService") local Storage = game:GetService("ReplicatedStorage") + +local Lights = require(script:WaitForChild("Lights")) local Enums = require(Storage:WaitForChild("Enums")) type Error = never -type rbxassetid = string type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor)) type Impl_Constructor = { @@ -22,10 +23,6 @@ type Impl_Constructor = { } & Impl_Static_Props type Impl_Static_Props = { - MaxLightSwitchActivationDistance: number, - MaxLightSwitchHoldDuration: number, - LightSwitchActivateSoundId: rbxassetid, - Decoders: { CarTag: (FloorTag: string) -> number? } @@ -68,9 +65,24 @@ export type LightSwitchProperties = { ClickSound: Sound?, ColorActivated: Color3?, ColorDeactivated: Color3?, + ActivatedMaterial: string?, + DeactivatedMaterial: string?, Enabled: boolean? } +export type LightSwitchPropertiesSafe = { + Switch: Instance, + Lights: {Instance}, + LightSources: {Instance}, + Prompt: ProximityPrompt, + ClickSound: Sound, + ColorActivated: Color3, + ColorDeactivated: Color3, + ActivatedMaterial: string, + DeactivatedMaterial: string, + Enabled: boolean +} + export type LightSwitchTree = { [string]: LightSwitchProperties } @@ -92,17 +104,16 @@ export type ButtonProperties = { Attachment: Attachment? } -export type TagProduct = Instance | {Instance} -export type ExportedTags = {[string]: TagProduct} +export type ExportedTags = { + [string]: TagProduct +} + +export type TagProduct = Instance | {Instance} export type TagsConstructor = ClassConstructor local Tags = {} :: Impl_Constructor Tags.__index = Tags -Tags.MaxLightSwitchActivationDistance = 3 -Tags.MaxLightSwitchHoldDuration = .15 -Tags.LightSwitchActivateSoundId = "rbxassetid://156286438" - Tags.Decoders = { CarTag = function(FloorTag) local Match = FloorTag:match('%d+$') @@ -244,45 +255,18 @@ function Tags:__Interactables() warn(`2 or more light switch tags were present under the same name, using the first index. "{TagName}". This feature is not implemented yet`) end - local Attachment = Instance.new("Attachment") :: Attachment - Attachment.Parent = Switch - local Prompt = Instance.new("ProximityPrompt") :: ProximityPrompt - Prompt.ObjectText = "Light" - Prompt.MaxActivationDistance = Tags.MaxLightSwitchActivationDistance - Prompt.HoldDuration = Tags.MaxLightSwitchHoldDuration - Prompt.Parent = Attachment - local ClickSound = Instance.new("Sound") :: Sound - ClickSound.Volume = .1 - ClickSound.SoundId = Tags.LightSwitchActivateSoundId - ClickSound.Parent = Switch + local LightConstructor = Lights.constructor(Switch) + local LightAddress = LightConstructor:Functionality() - local ActivatedColor: Color3 = Switch:GetAttribute("Activated") - local DeactivatedColor: Color3 = Switch:GetAttribute("Deactivated") - local Enabled: boolean = Switch:GetAttribute("Enabled") + ptr.Switch = Switch + ptr.Prompt = LightAddress.Prompt + ptr.Enabled = LightAddress.Enabled + ptr.ClickSound = LightAddress.ClickSound + ptr.ColorActivated = LightAddress.ColorActivated + ptr.ColorDeactivated = LightAddress.ColorDeactivated + ptr.ActivatedMaterial = LightAddress.ActivatedMaterial + ptr.DeactivatedMaterial = LightAddress.DeactivatedMaterial - if ActivatedColor then - ptr.ColorActivated = ActivatedColor - - 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 - - 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 - ptr.Enabled = Enabled - - Switch:SetAttribute("Activated", nil) - Switch:SetAttribute("Deactivated", nil) - Switch:SetAttribute("Enabled", nil) elseif InteractType == Enums.InteractType.Light then if type(Inst) == "table" then ptr.Lights = Inst @@ -290,6 +274,7 @@ function Tags:__Interactables() ptr.Lights = {} table.insert(ptr.Lights :: {Instance}, Inst) end + elseif InteractType == Enums.InteractType.LightSource then ptr.LightSources = (type(Inst) == "table" and Inst or {Inst :: Instance}) :: {Instance} end diff --git a/src/server/main/Workspace.lua b/src/server/main/Load/Workspace.lua similarity index 100% rename from src/server/main/Workspace.lua rename to src/server/main/Load/Workspace.lua diff --git a/src/server/main/Map/Interactions/LightSwitches.lua b/src/server/main/Map/Interactions/LightSwitches.lua index b342862..e127f99 100644 --- a/src/server/main/Map/Interactions/LightSwitches.lua +++ b/src/server/main/Map/Interactions/LightSwitches.lua @@ -2,12 +2,13 @@ --!native --!strict -local MapDir = script.Parent.Parent +local MapDir = script.Parent.Parent local MainDir = MapDir.Parent +local LoadDir = MainDir:WaitForChild("Load") local Storage = game:GetService("ReplicatedStorage") -local TagService = require(MainDir:WaitForChild("Tags")) +local TagService = require(LoadDir:WaitForChild("Tags")) local TweenModule = require(Storage:WaitForChild("Tween")) local PromptsConstructor = require(MapDir:WaitForChild("Prompts")) @@ -31,7 +32,8 @@ type Constructor_Return_Props = { LightSwitches: TagService.LightSwitchTree } -export type LightProperties = TagService.LightSwitchProperties +export type LightProperties = TagService.LightSwitchProperties +export type LightPropertiesSafe = TagService.LightSwitchPropertiesSafe local Lights = {} :: Impl_Constructor Lights.__index = Lights @@ -44,50 +46,78 @@ function Lights.constructor(LightSwitches) }, Lights) end -local function ToggleSwitchLight(EnabledState: boolean, LightObject: BasePart, LightProperties: LightProperties) - local Light = LightObject:FindFirstChildWhichIsA("PointLight", true) or LightObject:FindFirstChildWhichIsA("SpotLight", true) - - if Light then - Light.Enabled = EnabledState - end - if EnabledState then - if LightProperties.ColorActivated then - LightObject.Color = LightProperties.ColorActivated - LightObject.Material = Enum.Material.Neon - end - else - if LightProperties.ColorDeactivated then - LightObject.Color = LightProperties.ColorDeactivated - LightObject.Material = Enum.Material.SmoothPlastic - end - end +local EnumMaterials = Enum.Material:GetEnumItems() +--Convert it all to string values, couldnt figure out any hacks to make it a true one liner +for k: number, v: Enum.Material in EnumMaterials do + EnumMaterials[k] = v.Name end -local function SwitchState() - +local function ToggleSwitchLight(EnabledState: boolean, LightProperties: LightPropertiesSafe) + for n: number = 1, #LightProperties.LightSources do + (LightProperties.LightSources[n] :: Light).Enabled = EnabledState + end + + for n: number = 1, #LightProperties.Lights do + local LightObject = LightProperties.Lights[n] :: BasePart + + if EnabledState then + local ActivatedMaterial = table.find(EnumMaterials, LightProperties.ActivatedMaterial) or 1 --Only doing this because it is runtime safe + + LightObject.Color = LightProperties.ColorActivated + LightObject.Material = EnumMaterials[ActivatedMaterial] + else + local DeactivatedMaterial = table.find(EnumMaterials, LightProperties.DeactivatedMaterial) or 1 --Only doing this because it is runtime safe + + LightObject.Color = LightProperties.ColorDeactivated + LightObject.Material = EnumMaterials[DeactivatedMaterial] + end + end end local LightSwitchTween = TweenModule.constructor(TweenInfo.new(Lights.SwitchAnimationTime, Enum.EasingStyle.Linear)) local function SwitchAnimation(EnabledState: boolean, LightProperties: LightProperties) - local Switch = LightProperties.Switch + local Switch = LightProperties.Switch :: BasePart + local Prompt = LightProperties.Prompt :: ProximityPrompt if Switch then if EnabledState then - LightSwitchTween:Start(Switch, { + local Tween = LightSwitchTween:Start(Switch, { CFrame = CFrame.new(Switch.Position)*CFrame.Angles(0,math.rad(90),0)+Vector3.new(0,.15,0) }) + Tween.Completed:Once(function() + ToggleSwitchLight(EnabledState, LightProperties :: LightPropertiesSafe) + Prompt.ActionText = "Toggle Off" + end) else - LightSwitchTween:Start(Switch, { + local Tween = LightSwitchTween:Start(Switch, { CFrame = CFrame.new(Switch.Position)*CFrame.Angles(0,math.rad(90),math.rad(70))-Vector3.new(0,.15,0) }) + Tween.Completed:Once(function() + ToggleSwitchLight(EnabledState, LightProperties :: LightPropertiesSafe) + Prompt.ActionText = "Toggle On" + end) end end end +local function ToggleSwitch(EnabledState: boolean, LightProperties: LightProperties, Sounds: boolean) + SwitchAnimation(EnabledState, LightProperties) + + if Sounds and LightProperties.ClickSound then + LightProperties.ClickSound:Play() + end +end + --[[ Guide for lights with toggable switches: - TODO + ------ + Switch ->lever<- tag: "Interact_LightSwitch_ALIASNAME" + Switch ->level<- attributes: "Activated" (Color3), "Deactivated" (Color3), "Enabled" (boolean) + ------ + Light Bulb tag: "Interact_Light_ALIASNAME" + ------ + Light source tag: "Interact_LightSource_ALIASNAME" ]] function Lights:Init() for _, LightProperties in self.LightSwitches do @@ -95,28 +125,29 @@ function Lights:Init() local Prompt = PromptsConstructor.constructor(LightProperties.Prompt, LightProperties.Switch) local EnabledState = false - if LightProperties.ColorDeactivated and LightProperties.ColorActivated and LightProperties.Prompt and LightProperties.Lights then + --These must be available for Lights to work + if LightProperties.ColorDeactivated and + LightProperties.ColorActivated and + LightProperties.Prompt and + LightProperties.Lights and + LightProperties.LightSources and + LightProperties.ActivatedMaterial and + LightProperties.DeactivatedMaterial then if LightProperties.Enabled then + EnabledState = true LightProperties.Prompt.ActionText = "Toggle Off" - else LightProperties.Prompt.ActionText = "Toggle On" - end + ToggleSwitch(EnabledState, LightProperties :: LightPropertiesSafe, false) + Prompt:AddHookTriggered(function(_Player: Player) EnabledState = not EnabledState - - SwitchAnimation(EnabledState, LightProperties) - if LightProperties.ClickSound then - LightProperties.ClickSound:Play() - end - for n: number = 1, #LightProperties.Lights do - ToggleSwitchLight(EnabledState, LightProperties.Lights[n], LightProperties) - end + ToggleSwitch(EnabledState, LightProperties :: LightPropertiesSafe, true) end) else - warn(`LightSwitch hook failed, a required field is missing:\n-----\nColorDeactivated = {LightProperties.ColorDeactivated}\nColorActivated = {LightProperties.ColorActivated}\nPrompt = {LightProperties.Prompt}\nLights = {LightProperties.Lights}\n-----`) + warn(`LightSwitch hook failed, a required field is missing:\n-----\nColorDeactivated = {LightProperties.ColorDeactivated}\nColorActivated = {LightProperties.ColorActivated}\nPrompt = {LightProperties.Prompt}\nLights = {LightProperties.Lights}\nDeactivatedMaterial = {LightProperties.DeactivatedMaterial}\nActivatedMaterial = {LightProperties.ActivatedMaterial}\n-----`) end end end diff --git a/src/server/main/Map/Prompts.lua b/src/server/main/Map/Prompts.lua index 991c0b4..987a021 100644 --- a/src/server/main/Map/Prompts.lua +++ b/src/server/main/Map/Prompts.lua @@ -2,8 +2,8 @@ --!native --!strict -type PromptCallback = (Player: Player) -> () type HumanoidRootPart = BasePart +type PromptCallback = (Player: Player, Root: HumanoidRootPart) -> () type PromptSignal = RBXScriptSignal type PromptSignalName = "Triggered" | "TriggerEnded" @@ -48,11 +48,11 @@ end local function DistanceCheck(self: ClassConstructor, Player: Player) local PlayerCharacter = Player.Character - local Root = PlayerCharacter and PlayerCharacter:FindFirstChild("HumanoidRootPart") :: HumanoidRootPart? + local Root = PlayerCharacter and PlayerCharacter:FindFirstChild("HumanoidRootPart") :: HumanoidRootPart? if Root then if (Root.Position-(self.Instance :: BasePart).Position).Magnitude<=self.Prompt.MaxActivationDistance+1 then - (self.__TriggeredCallback :: PromptCallback)(Player) + (self.__TriggeredCallback :: PromptCallback)(Player, Root) else warn(`{Player.Name}, {Player.UserId} activated a prompt without being in range of MaxActivationDistance.`) end diff --git a/src/server/main/init.server.lua b/src/server/main/init.server.lua index 08a1dcf..b764318 100644 --- a/src/server/main/init.server.lua +++ b/src/server/main/init.server.lua @@ -6,19 +6,23 @@ local ShowEditorEntities = true local Storage = game:GetService("ReplicatedStorage") -local _PlayerAdded = require(script:WaitForChild("PlayerAdded")) -local TagsModule = require(script:WaitForChild("Tags")) -local HideEditorEntities = require(script:WaitForChild("EditorEntities")) -local Lighting_Stuff = require(script:WaitForChild("Lighting")) -local Workspace_Stuff = require(script:WaitForChild("Workspace")) -local StarterPlayer_Stuff = require(script:WaitForChild("StarterPlayer")) +local _PlayerAdded = require(script:WaitForChild("PlayerAdded")) +local Lighting_Stuff = require(script:WaitForChild("Lighting")) -local Elevators = script:WaitForChild("Elevators") -local Maps = script:WaitForChild("Map") -local Interactions = Maps:WaitForChild("Interactions") -local Enums = require(Storage:WaitForChild("Enums")) -local LightSwitches = require(Interactions:WaitForChild("LightSwitches")) -local Otis1960_Module = require(Elevators:WaitForChild("Otis1960")) +local Load = script:WaitForChild("Load") +local TagsModule = require(Load:WaitForChild("Tags")) +local HideEditorEntities = require(Load:WaitForChild("EditorEntities")) +local Workspace_Stuff = require(Load:WaitForChild("Workspace")) +local StarterPlayer_Stuff = require(Load:WaitForChild("StarterPlayer")) + +local Elevators = script:WaitForChild("Elevators") +local Maps = script:WaitForChild("Map") + +local Interactions = Maps:WaitForChild("Interactions") +local LightSwitches = require(Interactions:WaitForChild("LightSwitches")) +local Otis1960_Module = require(Elevators:WaitForChild("Otis1960")) + +local Enums = require(Storage:WaitForChild("Enums")) local TagsConstructor = TagsModule.constructor() print("[DEBUG] Tags=", TagsConstructor.__export)