new elevator structure and working Haughton relays!

This commit is contained in:
2024-08-15 01:34:57 -04:00
parent 9d081a2084
commit 7bae24c918
25 changed files with 348 additions and 171 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,38 +0,0 @@
--!optimize 2
--!native
--!strict
local ParentDir = script.Parent
local ElevatorDir = ParentDir.Parent
local MainDir = ElevatorDir.Parent
local StorageService = game:GetService("ReplicatedStorage")
local InitElevator = require(ParentDir)
local TagsModule = require(MainDir:WaitForChild("Load"):WaitForChild("Tags"))
local Enums = require(StorageService:WaitForChild("Enums"))
local ElevatorConfigurationTable = require(ElevatorDir:WaitForChild("Configs"))
local FloorLevelingPositions = require(ElevatorDir:WaitForChild("Leveling"))
local TractionRopes = require(ElevatorDir:WaitForChild("TractionRopes"))
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
local ElevatorBoxModel = TagsConstructor:Request("ElevatorMover_Haughton") :: BasePart
local RopeTags = TagsConstructor:Request("ElevatorRope_Haughton") :: {Instance}
local Elevator = InitElevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable.HaughtonConfiguration, FloorLevelingPositions.HaughtonLeveling)
local TractionRopesConstructor = TractionRopes.constructor(RopeTags, ElevatorBoxModel, FloorLevelingPositions.HaughtonLeveling)
task.wait(3)
task.spawn(function()
Elevator:RequestLevelAsync(2, Enums.ElevatorCallDirection.Down)
end)
Elevator.Events.Traveling:Connect(function(deltaTime: number, cabPosition: Vector3)
--TractionRopesConstructor:Move(10, cabPosition)
warn("This is impossible to be firing during parked")
end)
Elevator:StartTraveling()
Elevator.Events.Parked:Wait()
Elevator.__Connections.Moving:Disconnect()
end

View File

@@ -0,0 +1,35 @@
--!optimize 2
--!native
--!strict
local ParentDir = script.Parent
local ElevatorDir = ParentDir.Parent
local MainDir = ElevatorDir.Parent.Parent
local StorageService = game:GetService("ReplicatedStorage")
local Types = MainDir:WaitForChild("Types")
local Enums = require(StorageService:WaitForChild("Enums"))
local ElevatorTypes = require(Types:WaitForChild("Elevator"))
local SoundEnums = require(Types:WaitForChild("Enums"):WaitForChild("Sounds"))
local HaughtonConfiguration = {} :: ElevatorTypes.ElevatorConfigurationTable
HaughtonConfiguration.Name = Enums.Elevator.Haughton
HaughtonConfiguration.FloorLevelingDistance = 4
HaughtonConfiguration.FloorLeveling3PhaseDistance = 1.5
HaughtonConfiguration.LevelingVelocity = 1
HaughtonConfiguration.Phase3LevelingVelocity = 1
HaughtonConfiguration.ParkedDistance = 0.2
HaughtonConfiguration.Responsiveness = 5
HaughtonConfiguration.MaxVelocity = 10
HaughtonConfiguration.Functions = {
ManualTravelStart = true
}
HaughtonConfiguration.Colors = {
ButtonActivated = Color3.fromRGB(180,0,0),
ButtonDeactivated = Color3.fromRGB(139,139,139),
LanternDisplayOn = Color3.fromRGB(44,255,157),
LanternDisplayOff = Color3.fromRGB(255,29,101),
}
return HaughtonConfiguration

View File

@@ -0,0 +1,8 @@
--!optimize 2
--!native
--!strict
return {
[1] = 1.163,
[2] = 19.163,
}

View File

