Restructure the elevator scripts, and gonna try this elevator leveling and call system

This commit is contained in:
2024-08-01 18:31:15 -04:00
parent 2b7852d091
commit 51302d2d7b
7 changed files with 56 additions and 52 deletions

File diff suppressed because one or more lines are too long

View File

@@ -2,37 +2,38 @@
--!native --!native
--!strict --!strict
local MainDir = script.Parent.Parent.Parent local MainDir = script.Parent.Parent
local StorageService = game:GetService("ReplicatedStorage") local StorageService = game:GetService("ReplicatedStorage")
local Enums = require(StorageService:WaitForChild("Enums")) local Enums = require(StorageService:WaitForChild("Enums"))
local SoundEnums = require(MainDir:WaitForChild("Enums"):WaitForChild("Sounds")) local SoundEnums = require(MainDir:WaitForChild("Enums"):WaitForChild("Sounds"))
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator")) local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator"))
local ElevatorConfiguration = {} :: ElevatorTypes.ElevatorConfigurationTable local Otis1960Configuration = {} :: ElevatorTypes.ElevatorConfigurationTable
ElevatorConfiguration.Name = Enums.Elevator.Otis1960 Otis1960Configuration.Name = Enums.Elevator.Otis1960
ElevatorConfiguration.FloorLevelingDistance = 4 Otis1960Configuration.FloorLevelingDistance = 4
ElevatorConfiguration.FloorLeveling3PhaseDistance = 1.5 Otis1960Configuration.FloorLeveling3PhaseDistance = 1.5
ElevatorConfiguration.ParkedDistance = 0.2 Otis1960Configuration.ParkedDistance = 0.2
ElevatorConfiguration.Responsiveness = 20 Otis1960Configuration.Responsiveness = 20
ElevatorConfiguration.MaxVelocity = 7 Otis1960Configuration.MaxVelocity = 7
ElevatorConfiguration.LevelingVelocity = 2 Otis1960Configuration.LevelingVelocity = 2
ElevatorConfiguration.Phase3LevelingVelocity = .5 Otis1960Configuration.Phase3LevelingVelocity = .5
Otis1960Configuration.Functions = {
ElevatorConfiguration.Functions = {
ManualTravelStart = false ManualTravelStart = false
} }
Otis1960Configuration.Sounds = {
ElevatorConfiguration.Sounds = {
LanternChimeDirection = SoundEnums.Otis1960.LanternChimeDirection, LanternChimeDirection = SoundEnums.Otis1960.LanternChimeDirection,
LanternChimeLanding = SoundEnums.Otis1960.LanternChimeLanding LanternChimeLanding = SoundEnums.Otis1960.LanternChimeLanding
} }
Otis1960Configuration.Colors = {
ElevatorConfiguration.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),
LanternDisplayOn = Color3.fromRGB(255,114,71), LanternDisplayOn = Color3.fromRGB(255,114,71),
LanternDisplayOff = Color3.fromRGB(55,55,55), LanternDisplayOff = Color3.fromRGB(55,55,55),
} }
return ElevatorConfiguration
return {
Otis1960Configuration = Otis1960Configuration
}

View File

@@ -93,7 +93,7 @@ local function Mover(ElevatorBoxModel: UnionOperation, Responsiveness: number, M
local BoxAlignPosition = Instance.new("AlignPosition") local BoxAlignPosition = Instance.new("AlignPosition")
BoxAlignPosition.Mode = Enum.PositionAlignmentMode.OneAttachment BoxAlignPosition.Mode = Enum.PositionAlignmentMode.OneAttachment
BoxAlignPosition.Attachment0 = BoxAttachment BoxAlignPosition.Attachment0 = BoxAttachment
BoxAlignPosition.MaxForce = math.huge BoxAlignPosition.MaxForce = 1e6
BoxAlignPosition.Position = ElevatorBoxModel.Position BoxAlignPosition.Position = ElevatorBoxModel.Position
-- BoxAlignPosition.RigidityEnabled = true -- BoxAlignPosition.RigidityEnabled = true
-- Lines below are disabled with RigidityEnabled true -- Lines below are disabled with RigidityEnabled true
@@ -342,6 +342,7 @@ function Elevator:__TravelToFloorAsync(Level_Int, LEVEL_VEC3_Y_WRAP)
self.__Connections.Moving:Disconnect() self.__Connections.Moving:Disconnect()
end end
print("TravelingToFloorAsync")
local ElevatorTravelingUpwards = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, Level_Int) local ElevatorTravelingUpwards = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, Level_Int)
self.Attributes.Goal.Value = Level_Int self.Attributes.Goal.Value = Level_Int
self.Attributes.TravelingUpwards.Value = ElevatorTravelingUpwards self.Attributes.TravelingUpwards.Value = ElevatorTravelingUpwards

