Relays are broken

This commit is contained in:
2024-05-27 02:36:28 -04:00
parent 54d6358751
commit 1d8f684393
4 changed files with 86 additions and 65 deletions

View File

@@ -15,10 +15,14 @@ type Impl_Constructor = {
type Constructor_Fun = (BoxAlignPosition: AlignPosition, ElevatorAttributes: ElevatorAttributes, DoorAttributes: DoorAttributes) -> ClassConstructor
type Constructor_Return_Props = {
BoxAlignPosition: AlignPosition,
BoxAlignPosition: AlignPosition,
ElevatorAttributes: ElevatorAttributes,
DoorAttributes: DoorAttributes,
__FloorQueue: {number}
DoorAttributes: DoorAttributes,
__FloorQueue: FloorQueue,
Events: {
Sorted: BindableEvent
}
}
type ElevatorAttributes = {
@@ -33,6 +37,8 @@ type DoorAttributes = {
}
}
export type FloorQueue = {number?}
export type RelayAlgorithmConstructor = ClassConstructor
local RelayAlgorithm = {} :: Impl_Constructor
@@ -40,10 +46,13 @@ RelayAlgorithm.__index = RelayAlgorithm
function RelayAlgorithm.constructor(BoxAlignPosition, ElevatorAttributes, DoorAttributes)
return setmetatable({
Events = {
Sorted = Instance.new("BindableEvent")
},
BoxAlignPosition = BoxAlignPosition,
ElevatorAttributes = ElevatorAttributes,
DoorAttributes = DoorAttributes,
__FloorQueue = {}
__FloorQueue = {},
}, RelayAlgorithm)
end
@@ -51,14 +60,14 @@ end
--https://youtu.be/BCN9mQOT3RQ
function RelayAlgorithm:Sort(ElevatorGoingUp)
table.sort(self.__FloorQueue, function(a: number, b: number): boolean
table.sort(self.__FloorQueue, function(a, b): boolean
if ElevatorGoingUp then
return a<b
else
return a>b
end
end)
print(table.unpack(self.__FloorQueue))
self.Events.Sorted:Fire(self.__FloorQueue)
end
function RelayAlgorithm:Check(ElevatorGoingUp)