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 --!native
--!strict --!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 StorageService = game:GetService("ReplicatedStorage")
local Types = MainDir:WaitForChild("Types")
local Enums = require(StorageService:WaitForChild("Enums")) local Enums = require(StorageService:WaitForChild("Enums"))
local SoundEnums = require(MainDir:WaitForChild("Enums"):WaitForChild("Sounds")) local ElevatorTypes = require(Types:WaitForChild("Elevator"))
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator")) local SoundEnums = require(Types:WaitForChild("Enums"):WaitForChild("Sounds"))
local Otis1960Configuration = {} :: ElevatorTypes.ElevatorConfigurationTable local Otis1960Configuration = {} :: ElevatorTypes.ElevatorConfigurationTable
Otis1960Configuration.Name = Enums.Elevator.Otis1960 Otis1960Configuration.Name = Enums.Elevator.Otis1960
Otis1960Configuration.FloorLevelingDistance = 4 Otis1960Configuration.FloorLevelingDistance = 4
Otis1960Configuration.FloorLeveling3PhaseDistance = 1.5 Otis1960Configuration.FloorLeveling3PhaseDistance = 1.5
Otis1960Configuration.Phase3LevelingVelocity = .5
Otis1960Configuration.LevelingVelocity = 2
Otis1960Configuration.ParkedDistance = 0.2 Otis1960Configuration.ParkedDistance = 0.2
Otis1960Configuration.Responsiveness = 20 Otis1960Configuration.Responsiveness = 20
Otis1960Configuration.MaxVelocity = 7 Otis1960Configuration.MaxVelocity = 7
Otis1960Configuration.LevelingVelocity = 2
Otis1960Configuration.Phase3LevelingVelocity = .5
Otis1960Configuration.Functions = { Otis1960Configuration.Functions = {
ManualTravelStart = false ManualTravelStart = false
} }
Otis1960Configuration.Sounds = { Otis1960Configuration.Sounds = {
LanternChimeDirection = SoundEnums.Otis1960.LanternChimeDirection, LanternChimeDirection = SoundEnums.Otis1960.LanternChimeDirection,
LanternChimeLanding = SoundEnums.Otis1960.LanternChimeLanding LanternChimeLanding = SoundEnums.Otis1960.LanternChimeLanding
} }
Otis1960Configuration.Colors = { Otis1960Configuration.Colors = {
ButtonActivated = Color3.fromRGB(180,0,0), ButtonActivated = Color3.fromRGB(180,0,0),
ButtonDeactivated = Color3.fromRGB(139,139,139), ButtonDeactivated = Color3.fromRGB(139,139,139),
@@ -32,26 +39,4 @@ Otis1960Configuration.Colors = {
LanternDisplayOff = Color3.fromRGB(55,55,55), LanternDisplayOff = Color3.fromRGB(55,55,55),
} }
local HaughtonConfiguration = {} :: ElevatorTypes.ElevatorConfigurationTable return Otis1960Configuration
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
}

View File

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

View File

@@ -2,18 +2,6 @@
--!native --!native
--!strict --!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.ElevatorBox_1960 = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
-- self.ElevatorDoor1 = TagsConstructor:Request("ElevatorDoor_1960_1") :: BasePart -- self.ElevatorDoor1 = TagsConstructor:Request("ElevatorDoor_1960_1") :: BasePart
-- self.ElevatorDoor2 = TagsConstructor:Request("ElevatorDoor_1960_2") :: 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.PiePlatePlates = TagsConstructor:Request("Otis1960_PiePlatePlates") :: UnionOperation
-- self.MachineRoom.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation -- self.MachineRoom.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags) local ParentDir = script.Parent
--local ElevatorBoxModel = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation 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 end

View File