View File

@@ -0,0 +1,29 @@
--!optimize 2
--!native
--!strict
local Otis1960Leveling: {number} = {
[1] = 13.041,
[2] = 37.973,
[3] = 62.978,
[4] = 87.968,
[5] = 112.952,
[6] = 137.988,
[7] = 163.009,
[8] = 188.007,
[9] = 213.058,
[10] = 239.245,
}
local HaughtonLeveling: {number} = {
[1] = 0,
[2] = 0,
[3] = 0,
[4] = 0,
[5] = 0,
}
return {
Otis1960Leveling = Otis1960Leveling,
HaughtonLeveling = HaughtonLeveling
}

View File

@@ -1,18 +0,0 @@
--!optimize 2
--!native
--!strict
local Leveling: {number} = {
[1] = 13.041,
[2] = 37.973,
[3] = 62.978,
[4] = 87.968,
[5] = 112.952,
[6] = 137.988,
[7] = 163.009,
[8] = 188.007,
[9] = 213.058,
[10] = 239.245,
}
return Leveling

View File

@@ -11,8 +11,8 @@ local Enums = require(StorageService:WaitForChild("Enums"))
local InitElevator = require(ParentDir:WaitForChild("InitElevator")) local InitElevator = require(ParentDir:WaitForChild("InitElevator"))
local TagsModule = require(MainDir:WaitForChild("Load"):WaitForChild("Tags")) local TagsModule = require(MainDir:WaitForChild("Load"):WaitForChild("Tags"))
local ElevatorConfigurationTable = require(script:WaitForChild("Config")) local ElevatorConfigurationTable = require(ParentDir:WaitForChild("Config"))
local FloorLevelingPositions = require(script:WaitForChild("Leveling")) 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
@@ -32,12 +32,11 @@ local FloorLevelingPositions = require(script:WaitForChild("Leveling"))
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags) return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
local ElevatorBoxModel = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation local ElevatorBoxModel = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
local Elevator = InitElevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, FloorLevelingPositions) local Elevator = InitElevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable.Otis1960Configuration, FloorLevelingPositions)
Elevator.Events.Progression:Connect(function(PreviousFloor: number, CurrentFloor: number, NextFloor: number) Elevator.Events.Progression:Connect(function(PreviousFloor: number, CurrentFloor: number, NextFloor: number)
print(CurrentFloor) print(CurrentFloor)
end) end)
Elevator.Attributes.Goal:GetPropertyChangedSignal("Value"):Connect(function() Elevator.Attributes.Goal:GetPropertyChangedSignal("Value"):Connect(function()
print("Goal=", Elevator.Attributes.Goal.Value) print("Goal=", Elevator.Attributes.Goal.Value)
end) end)
@@ -46,14 +45,6 @@ return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsMod
task.spawn(function() task.spawn(function()
Elevator:RequestLevelAsync(2, Enums.ElevatorCallDirection.Up) Elevator:RequestLevelAsync(2, Enums.ElevatorCallDirection.Up)
end) end)
task.spawn(function()
Elevator:RequestLevelAsync(3, Enums.ElevatorCallDirection.Down)
end)
task.spawn(function()
Elevator:RequestLevelAsync(4, Enums.ElevatorCallDirection.Up)
end)
task.spawn(function()
Elevator:RequestLevelAsync(5, Enums.ElevatorCallDirection.Down)
end)
print(Elevator.RelayAlgorithm.FloorQueue.Up) print(Elevator.RelayAlgorithm.FloorQueue.Up)
end end