Haughton elevator and work on the buttons and new structure

This commit is contained in:
2024-08-20 16:29:06 -04:00
parent 7bae24c918
commit 8af537f9de
13 changed files with 419 additions and 259 deletions

View File

@@ -6,103 +6,45 @@ local ParentDir = script.Parent
local ElevatorsDir = ParentDir.Parent
local MainDir = ElevatorsDir.Parent
local StorageService = game:GetService("ReplicatedStorage")
local Enums = require(StorageService:WaitForChild("Enums"))
local InitElevator = require(ElevatorsDir:WaitForChild("System"))
local Config = require(script:WaitForChild("Config"))
local Buttons = require(script:WaitForChild("Buttons"))
local Leveling = require(script:WaitForChild("Leveling"))
local MovingObjects = require(script:WaitForChild("MovingObjects"))
local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags"))
local function ElectricalFlash(Flash: PointLight)
Flash.Enabled = true
task.delay(.07, function()
Flash.Enabled = false
end)
end
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
local ElevatorModel = TagsConstructor:Request("Elevator_Haughton") :: Model
local ElevatorBoxModel = ElevatorModel:WaitForChild("Mover") :: BasePart
local MagnetCog_Row3 = TagsConstructor:Request("Haughton_MagnetCog_Row3") :: BasePart
local Cog2_Row3 = TagsConstructor:Request("Haughton_Cog2_Row3") :: BasePart
local Row3_CounterWeight = TagsConstructor:Request("Haughton_Row3_CounterWeight") :: BasePart
local Row3_RelayDown = TagsConstructor:Request("Haughton_Row3_Relay_Down") :: BasePart
local Haughton_Relay_Close = TagsConstructor:Request("Haughton_Relay_Close") :: Sound
local Haughton_Relay_Open = TagsConstructor:Request("Haughton_Relay_Open") :: Sound
local Haughton_Relay_FullOpen = TagsConstructor:Request("Haughton_Relay_FullOpen") :: Sound
local MagnetCog_Row1 = TagsConstructor:Request("Haughton_MagnetCog_Row1") :: BasePart
local Cog2_Row1 = TagsConstructor:Request("Haughton_Cog2_Row1") :: BasePart
local Row1_CounterWeight = TagsConstructor:Request("Haughton_Row1_CounterWeight") :: BasePart
local Row1_Relays = TagsConstructor:Request("Haughton_Row1_Relays") :: BasePart
local Row1_Flash = TagsConstructor:Request("Haughton_Row1_Flash") :: PointLight
local MagnetCog_Row2 = TagsConstructor:Request("Haughton_MagnetCog_Row2") :: BasePart
local Cog2_Row2 = TagsConstructor:Request("Haughton_Cog2_Row2") :: BasePart
local Row2_CounterWeight = TagsConstructor:Request("Haughton_Row2_CounterWeight") :: BasePart
local Row2_Relays = TagsConstructor:Request("Haughton_Row2_Relays") :: BasePart
local Row2_Flash = TagsConstructor:Request("Haughton_Row2_Flash") :: PointLight
local MagnetCog_Row4 = TagsConstructor:Request("Haughton_MagnetCog_Row4") :: BasePart
local Cog2_Row4 = TagsConstructor:Request("Haughton_Cog2_Row4") :: BasePart
local Row4_CounterWeight = TagsConstructor:Request("Haughton_Row4_CounterWeight") :: BasePart
local Row4_Relays = TagsConstructor:Request("Haughton_Row4_Relays") :: BasePart
local Row4_Flash = TagsConstructor:Request("Haughton_Row4_Flash") :: PointLight
--sneaky Machine room stuff hehe
local PulleyWheel = TagsConstructor:Request("Haughton_PulleyWheel") :: BasePart
local Elevator = InitElevator.constructor(ElevatorBoxModel, Config, Leveling)
local MovingObjectsConstructor = MovingObjects.constructor()
task.wait(3)
task.spawn(function()
Elevator:RequestLevelAsync(2, Enums.ElevatorCallDirection.Down)
end)
local MovingObjectsConstructor = MovingObjects.constructor(TagsConstructor)
local ButtonsConstructor = Buttons.constructor(Config.Name, ButtonTags, Elevator.Attributes.CurrentFloor)
Elevator.Events.Traveling:Connect(function(_DeltaTime: number, CabPosition: Vector3)
local CabVelocity = ElevatorBoxModel:GetVelocityAtPosition(CabPosition)
local Pulley_Y_Direction = (Elevator.Attributes.TravelingUpwards.Value and -CabVelocity.Y or CabVelocity.Y)
local TravelingUpwards = Elevator.Attributes.TravelingUpwards.Value
PulleyWheel.CFrame*=CFrame.Angles(math.rad(Pulley_Y_Direction/2),0,0)
MovingObjectsConstructor:RotatePulleyWheel(TravelingUpwards, CabVelocity.Y)
MovingObjectsConstructor:RotateRotodials(CabVelocity.Y)
end)
Elevator.Events.Progression:Connect(function(previousFloor: number, CurrentFloor: number, NextFloor: number)
warn("previousFloor=",previousFloor,"CurrentFloor=", CurrentFloor, "NextFloor=",NextFloor)
end)
Elevator.Events.Leveling:Connect(function()
Haughton_Relay_Open:Play()
MovingObjectsConstructor:RotateRelayCogs(false, false, false, MagnetCog_Row2, Cog2_Row2, Row2_CounterWeight, Row2_Relays)
ElectricalFlash(Row2_Flash)
MovingObjectsConstructor:RotateRelayCogs(true, true, false, MagnetCog_Row1, Cog2_Row1, Row1_CounterWeight, Row1_Relays)
task.wait(.1)
MovingObjectsConstructor:RotateRelayCogs(false, true, false, MagnetCog_Row4, Cog2_Row4, Row4_CounterWeight, Row4_Relays)
ElectricalFlash(Row4_Flash)
MovingObjectsConstructor:RotateRelayCogs2Async()
end)
Elevator.Events.Parked:Connect(function()
MovingObjectsConstructor:RotateRelayCogs(false, true, false, MagnetCog_Row1, Cog2_Row1, Row1_CounterWeight, Row1_Relays)
ElectricalFlash(Row1_Flash)
MovingObjectsConstructor:RotateRelayCogs(false, false, false, MagnetCog_Row3, Cog2_Row3, Row3_CounterWeight, Row3_RelayDown)
Haughton_Relay_FullOpen:Play()
MovingObjectsConstructor:RotateRelayCogs3()
end)
Haughton_Relay_Close:Play()
MovingObjectsConstructor:RotateRelayCogs(true, false, false, MagnetCog_Row3, Cog2_Row3, Row3_CounterWeight, Row3_RelayDown)
task.wait(.30)
MovingObjectsConstructor:RotateRelayCogs(true, false, false, MagnetCog_Row2, Cog2_Row2, Row2_CounterWeight, Row2_Relays).Completed:Once(function()
MovingObjectsConstructor:RotateRelayCogs(true, true, true, MagnetCog_Row1, Cog2_Row1, Row1_CounterWeight, Row1_Relays)
task.wait(.35)
MovingObjectsConstructor:RotateRelayCogs(false, true, true, MagnetCog_Row1, Cog2_Row1, Row1_CounterWeight, Row1_Relays)
end)
task.wait(.30)
MovingObjectsConstructor:RotateRelayCogs(true, true, false, MagnetCog_Row4, Cog2_Row4, Row4_CounterWeight, Row4_Relays)
ButtonsConstructor:Hook()
Elevator:StartTraveling()
-- MovingObjectsConstructor:RotateRelayCogs1Async()
-- Elevator:StartTraveling()
end