@@ -4,10 +4,12 @@
local Elevators = script.Parent local Elevators = script.Parent
local MainDir = Elevators.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 RunService = game:GetService("RunService")
local StorageService = game:GetService("ReplicatedStorage") local StorageService = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Enums = require(StorageService:WaitForChild("Enums")) local Enums = require(StorageService:WaitForChild("Enums"))
local Out = require(StorageService:WaitForChild("Output")) local Out = require(StorageService:WaitForChild("Output"))
@@ -47,15 +49,26 @@ type Constructor_Return_Props = {
AlignPosition: AlignPosition, AlignPosition: AlignPosition,
Configuration: ElevatorTypes.ElevatorConfigurationTable Configuration: ElevatorTypes.ElevatorConfigurationTable
}, },
Attributes: { Attributes: Attributes,
Events: Events,
__functionEvents: {
StartTraveling: BindableEvent
},
__Connections: {
Moving: RBXScriptConnection?,
}
}
export type Attributes = {
PreviousFloor: IntValue, PreviousFloor: IntValue,
CurrentFloor: IntValue, CurrentFloor: IntValue,
NextFloor: IntValue, NextFloor: IntValue,
Goal: IntValue, Goal: IntValue,
TravelingUpwards: BoolValue, TravelingUpwards: BoolValue,
Stopped: BoolValue Stopped: BoolValue
}, }
Events: {
export type Events = {
Progression: RBXScriptSignal<number, number, number>, Progression: RBXScriptSignal<number, number, number>,
Traveling: RBXScriptSignal<number, Vector3>, Traveling: RBXScriptSignal<number, Vector3>,
Parked: RBXScriptSignal, Parked: RBXScriptSignal,
@@ -68,13 +81,6 @@ type Constructor_Return_Props = {
Leveling: BindableEvent, Leveling: BindableEvent,
Leveling3Phase: BindableEvent, Leveling3Phase: BindableEvent,
} }
},
__functionEvents: {
StartTraveling: BindableEvent
},
__Connections: {
Moving: RBXScriptConnection?,
}
} }
local Elevator = {} :: Impl_Constructor local Elevator = {} :: Impl_Constructor
@@ -86,7 +92,7 @@ local function ElevatorGoingUpDirection(CurrentFloor: number, RequestedFloor: nu
return CurrentFloor<RequestedFloor return CurrentFloor<RequestedFloor
end 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") local BoxAttachment = Instance.new("Attachment")
BoxAttachment.Parent = ElevatorBoxModel BoxAttachment.Parent = ElevatorBoxModel
@@ -98,7 +104,7 @@ local function Mover(ElevatorBoxModel: BasePart, Responsiveness: number, MaxVelo
-- BoxAlignPosition.RigidityEnabled = true -- BoxAlignPosition.RigidityEnabled = true
-- Lines below are disabled with RigidityEnabled true -- Lines below are disabled with RigidityEnabled true
BoxAlignPosition.Responsiveness = Responsiveness BoxAlignPosition.Responsiveness = Responsiveness
BoxAlignPosition.MaxVelocity = MaxVelocity BoxAlignPosition.MaxVelocity = 0
-- --
BoxAlignPosition.Parent = ElevatorBoxModel BoxAlignPosition.Parent = ElevatorBoxModel
@@ -131,7 +137,7 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo
local _BoxAttachment, local _BoxAttachment,
BoxAlignPosition, BoxAlignPosition,
_BoxAlignOrientation = Mover(ElevatorBoxModel, ElevatorConfigurationTable.Responsiveness, ElevatorConfigurationTable.MaxVelocity) _BoxAlignOrientation = Mover(ElevatorBoxModel, ElevatorConfigurationTable.Responsiveness)
local RelayAlgorithmConstructor = RelayAlgorithm.constructor(BoxAlignPosition) local RelayAlgorithmConstructor = RelayAlgorithm.constructor(BoxAlignPosition)
@@ -215,11 +221,22 @@ local function ProceedToNextLevel(self: ClassConstructor, Level_Int: number): Ve
return VEC3_Y_WRAP return VEC3_Y_WRAP
end 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 local function GoingUpDirectionToDirectionEnum(CurrentFloor: number, RequestedFloor: number): Enums.ElevatorCallDirectionValues
return ElevatorGoingUpDirection(CurrentFloor, RequestedFloor) and Enums.ElevatorCallDirection.Up or Enums.ElevatorCallDirection.Down return ElevatorGoingUpDirection(CurrentFloor, RequestedFloor) and Enums.ElevatorCallDirection.Up or Enums.ElevatorCallDirection.Down
end end
local function CheckFloorQueue(self: ClassConstructor) 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 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 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) return Algebra.minmax(1, n, #self.FloorLevelingPositions)
end end
local Debounce = {
Leveling = false,
Leveling3Phase = false
}
local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC3_Y_WRAP: Vector3) local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC3_Y_WRAP: Vector3)
local ElevatorPosition = self.Elevator.BoxModel.Position 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)] 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 if self.Attributes.TravelingUpwards.Value then
--Detecting between the floors --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.PreviousFloor.Value = self.Attributes.CurrentFloor.Value
self.Attributes.CurrentFloor.Value+=1 self.Attributes.CurrentFloor.Value+=1
self.Attributes.NextFloor.Value = FloorsClamp(self, 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 --Elevator is riding upwards towards the destination
if ElevatorPosition.Y>=LEVEL_VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLevelingDistance then if ElevatorPosition.Y>=LEVEL_VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLevelingDistance then
if not Debounce.Leveling then
self.Events.__eventInstances__.Leveling:Fire() self.Events.__eventInstances__.Leveling:Fire()
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.LevelingVelocity SmoothVelocity(self, self.Elevator.Configuration.LevelingVelocity, .5)
Debounce.Leveling = true
end
if ElevatorPosition.Y>=LEVEL_VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLeveling3PhaseDistance then if ElevatorPosition.Y>=LEVEL_VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLeveling3PhaseDistance then
if not Debounce.Leveling3Phase then
self.Events.__eventInstances__.Leveling3Phase:Fire() self.Events.__eventInstances__.Leveling3Phase:Fire()
--I dont think 3 phase leveling should need smoothing
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity 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 if ElevatorPosition.Y>=LEVEL_VEC3_Y_WRAP.Y-self.Elevator.Configuration.ParkedDistance then
self.Events.__eventInstances__.Parked:Fire() self.Events.__eventInstances__.Parked:Fire()
@@ -297,7 +326,7 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC
end end
end end
else 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.PreviousFloor.Value = self.Attributes.CurrentFloor.Value
self.Attributes.CurrentFloor.Value-=1 self.Attributes.CurrentFloor.Value-=1
self.Attributes.NextFloor.Value = FloorsClamp(self, 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 --Elevator is riding upwards towards the destination
if ElevatorPosition.Y<=LEVEL_VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLevelingDistance then if ElevatorPosition.Y<=LEVEL_VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLevelingDistance then
if not Debounce.Leveling then
self.Events.__eventInstances__.Leveling:Fire() self.Events.__eventInstances__.Leveling:Fire()
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.LevelingVelocity SmoothVelocity(self, self.Elevator.Configuration.LevelingVelocity, .5)
Debounce.Leveling = true
end
if ElevatorPosition.Y<=LEVEL_VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLeveling3PhaseDistance then if ElevatorPosition.Y<=LEVEL_VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLeveling3PhaseDistance then
if not Debounce.Leveling then
self.Events.__eventInstances__.Leveling3Phase:Fire() self.Events.__eventInstances__.Leveling3Phase:Fire()
--I dont think 3 phase leveling should need smoothing
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity 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 if ElevatorPosition.Y<=LEVEL_VEC3_Y_WRAP.Y+self.Elevator.Configuration.ParkedDistance then
self.Events.__eventInstances__.Parked:Fire() 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.Goal.Value = Level_Int
self.Attributes.TravelingUpwards.Value = ElevatorTravelingUpwards 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) CabTraveling(self, deltaTime, LEVEL_VEC3_Y_WRAP)
end) end)
--Set the elevator's AlignPosition to the floor Y vector --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) 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 --Set the elevator's velocity
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.MaxVelocity SmoothVelocity(self, self.Elevator.Configuration.MaxVelocity, 10)
end end
function Elevator:RequestLevelAsync(RequestedLevel, Direction) function Elevator:RequestLevelAsync(RequestedLevel, Direction)

