mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
working light switch, needs modularized
This commit is contained in:
@@ -60,13 +60,17 @@ export type LanternsTree = {
|
|||||||
[Enums.ElevatorValues]: Lanterns
|
[Enums.ElevatorValues]: Lanterns
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type LightSwitchProperties = {
|
||||||
|
Switch: Instance?,
|
||||||
|
Lights: {Instance}?,
|
||||||
|
Prompt: ProximityPrompt?,
|
||||||
|
ClickSound: Sound?,
|
||||||
|
ColorActivated: Color3?,
|
||||||
|
ColorDeactivated: Color3?
|
||||||
|
}
|
||||||
|
|
||||||
export type LightSwitchTree = {
|
export type LightSwitchTree = {
|
||||||
[string]: {
|
[string]: LightSwitchProperties
|
||||||
Switch: Instance?,
|
|
||||||
Lights: {Instance}?,
|
|
||||||
Prompt: ProximityPrompt?,
|
|
||||||
ClickSound: Sound?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type InteractablesTree = {
|
export type InteractablesTree = {
|
||||||
@@ -226,7 +230,9 @@ function Tags:__Interactables()
|
|||||||
local InteractObjectLocation = Split[3]
|
local InteractObjectLocation = Split[3]
|
||||||
|
|
||||||
if InteractHint == "Interact" then
|
if InteractHint == "Interact" then
|
||||||
Interactables.LightSwitches[InteractObjectLocation] = {}
|
if not Interactables.LightSwitches[InteractObjectLocation] then
|
||||||
|
Interactables.LightSwitches[InteractObjectLocation] = {}
|
||||||
|
end
|
||||||
|
|
||||||
if InteractType == Enums.Interactables.LightSwitch then
|
if InteractType == Enums.Interactables.LightSwitch then
|
||||||
local ptr = Interactables.LightSwitches[InteractObjectLocation]
|
local ptr = Interactables.LightSwitches[InteractObjectLocation]
|
||||||
@@ -246,6 +252,25 @@ function Tags:__Interactables()
|
|||||||
ClickSound.SoundId = Tags.LightSwitchActivateSoundId
|
ClickSound.SoundId = Tags.LightSwitchActivateSoundId
|
||||||
ClickSound.Parent = Switch
|
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.Switch = Switch
|
||||||
ptr.Prompt = Prompt
|
ptr.Prompt = Prompt
|
||||||
ptr.ClickSound = ClickSound
|
ptr.ClickSound = ClickSound
|
||||||
@@ -253,7 +278,7 @@ function Tags:__Interactables()
|
|||||||
local ptr = Interactables.LightSwitches[InteractObjectLocation]
|
local ptr = Interactables.LightSwitches[InteractObjectLocation]
|
||||||
|
|
||||||
if type(Inst) == "table" then
|
if type(Inst) == "table" then
|
||||||
ptr.Lights = table.clone(Inst)
|
ptr.Lights = Inst
|
||||||
else
|
else
|
||||||
ptr.Lights = {}
|
ptr.Lights = {}
|
||||||
table.insert(ptr.Lights :: {Instance}, Inst)
|
table.insert(ptr.Lights :: {Instance}, Inst)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ local Otis1960_Module = require(Elevators:WaitForChild("Otis1960"))
|
|||||||
|
|
||||||
local Map = script:WaitForChild("Map")
|
local Map = script:WaitForChild("Map")
|
||||||
local LightSwitchesConstructor = require(Map:WaitForChild("LightSwitches"))
|
local LightSwitchesConstructor = require(Map:WaitForChild("LightSwitches"))
|
||||||
|
local PromptsConstructor = require(Map:WaitForChild("Prompts"))
|
||||||
|
|
||||||
local TagsModule = require(script:WaitForChild("Tags"))
|
local TagsModule = require(script:WaitForChild("Tags"))
|
||||||
local HideEditorEntities = require(script:WaitForChild("EditorEntities"))
|
local HideEditorEntities = require(script:WaitForChild("EditorEntities"))
|
||||||
@@ -33,6 +34,40 @@ Workspace_Stuff()
|
|||||||
local Interactables = TagsConstructor:__Interactables()
|
local Interactables = TagsConstructor:__Interactables()
|
||||||
print("[DEBUG] Interactables=", 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)
|
--local LightSwitches = LightSwitchesConstructor.constructor(Interactables.LightSwitches)
|
||||||
|
|
||||||
--Start the elevators
|
--Start the elevators
|
||||||
|
|||||||
Reference in New Issue
Block a user