@@ -0,0 +1,50 @@
--!optimize 2
--!native
--!strict
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
RotateRelayCogs: (self: ClassConstructor, InwardsDirection: boolean, SextetRow: boolean, Faulting: boolean, MagnetCog: BasePart, Cog2: BasePart, CounterWeight: BasePart, Row3_RelayDown: BasePart) -> Tween
}
type Constructor_Fun = () -> ClassConstructor
type Constructor_Return_Props = {}
local TS = game:GetService("TweenService")
local MovingObjects = {} :: Impl_Constructor
MovingObjects.__index = MovingObjects
function MovingObjects.constructor()
return setmetatable({}, MovingObjects)
end
function MovingObjects:RotateRelayCogs(InwardsDirection, SextetRow, Faulting, MagnetCog, Cog2, CounterWeight, Row_Relays)
local CogTweenInfo = TweenInfo.new(InwardsDirection and .25 or (Faulting and 5 or 3), InwardsDirection and Enum.EasingStyle.Quad or Enum.EasingStyle.Elastic)
local MagnetCogTween = TS:Create(MagnetCog, CogTweenInfo, {
CFrame = MagnetCog.CFrame*CFrame.Angles(math.rad(InwardsDirection and -90 or 90), 0, 0)
})
local Cog2Tween = TS:Create(Cog2, CogTweenInfo, {
CFrame = Cog2.CFrame*CFrame.Angles(math.rad(InwardsDirection and 90 or -90), 0, 0)
})
local CounterWeightTween = TS:Create(CounterWeight, TweenInfo.new(.105, Enum.EasingStyle.Linear), {
Position = InwardsDirection and CounterWeight.Position+Vector3.new(0,.23,0) or CounterWeight.Position-Vector3.new(0,.23,0)
})
local RelaysTween = TS:Create(Row_Relays, TweenInfo.new(.105, Enum.EasingStyle.Linear), {
CFrame = Row_Relays.CFrame*CFrame.Angles(0,0,math.rad(SextetRow and (InwardsDirection and 6 or -6) or InwardsDirection and -6 or 6))
})
MagnetCogTween:Play()
Cog2Tween:Play()
CounterWeightTween:Play()
RelaysTween:Play()
return MagnetCogTween
end
return MovingObjects

View File

@@ -0,0 +1,108 @@
--!optimize 2
--!native
--!strict
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 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)
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)
PulleyWheel.CFrame*=CFrame.Angles(math.rad(Pulley_Y_Direction/2),0,0)
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)
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()
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)
Elevator:StartTraveling()
end

View File