View File

@@ -3,8 +3,7 @@
--!strict --!strict
local MapDir = script.Parent.Parent local MapDir = script.Parent.Parent
local MainDir = MapDir.Parent local LoadDir = MapDir:WaitForChild("Load")
local LoadDir = MainDir:WaitForChild("Load")
local Storage = game:GetService("ReplicatedStorage") local Storage = game:GetService("ReplicatedStorage")
@@ -46,7 +45,7 @@ end
local EnumMaterials: {Enum.Material} = Enum.Material:GetEnumItems() local EnumMaterials: {Enum.Material} = Enum.Material:GetEnumItems()
local EnumMaterialsNames: {string} = {} 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 for k: number, v: Enum.Material in EnumMaterials do
EnumMaterialsNames[k] = v.Name EnumMaterialsNames[k] = v.Name
end end

View File

@@ -32,7 +32,7 @@ type Impl_Static_Props = {
type Constructor_Fun = () -> ClassConstructor type Constructor_Fun = () -> ClassConstructor
type Constructor_Return_Props = { type Constructor_Return_Props = {
__export: ExportedTags __dump: ExportedTags
} }
export type Lantern = { export type Lantern = {
@@ -179,16 +179,16 @@ function Tags.constructor()
end end
return setmetatable({ return setmetatable({
__export = Exports __dump = Exports
}, Tags) }, Tags)
end end
function Tags:Request(Name) 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 end
function Tags:Nuke() 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 if type(v) == "table" then
for n: number = 1, #v do for n: number = 1, #v do
CS:RemoveTag(v[n], i) CS:RemoveTag(v[n], i)
@@ -208,7 +208,7 @@ function Tags:__ElevatorLanterns()
for _, EnumValue in Enums.Elevator do for _, EnumValue in Enums.Elevator do
Lanterns[EnumValue :: Enums.ElevatorValues] = {} 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 Split = TagName:split('_')
local LanternModel = Split[1] local LanternModel = Split[1]
local IndicatorType = Split[2] local IndicatorType = Split[2]
@@ -266,7 +266,7 @@ function Tags:__ElevatorButtons()
for _, EnumValue in Enums.Elevator do for _, EnumValue in Enums.Elevator do
Buttons[EnumValue :: Enums.ElevatorValues] = {} 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 Split = TagName:split('_')
local ModelHint = Split[1] local ModelHint = Split[1]
local ButtonHint = Split[2] local ButtonHint = Split[2]
@@ -291,7 +291,7 @@ function Tags:__ElevatorDoors()
for _, EnumValue in Enums.Elevator do for _, EnumValue in Enums.Elevator do
Doors[EnumValue :: Enums.ElevatorValues] = {} 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 Split = TagName:split('_')
local ModelHint = Split[1] local ModelHint = Split[1]
local FloorHint = Split[2] local FloorHint = Split[2]
@@ -338,7 +338,7 @@ function Tags:__Interactables()
LightSwitches = {} LightSwitches = {}
} }
for TagName: string, Inst: TagProduct in self.__export do for TagName: string, Inst: TagProduct in self.__dump do
local Split = TagName:split('_') local Split = TagName:split('_')
local InteractHint = Split[1] local InteractHint = Split[1]
local InteractType = Split[2] local InteractType = Split[2]

View File

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

View File

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