work on door opening possibility while the elevator is stopped

This commit is contained in:
2024-05-25 01:06:48 -04:00
parent 61153b53e1
commit c9f0074217
7 changed files with 119 additions and 75 deletions

View File

@@ -3,9 +3,10 @@
--!strict
local RelayAlgorithmModule = require(script.Parent:WaitForChild("RelayAlgorithm"))
local DoorsModule = require(script.Parent:WaitForChild("Doors"))
type Leveling = {
Leveling: {number},
Leveling: {number},
LevelingBetween: {number}
}
type ElevatorBox = BasePart
@@ -34,10 +35,12 @@ type Constructor_Return_Props = {
BoxAlignPosition: BoxAlignPosition,
ElevatorBox: ElevatorBox,
__ReadyConnection: RBXScriptConnection?,
__OpenConnection: RBXScriptConnection?,
__GoalYLevelConnection: RBXScriptConnection?,
__GoalConnection: RBXScriptConnection?,
__Connections: {
Ready: RBXScriptConnection?,
Open: RBXScriptConnection?,
GoalYLevel: RBXScriptConnection?,
Goal: RBXScriptConnection?
}
}
type ElevatorAttributes = {
@@ -50,11 +53,7 @@ type ElevatorAttributes = {
Stopped: BoolValue
}
type DoorAttributes = {
Relay: {
Open: BoolValue
}
}
type DoorAttributes = DoorsModule.RelayAttributes
export type RelayConstructor = ClassConstructor
@@ -68,7 +67,9 @@ function Relay.constructor(RelayAlgorthm, ElevatorAttributes, DoorAttributes, Le
DoorAttributes = DoorAttributes,
LevelingModule = LevelingModule,
BoxAlignPosition = BoxAlignPosition,
ElevatorBox = ElevatorBox
ElevatorBox = ElevatorBox,
__Connections = {}
}, Relay)
end
@@ -101,25 +102,25 @@ function Relay:__Goal()
end
function Relay:BulkConnect()
self.__ReadyConnection = self.ElevatorAttributes.Relay.Ready:GetPropertyChangedSignal("Value"):Connect(function()
self.__Connections.Ready = self.ElevatorAttributes.Relay.Ready:GetPropertyChangedSignal("Value"):Connect(function()
if not self.ElevatorAttributes.Stopped.Value then
self:__Ready()
end
end)
self.__OpenConnection = self.DoorAttributes.Relay.Open:GetPropertyChangedSignal("Value"):Connect(function()
self.__Connections.Open = self.DoorAttributes.Relay.Open:GetPropertyChangedSignal("Value"):Connect(function()
if not self.ElevatorAttributes.Stopped.Value then
self:__Open()
end
end)
self.__GoalYLevelConnection = self.ElevatorAttributes.Relay.GoalYLevel:GetPropertyChangedSignal("Value"):Connect(function()
self.__Connections.GoalYLevel = self.ElevatorAttributes.Relay.GoalYLevel:GetPropertyChangedSignal("Value"):Connect(function()
if not self.ElevatorAttributes.Stopped.Value then
self:__GoalYLevel()
end
end)
self.__GoalConnection = self.ElevatorAttributes.Relay.Goal:GetPropertyChangedSignal("Value"):Connect(function()
self.__Connections.Goal = self.ElevatorAttributes.Relay.Goal:GetPropertyChangedSignal("Value"):Connect(function()
if not self.ElevatorAttributes.Stopped.Value then
self:__Goal()
end
@@ -127,17 +128,17 @@ function Relay:BulkConnect()
end
function Relay:BulkDisconnect()
if self.__ReadyConnection and self.__ReadyConnection.Connected then
self.__ReadyConnection:Disconnect()
if self.__Connections.Ready and self.__Connections.Ready.Connected then
self.__Connections.Ready:Disconnect()
end
if self.__OpenConnection and self.__OpenConnection.Connected then
self.__OpenConnection:Disconnect()
if self.__Connections.Open and self.__Connections.Open.Connected then
self.__Connections.Open:Disconnect()
end
if self.__GoalYLevelConnection and self.__GoalYLevelConnection.Connected then
self.__GoalYLevelConnection:Disconnect()
if self.__Connections.GoalYLevel and self.__Connections.GoalYLevel.Connected then
self.__Connections.GoalYLevel:Disconnect()
end
if self.__GoalConnection and self.__GoalConnection.Connected then
self.__GoalConnection:Disconnect()
if self.__Connections.Goal and self.__Connections.Goal.Connected then
self.__Connections.Goal:Disconnect()
end
end