@@ -2,29 +2,36 @@
--!native
--!strict
local MainDir = script.Parent.Parent
local ParentDir = script.Parent
local ElevatorDir = ParentDir.Parent
local MainDir = ElevatorDir.Parent.Parent
local StorageService = game:GetService("ReplicatedStorage")
local Types = MainDir:WaitForChild("Types")
local Enums = require(StorageService:WaitForChild("Enums"))
local SoundEnums = require(MainDir:WaitForChild("Enums"):WaitForChild("Sounds"))
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator"))
local ElevatorTypes = require(Types:WaitForChild("Elevator"))
local SoundEnums = require(Types:WaitForChild("Enums"):WaitForChild("Sounds"))
local Otis1960Configuration = {} :: ElevatorTypes.ElevatorConfigurationTable
Otis1960Configuration.Name = Enums.Elevator.Otis1960
Otis1960Configuration.FloorLevelingDistance = 4
Otis1960Configuration.FloorLeveling3PhaseDistance = 1.5
Otis1960Configuration.Phase3LevelingVelocity = .5
Otis1960Configuration.LevelingVelocity = 2
Otis1960Configuration.ParkedDistance = 0.2
Otis1960Configuration.Responsiveness = 20
Otis1960Configuration.MaxVelocity = 7
Otis1960Configuration.LevelingVelocity = 2
Otis1960Configuration.Phase3LevelingVelocity = .5
Otis1960Configuration.Functions = {
ManualTravelStart = false
}
Otis1960Configuration.Sounds = {
LanternChimeDirection = SoundEnums.Otis1960.LanternChimeDirection,
LanternChimeLanding = SoundEnums.Otis1960.LanternChimeLanding
}
Otis1960Configuration.Colors = {
ButtonActivated = Color3.fromRGB(180,0,0),
ButtonDeactivated = Color3.fromRGB(139,139,139),
@@ -32,26 +39,4 @@ Otis1960Configuration.Colors = {
LanternDisplayOff = Color3.fromRGB(55,55,55),
}
local HaughtonConfiguration = {} :: ElevatorTypes.ElevatorConfigurationTable
HaughtonConfiguration.Name = Enums.Elevator.Haughton
HaughtonConfiguration.FloorLevelingDistance = 4
HaughtonConfiguration.FloorLeveling3PhaseDistance = 1.5
HaughtonConfiguration.ParkedDistance = 0.2
HaughtonConfiguration.Responsiveness = 20
HaughtonConfiguration.MaxVelocity = 7
HaughtonConfiguration.LevelingVelocity = 2
HaughtonConfiguration.Phase3LevelingVelocity = .5
HaughtonConfiguration.Functions = {
ManualTravelStart = true
}
HaughtonConfiguration.Colors = {
ButtonActivated = Color3.fromRGB(180,0,0),
ButtonDeactivated = Color3.fromRGB(139,139,139),
LanternDisplayOn = Color3.fromRGB(44,255,157),
LanternDisplayOff = Color3.fromRGB(255,29,101),
}
return {
Otis1960Configuration = Otis1960Configuration,
HaughtonConfiguration = HaughtonConfiguration
}
return Otis1960Configuration

View File

@@ -2,7 +2,7 @@
--!native
--!strict
local Otis1960Leveling: {number} = {
return {
[1] = 13.041,
[2] = 37.973,
[3] = 62.978,
@@ -14,13 +14,3 @@ local Otis1960Leveling: {number} = {
[9] = 213.058,
[10] = 239.245,
}
local HaughtonLeveling: {number} = {
[1] = 1.163,
[2] = 19.163,
}
return {
Otis1960Leveling = Otis1960Leveling,
HaughtonLeveling = HaughtonLeveling
}

View File

@@ -7,7 +7,7 @@ type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
UpdateCFrame: (self: ClassConstructor) -> (),
UpdateCFrame: (self: ClassConstructor) -> (),
FramePullies: (self: ClassConstructor, Delta: number, ElevatorVelocity_Y: number) -> (),
FramePiePlate: (self: ClassConstructor, Delta: number, ElevatorVelocity_Y: number) -> ()
}
@@ -46,7 +46,7 @@ MovingObjects.__index = MovingObjects
function MovingObjects.constructor(InstanceTree)
local self = InstanceTree :: Constructor_Return_Props
self.MachineRoom._CFrame.PulleyCFrame = InstanceTree.MachineRoom.Pulley.CFrame
self.MachineRoom._CFrame.Pulley2CFrame = InstanceTree.MachineRoom.Pulley2.CFrame
self.MachineRoom._CFrame.GovernorCFrame = InstanceTree.MachineRoom.Governor.CFrame
@@ -92,4 +92,4 @@ function MovingObjects:FramePiePlate(Delta, ElevatorVelocity_Y)
MR.PiePlatePlates.CFrame = MR_C.PiePlatePlatesCFrame *CFrame.Angles(-math.rad(Delta*5), 0, 0)
end
return MovingObjects
return MovingObjects

View File

@@ -2,18 +2,6 @@
--!native
--!strict
local ParentDir = script.Parent
local MainDir = ParentDir.Parent
local StorageService = game:GetService("ReplicatedStorage")
local Enums = require(StorageService:WaitForChild("Enums"))
local InitElevator = require(ParentDir:WaitForChild("InitElevator"))
local TagsModule = require(MainDir:WaitForChild("Load"):WaitForChild("Tags"))
local ElevatorConfigurationTable = require(ParentDir:WaitForChild("Configs"))
local FloorLevelingPositions = require(ParentDir:WaitForChild("Leveling"))
-- self.ElevatorBox_1960 = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
-- self.ElevatorDoor1 = TagsConstructor:Request("ElevatorDoor_1960_1") :: BasePart
-- self.ElevatorDoor2 = TagsConstructor:Request("ElevatorDoor_1960_2") :: BasePart
@@ -29,8 +17,18 @@ local FloorLevelingPositions = require(ParentDir:WaitForChild("Leveling"))
-- self.MachineRoom.PiePlatePlates = TagsConstructor:Request("Otis1960_PiePlatePlates") :: UnionOperation
-- self.MachineRoom.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
--local ElevatorBoxModel = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
local ParentDir = script.Parent
local ElevatorsDir = ParentDir.Parent
local MainDir = ElevatorsDir.Parent
local StorageService = game:GetService("ReplicatedStorage")
local InitElevator = require(ElevatorsDir:WaitForChild("System"))
local Config = require(script:WaitForChild("Config"))
local Leveling = require(script:WaitForChild("Leveling"))
local Enums = require(StorageService:WaitForChild("Enums"))
local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags"))
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
--local Elevator = InitElevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable.Otis1960Configuration, FloorLevelingPositions)
end

View File

@@ -4,10 +4,12 @@
local Elevators = script.Parent
local MainDir = Elevators.Parent
local LoadDir = MainDir:WaitForChild("Load")
local MapDir = MainDir:WaitForChild("Map")
local LoadDir = MapDir:WaitForChild("Load")
local RunService = game:GetService("RunService")
local StorageService = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Enums = require(StorageService:WaitForChild("Enums"))
local Out = require(StorageService:WaitForChild("Output"))
@@ -47,28 +49,8 @@ type Constructor_Return_Props = {
AlignPosition: AlignPosition,
Configuration: ElevatorTypes.ElevatorConfigurationTable
},
Attributes: {
PreviousFloor: IntValue,
CurrentFloor: IntValue,
NextFloor: IntValue,
Goal: IntValue,
TravelingUpwards: BoolValue,
Stopped: BoolValue
},
Events: {
Progression: RBXScriptSignal<number, number, number>,
Traveling: RBXScriptSignal<number, Vector3>,
Parked: RBXScriptSignal,
Leveling: RBXScriptSignal,
Leveling3Phase: RBXScriptSignal,
__eventInstances__: {
Progression: BindableEvent,
Traveling: BindableEvent,
Parked: BindableEvent,
Leveling: BindableEvent,
Leveling3Phase: BindableEvent,
}
},
Attributes: Attributes,
Events: Events,
__functionEvents: {
StartTraveling: BindableEvent
},
@@ -77,6 +59,30 @@ type Constructor_Return_Props = {
}
}
export type Attributes = {
PreviousFloor: IntValue,
CurrentFloor: IntValue,
NextFloor: IntValue,
Goal: IntValue,
TravelingUpwards: BoolValue,
Stopped: BoolValue
}
export type Events = {
Progression: RBXScriptSignal<number, number, number>,
Traveling: RBXScriptSignal<number, Vector3>,
Parked: RBXScriptSignal,
Leveling: RBXScriptSignal,
Leveling3Phase: RBXScriptSignal,
__eventInstances__: {
Progression: BindableEvent,
Traveling: BindableEvent,
Parked: BindableEvent,
Leveling: BindableEvent,
Leveling3Phase: BindableEvent,
}
}
local Elevator = {} :: Impl_Constructor
Elevator.__index = Elevator
@@ -86,7 +92,7 @@ local function ElevatorGoingUpDirection(CurrentFloor: number, RequestedFloor: nu
return CurrentFloor<RequestedFloor
end
local function Mover(ElevatorBoxModel: BasePart, Responsiveness: number, MaxVelocity: number): (Attachment, AlignPosition, AlignOrientation)
local function Mover(ElevatorBoxModel: BasePart, Responsiveness: number): (Attachment, AlignPosition, AlignOrientation)
local BoxAttachment = Instance.new("Attachment")
BoxAttachment.Parent = ElevatorBoxModel
@@ -98,7 +104,7 @@ local function Mover(ElevatorBoxModel: BasePart, Responsiveness: number, MaxVelo
-- BoxAlignPosition.RigidityEnabled = true
-- Lines below are disabled with RigidityEnabled true
BoxAlignPosition.Responsiveness = Responsiveness
BoxAlignPosition.MaxVelocity = MaxVelocity
BoxAlignPosition.MaxVelocity = 0
--
BoxAlignPosition.Parent = ElevatorBoxModel
@@ -131,7 +137,7 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo
local _BoxAttachment,
BoxAlignPosition,
_BoxAlignOrientation = Mover(ElevatorBoxModel, ElevatorConfigurationTable.Responsiveness, ElevatorConfigurationTable.MaxVelocity)
_BoxAlignOrientation = Mover(ElevatorBoxModel, ElevatorConfigurationTable.Responsiveness)
local RelayAlgorithmConstructor = RelayAlgorithm.constructor(BoxAlignPosition)
@@ -215,11 +221,22 @@ local function ProceedToNextLevel(self: ClassConstructor, Level_Int: number): Ve
return VEC3_Y_WRAP
end
local function SmoothVelocity(self: ClassConstructor, Velocity: number, Timing: number): Tween
local VelocitySmoothing = TweenService:Create(self.Elevator.AlignPosition, TweenInfo.new(Timing, Enum.EasingStyle.Quad), {
MaxVelocity = Velocity
})
VelocitySmoothing:Play()
return VelocitySmoothing
end
local function GoingUpDirectionToDirectionEnum(CurrentFloor: number, RequestedFloor: number): Enums.ElevatorCallDirectionValues
return ElevatorGoingUpDirection(CurrentFloor, RequestedFloor) and Enums.ElevatorCallDirection.Up or Enums.ElevatorCallDirection.Down
end
local function CheckFloorQueue(self: ClassConstructor)
self.Elevator.AlignPosition.MaxVelocity = 0
local DirectionToDirectionQueue = self.Attributes.TravelingUpwards.Value and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down
local DirectionToOppositeDirectionQueue = self.Attributes.TravelingUpwards.Value and self.RelayAlgorithm.FloorQueue.Down or self.RelayAlgorithm.FloorQueue.Up
@@ -266,13 +283,18 @@ local function FloorsClamp(self: ClassConstructor, n: number): number
return Algebra.minmax(1, n, #self.FloorLevelingPositions)
end
local Debounce = {
Leveling = false,
Leveling3Phase = false
}
local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC3_Y_WRAP: Vector3)
local ElevatorPosition = self.Elevator.BoxModel.Position
local AtFloorY = self.FloorLevelingPositions[FloorsClamp(self, self.Attributes.TravelingUpwards.Value and self.Attributes.CurrentFloor.Value+1 or self.Attributes.CurrentFloor.Value-1)]
if self.Attributes.TravelingUpwards.Value then
--Detecting between the floors
if ElevatorPosition.Y>=AtFloorY-self.Elevator.Configuration.FloorLevelingDistance then
if ElevatorPosition.Y>=AtFloorY-self.Elevator.Configuration.FloorLevelingDistance and self.Attributes.CurrentFloor.Value~=self.Attributes.Goal.Value then
self.Attributes.PreviousFloor.Value = self.Attributes.CurrentFloor.Value
self.Attributes.CurrentFloor.Value+=1
self.Attributes.NextFloor.Value = FloorsClamp(self, self.Attributes.CurrentFloor.Value+1)
@@ -282,12 +304,19 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC
--Elevator is riding upwards towards the destination
if ElevatorPosition.Y>=LEVEL_VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLevelingDistance then
self.Events.__eventInstances__.Leveling:Fire()
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.LevelingVelocity
if not Debounce.Leveling then
self.Events.__eventInstances__.Leveling:Fire()
SmoothVelocity(self, self.Elevator.Configuration.LevelingVelocity, .5)
Debounce.Leveling = true
end
if ElevatorPosition.Y>=LEVEL_VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLeveling3PhaseDistance then
self.Events.__eventInstances__.Leveling3Phase:Fire()
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity
if not Debounce.Leveling3Phase then
self.Events.__eventInstances__.Leveling3Phase:Fire()
--I dont think 3 phase leveling should need smoothing
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity
Debounce.Leveling3Phase = true
end
if ElevatorPosition.Y>=LEVEL_VEC3_Y_WRAP.Y-self.Elevator.Configuration.ParkedDistance then
self.Events.__eventInstances__.Parked:Fire()
@@ -297,7 +326,7 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC
end
end
else
if ElevatorPosition.Y<=AtFloorY+self.Elevator.Configuration.FloorLevelingDistance then
if ElevatorPosition.Y<=AtFloorY+self.Elevator.Configuration.FloorLevelingDistance and self.Attributes.CurrentFloor.Value~=self.Attributes.Goal.Value then
self.Attributes.PreviousFloor.Value = self.Attributes.CurrentFloor.Value
self.Attributes.CurrentFloor.Value-=1
self.Attributes.NextFloor.Value = FloorsClamp(self, self.Attributes.CurrentFloor.Value-1)
@@ -307,12 +336,19 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC
--Elevator is riding upwards towards the destination
if ElevatorPosition.Y<=LEVEL_VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLevelingDistance then
self.Events.__eventInstances__.Leveling:Fire()
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.LevelingVelocity
if not Debounce.Leveling then
self.Events.__eventInstances__.Leveling:Fire()
SmoothVelocity(self, self.Elevator.Configuration.LevelingVelocity, .5)
Debounce.Leveling = true
end
if ElevatorPosition.Y<=LEVEL_VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLeveling3PhaseDistance then
self.Events.__eventInstances__.Leveling3Phase:Fire()
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity
if not Debounce.Leveling then
self.Events.__eventInstances__.Leveling3Phase:Fire()
--I dont think 3 phase leveling should need smoothing
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity
Debounce.Leveling3Phase = true
end
if ElevatorPosition.Y<=LEVEL_VEC3_Y_WRAP.Y+self.Elevator.Configuration.ParkedDistance then
self.Events.__eventInstances__.Parked:Fire()
@@ -349,13 +385,16 @@ function Elevator:__TravelToFloorAsync(Level_Int, LEVEL_VEC3_Y_WRAP)
self.Attributes.Goal.Value = Level_Int
self.Attributes.TravelingUpwards.Value = ElevatorTravelingUpwards
self.__Connections.Moving = RunService.Heartbeat:Connect(function(deltaTime: number)
Debounce.Leveling = false
Debounce.Leveling3Phase = false
self.__Connections.Moving = RunService.Stepped:Connect(function(deltaTime: number)
CabTraveling(self, deltaTime, LEVEL_VEC3_Y_WRAP)
end)
--Set the elevator's AlignPosition to the floor Y vector
self.Elevator.AlignPosition.Position = Vector3.new(self.Elevator.AlignPosition.Position.X, LEVEL_VEC3_Y_WRAP.Y, self.Elevator.AlignPosition.Position.Z)
--Set the elevator's max velocity to its fastest speed when moving starts
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.MaxVelocity
--Set the elevator's velocity
SmoothVelocity(self, self.Elevator.Configuration.MaxVelocity, 10)
end
function Elevator:RequestLevelAsync(RequestedLevel, Direction)

View File

@@ -3,8 +3,7 @@
--!strict
local MapDir = script.Parent.Parent
local MainDir = MapDir.Parent
local LoadDir = MainDir:WaitForChild("Load")
local LoadDir = MapDir:WaitForChild("Load")
local Storage = game:GetService("ReplicatedStorage")
@@ -46,7 +45,7 @@ end
local EnumMaterials: {Enum.Material} = Enum.Material:GetEnumItems()
local EnumMaterialsNames: {string} = {}
--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
EnumMaterialsNames[k] = v.Name
end
@@ -96,7 +95,7 @@ end
local function ToggleSwitch(EnabledState: boolean, LightProperties: LightProperties, Sounds: boolean)
SwitchAnimation(EnabledState, LightProperties)
if Sounds and LightProperties.ClickSound then
LightProperties.ClickSound:Play()
end
@@ -125,7 +124,7 @@ function Lights:Init()
LightProperties.Lights and
LightProperties.LightSources and
LightProperties.ActivatedMaterial and
LightProperties.DeactivatedMaterial
LightProperties.DeactivatedMaterial
then
if LightProperties.Enabled then
EnabledState = true
@@ -136,7 +135,7 @@ function Lights:Init()
local ActivatedMaterial = table.find(EnumMaterialsNames, LightProperties.ActivatedMaterial)
local DeactivatedMaterial = table.find(EnumMaterialsNames, LightProperties.DeactivatedMaterial)
if not ActivatedMaterial then
ActivatedMaterial = 1
warn()
@@ -162,4 +161,4 @@ function Lights:Init()
end
end
return Lights
return Lights

View File

@@ -32,7 +32,7 @@ type Impl_Static_Props = {
type Constructor_Fun = () -> ClassConstructor
type Constructor_Return_Props = {
__export: ExportedTags
__dump: ExportedTags
}
export type Lantern = {
@@ -58,7 +58,7 @@ export type Lanterns = {
export type LanternsTree = {
[Enums.ElevatorValues]: Lanterns
}
}
export type LightSwitchProperties = {
Switch: Instance?,
@@ -91,7 +91,7 @@ export type LightSwitchTree = {
}
export type InteractablesTree = {
LightSwitches: LightSwitchTree
LightSwitches: LightSwitchTree
}
export type ButtonDictionary = {
@@ -112,7 +112,7 @@ export type RelayDictionary = {
}
export type ButtonsTree = {
[Enums.ElevatorValues]: {
[Enums.ElevatorValues]: {
Car: ButtonDictionary,
Landing: ButtonDictionary,
Special: ButtonDictionary,
@@ -171,7 +171,7 @@ Tags.Decoders = {
function Tags.constructor()
local Exports: ExportedTags = {}
local AllTags = CS:GetAllTags()
for n: number = 1, #AllTags do
local TagName = AllTags[n]
local Tagged = CS:GetTagged(TagName)
@@ -179,16 +179,16 @@ function Tags.constructor()
end
return setmetatable({
__export = Exports
__dump = Exports
}, Tags)
end
function Tags:Request(Name)
return self.__export[Name] or error(`Error requesting tag name, tag name "{Name}" does not exist.`, 2)
return self.__dump[Name] or error(`Error requesting tag name, tag name "{Name}" does not exist.`, 2)
end
function Tags:Nuke()
for i: string, v: TagProduct in self.__export do
for i: string, v: TagProduct in self.__dump do
if type(v) == "table" then
for n: number = 1, #v do
CS:RemoveTag(v[n], i)
@@ -208,7 +208,7 @@ function Tags:__ElevatorLanterns()
for _, EnumValue in Enums.Elevator do
Lanterns[EnumValue :: Enums.ElevatorValues] = {}
for TagName: string, Inst: TagProduct in self.__export do
for TagName: string, Inst: TagProduct in self.__dump do
local Split = TagName:split('_')
local LanternModel = Split[1]
local IndicatorType = Split[2]
@@ -216,7 +216,7 @@ function Tags:__ElevatorLanterns()
if LanternModel == (EnumValue :: string) and IndicatorType == "DirectionIndicator" then
local Floor = tonumber(FloorHint)
if Floor then
if not Lanterns[EnumValue :: Enums.ElevatorValues][Floor] then
local Light = ((Inst :: BasePart).Parent :: Instance):FindFirstChild("Light") :: BasePart?
@@ -266,7 +266,7 @@ function Tags:__ElevatorButtons()
for _, EnumValue in Enums.Elevator do
Buttons[EnumValue :: Enums.ElevatorValues] = {}
for TagName: string, Inst: TagProduct in self.__export do
for TagName: string, Inst: TagProduct in self.__dump do
local Split = TagName:split('_')
local ModelHint = Split[1]
local ButtonHint = Split[2]
@@ -291,7 +291,7 @@ function Tags:__ElevatorDoors()
for _, EnumValue in Enums.Elevator do
Doors[EnumValue :: Enums.ElevatorValues] = {}
for TagName: string, Inst: TagProduct in self.__export do
for TagName: string, Inst: TagProduct in self.__dump do
local Split = TagName:split('_')
local ModelHint = Split[1]
local FloorHint = Split[2]
@@ -306,7 +306,7 @@ function Tags:__ElevatorDoors()
if FloorNumber then
local DoorNumberPlacement = tonumber(DoorNumber)
if DoorNumberPlacement then
if not Doors[ModelHint][FloorNumber] then
Doors[ModelHint][FloorNumber] = {}
@@ -314,7 +314,7 @@ function Tags:__ElevatorDoors()
if typeof(Inst) ~= "Instance" then
Inst = Inst[1]
warn(`[{ModelHint}] Door {Inst} was not a single instance, duplicate doors detected Tag={TagName}`)
end
end
table.insert(Doors[ModelHint][FloorNumber], DoorNumberPlacement, Inst :: Instance)
else
@@ -338,7 +338,7 @@ function Tags:__Interactables()
LightSwitches = {}
}
for TagName: string, Inst: TagProduct in self.__export do
for TagName: string, Inst: TagProduct in self.__dump do
local Split = TagName:split('_')
local InteractHint = Split[1]
local InteractType = Split[2]
@@ -377,7 +377,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
@@ -387,4 +387,4 @@ function Tags:__Interactables()
return Interactables
end
return Tags
return Tags

View File

@@ -1,5 +1,4 @@
local MainDir = script.Parent.Parent
local EnumsDir = MainDir:WaitForChild("Enums")
local EnumsDir = script.Parent:WaitForChild("Enums")
local StorageService = game:GetService("ReplicatedStorage")

View File

@@ -6,29 +6,33 @@ local ShowEditorEntities = true
local Storage = game:GetService("ReplicatedStorage")
local _PlayerAdded = require(script:WaitForChild("PlayerAdded"))
local Lighting_Stuff = require(script:WaitForChild("Lighting"))
--Prerequisite loading, do not put more code above this
local _PlayerAdded = require(script:WaitForChild("PlayerAdded"))
--
local Load = script:WaitForChild("Load")
local MapDir = script:WaitForChild("Map")
local Lighting_Stuff = require(MapDir:WaitForChild("Lighting"))
local Load = MapDir: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 Elevator = Elevators:WaitForChild("Elevator")
local Maps = script:WaitForChild("Map")
local Elevators = script:WaitForChild("Elevators")
local MapElevators = Elevators:WaitForChild("Map")
local Map = script:WaitForChild("Map")
local Interactions = Maps:WaitForChild("Interactions")
local Interactions = Map:WaitForChild("Interactions")
local LightSwitches = require(Interactions:WaitForChild("LightSwitches"))
--local Otis1960 = require(Elevators:WaitForChild("Elevator"):WaitForChild("Otis1960"))
local Haughton = require(Elevator:WaitForChild("Haughton"))
--local Otis1960 = require(Elevators:WaitForChild("Elevator"):WaitForChild("Otis1960"))
local Haughton = require(MapElevators:WaitForChild("Haughton"))
local Enums = require(Storage:WaitForChild("Enums"))
local TagsConstructor = TagsModule.constructor()
print("[DEBUG] Tags=", TagsConstructor.__export)
print("[DEBUG] Tags=", TagsConstructor.__dump)
HideEditorEntities.indexAll(ShowEditorEntities)
TagsConstructor:Nuke()