diff --git a/src/server/main/Elevators/InitElevator/RelayAlgorithm.luau b/src/server/main/Elevators/InitElevator/RelayAlgorithm.luau index a18e5e9..78d8911 100644 --- a/src/server/main/Elevators/InitElevator/RelayAlgorithm.luau +++ b/src/server/main/Elevators/InitElevator/RelayAlgorithm.luau @@ -90,7 +90,6 @@ end function RelayAlgorithm:AddFloor(Direction, RequestedLevel) table.insert(Direction == Enums.ElevatorCallDirection.Up and self.FloorQueue.Up or self.FloorQueue.Down, RequestedLevel) self.Events.__eventInstances__.Added:Fire(Direction, RequestedLevel) - self:Sort(Direction :: Enums.ElevatorCallDirectionValues) end return RelayAlgorithm diff --git a/src/server/main/Elevators/InitElevator/init.luau b/src/server/main/Elevators/InitElevator/init.luau index 0cd69fc..19551f0 100644 --- a/src/server/main/Elevators/InitElevator/init.luau +++ b/src/server/main/Elevators/InitElevator/init.luau @@ -11,6 +11,7 @@ local StorageService = game:GetService("ReplicatedStorage") local Enums = require(StorageService:WaitForChild("Enums")) local Out = require(StorageService:WaitForChild("Output")) +local Algebra = require(StorageService:WaitForChild("Algebra")) local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator")) local Tags = require(LoadDir:WaitForChild("Tags")) local RelayAlgorithm = require(script:WaitForChild("RelayAlgorithm")) @@ -23,9 +24,10 @@ type Impl_Constructor = { __index: Impl_Constructor, constructor: Constructor_Fun, --Class functions - GetLevel: (self: ClassConstructor, Level: number, Direction: Enums.ElevatorCallDirectionValues) -> Vector3?, - RequestLevel: (self: ClassConstructor, RequestedLevel: number, Direction: Enums.ElevatorCallDirectionValues) -> boolean, - __TravelToFloor: (self: ClassConstructor, LevelInt: number, VEC3_Y_WRAP: Vector3, Direction: Enums.ElevatorCallDirectionValues) -> (), + GetLevel: (self: ClassConstructor, Level: number) -> Vector3?, + RequestLevelAsync: (self: ClassConstructor, RequestedLevel: number, Direction: Enums.ElevatorCallDirectionValues) -> boolean, + StartTraveling: (self: ClassConstructor) -> (), + __TravelToFloorAsync: (self: ClassConstructor, LevelInt: number, VEC3_Y_WRAP: Vector3) -> (), } type FloorLevelingPositions = {number} @@ -37,6 +39,7 @@ type Constructor_Return_Props = { eprint: (T...) -> (), ewarn: (T...) -> (), eprintStudio: (T...) -> (), + ewarnStudio: (T...) -> (), Elevator: { TravelingDirection: Enums.ElevatorCallDirectionValues, @@ -53,20 +56,22 @@ type Constructor_Return_Props = { Stopped: BoolValue }, Events: { - CabProgression: RBXScriptSignal, - CabTraveling: RBXScriptSignal, + Progression: RBXScriptSignal, + Traveling: RBXScriptSignal, Parked: RBXScriptSignal, Leveling: RBXScriptSignal, Leveling3Phase: RBXScriptSignal, __eventInstances__: { - CabProgression: BindableEvent, - CabTraveling: BindableEvent, + Progression: BindableEvent, + Traveling: BindableEvent, Parked: BindableEvent, Leveling: BindableEvent, Leveling3Phase: BindableEvent, } }, - + __functionEvents: { + StartTraveling: BindableEvent + }, __Connections: { Moving: RBXScriptConnection?, } @@ -119,6 +124,10 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo local function eprintStudio(...: T...) Out.printStudio(`[{ElevatorConfigurationTable.Name}]:`, ...) end + local function ewarnStudio(...: T...) + Out.warnStudio(`[{ElevatorConfigurationTable.Name}]:`, ...) + end + local _BoxAttachment, BoxAlignPosition, _BoxAlignOrientation = Mover(ElevatorBoxModel, ElevatorConfigurationTable.Responsiveness, ElevatorConfigurationTable.MaxVelocity) @@ -150,6 +159,7 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo eprint = eprint, ewarn = ewarn, eprintStudio = eprintStudio, + ewarnStudio = ewarnStudio, Elevator = { TravelingDirection = Enums.ElevatorCallDirection.Up, @@ -158,20 +168,23 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo Configuration = ElevatorConfigurationTable, }, Events = { - CabProgression = CabProgression.Event, - CabTraveling = CabTraveling.Event, + Progression = CabProgression.Event, + Traveling = CabTraveling.Event, Parked = Parked.Event, Leveling = Leveling.Event, Leveling3Phase = Leveling3Phase.Event, __eventInstances__ = { - CabProgression = CabProgression, - CabTraveling = CabTraveling, + Progression = CabProgression, + Traveling = CabTraveling, Parked = Parked, Leveling = Leveling, Leveling3Phase = Leveling3Phase, } }, Attributes = Attributes, + __functionEvents = { + StartTraveling = Instance.new("BindableEvent") :: BindableEvent + }, __Connections = {} }, Elevator) @@ -180,7 +193,7 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo local NextFloorAsTraveling = FloorDirectionQueue[1] if NextFloorAsTraveling then local Level = FloorLevelingPositions[NextFloorAsTraveling] - ElevatorClass:__TravelToFloor(Level, Vector3.new(0, Level, 0), AddedFloorDirection) + ElevatorClass:__TravelToFloorAsync(Level, Vector3.new(0, Level, 0), AddedFloorDirection) end ElevatorClass.eprintStudio(`Floors sorted in proceeding direction. direction={AddedFloorDirection}, FloorDirectionQueue={FloorDirectionQueue}`) end @@ -190,88 +203,94 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo return ElevatorClass end -local function ProceedToNextLevel(self: ClassConstructor, Level: number, Direction: Enums.ElevatorCallDirectionValues): Vector3? - local VEC3_Y_WRAP = self:GetLevel(Level, Direction) +local function ProceedToNextLevel(self: ClassConstructor, Level_Int: number): Vector3? + local VEC3_Y_WRAP = self:GetLevel(Level_Int) if VEC3_Y_WRAP then - self:__TravelToFloor(Level, VEC3_Y_WRAP, Direction) - self.eprintStudio(`Traveling to Level={Level} VEC3_Y_WRAP={VEC3_Y_WRAP} Direct={Direction}`) + self:__TravelToFloorAsync(Level_Int, VEC3_Y_WRAP) + self.eprintStudio(`Traveling to Level={Level_Int} VEC3_Y_WRAP={VEC3_Y_WRAP}`) else - self.ewarn(`Failed to get the requested level's Y position. VEC3_Y_WRAP={VEC3_Y_WRAP} Level={Level} Direction={Direction}`) + self.ewarn(`Failed to get the requested level's Y position. VEC3_Y_WRAP={VEC3_Y_WRAP} Level={Level_Int}`) end return VEC3_Y_WRAP end -local function CheckFloorQueue(self: ClassConstructor, Direction: Enums.ElevatorCallDirectionValues) - local DirectionFloorQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down +local function GoingUpDirectionToDirectionEnum(CurrentFloor: number, RequestedFloor: number): Enums.ElevatorCallDirectionValues + return ElevatorGoingUpDirection(CurrentFloor, RequestedFloor) and Enums.ElevatorCallDirection.Up or Enums.ElevatorCallDirection.Down +end - if DirectionFloorQueue[1] ~= self.Attributes.CurrentFloor.Value then - self.ewarn("The floor queue first index did not match the elevator's current floor, CurrentFloor=", self.Attributes.CurrentFloor.Value, "FloorQueue[1]=", DirectionFloorQueue[1]) +local function CheckFloorQueue(self: ClassConstructor) + 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 + + if DirectionToOppositeDirectionQueue[1] ~= self.Attributes.CurrentFloor.Value then + self.ewarn("The floor queue first index did not match the elevator's current floor, CurrentFloor=", self.Attributes.CurrentFloor.Value, "FloorQueue[1]=", DirectionToOppositeDirectionQueue[1]) end - table.remove(DirectionFloorQueue, 1) - self.RelayAlgorithm:Sort(Direction) - self.eprintStudio("Checking more floors in direction queue. Direction=", Direction, "DirectionFloorQueue=", DirectionFloorQueue) - local NextFloorInQueue = DirectionFloorQueue[1] + table.remove(DirectionToDirectionQueue, 1) + local IdenticalOpposite = table.find(DirectionToOppositeDirectionQueue, self.Attributes.CurrentFloor.Value) + if IdenticalOpposite then + table.remove(DirectionToOppositeDirectionQueue, IdenticalOpposite) + self.eprintStudio(`Removed the current floor from the opposite direction, ElevatorTravelingUpwards={self.Attributes.TravelingUpwards.Value} CurrentFloor={self.Attributes.CurrentFloor.Value}`) + end + + self.eprintStudio("Checking more floors in direction queue. DirectionToDirectionQueue=", DirectionToDirectionQueue) + + local NextFloorInQueue = DirectionToOppositeDirectionQueue[1] if NextFloorInQueue then - local ProceedingToTheNextLevel = ProceedToNextLevel(self, NextFloorInQueue, Direction) + local NewDirection = GoingUpDirectionToDirectionEnum(self.Attributes.CurrentFloor.Value, NextFloorInQueue) + self.RelayAlgorithm:Sort(NewDirection :: Enums.ElevatorCallDirectionValues) + + local ProceedingToTheNextLevel = ProceedToNextLevel(self, NextFloorInQueue) if not ProceedingToTheNextLevel then self.RelayAlgorithm:Sort(Enums.ElevatorCallDirection.Down) - ProceedToNextLevel(self, 1, Enums.ElevatorCallDirection.Down) + ProceedToNextLevel(self, 1) end else --No more floors in the current direction? --Check the opposite - self.eprintStudio(`No more floors in the direction "{Direction}" checking the opposite direction floors`) - if Direction == Enums.ElevatorCallDirection.Up then - if #self.RelayAlgorithm.FloorQueue.Down ~= 0 then - local NextLevelDown = self.RelayAlgorithm.FloorQueue.Down[1] - if NextLevelDown then - local NewDirection = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, NextLevelDown) and Enums.ElevatorCallDirection.Up or Enums.ElevatorCallDirection.Down - self.RelayAlgorithm:Sort(NewDirection :: Enums.ElevatorCallDirectionValues) - self.eprint("Floors found in the opposite direction. Direction=", Enums.ElevatorCallDirection.Down, "NextLevel=", NextLevelDown) - ProceedToNextLevel(self, NextLevelDown, Enums.ElevatorCallDirection.Down) - end - end - else - if #self.RelayAlgorithm.FloorQueue.Up ~= 0 then - local NextLevelUp = self.RelayAlgorithm.FloorQueue.Up[1] - if NextLevelUp then - local NewDirection = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, NextLevelUp) and Enums.ElevatorCallDirection.Up or Enums.ElevatorCallDirection.Down - self.RelayAlgorithm:Sort(NewDirection :: Enums.ElevatorCallDirectionValues) - self.eprint("Floors found in the opposite direction. Direction=", Enums.ElevatorCallDirection.Up, "NextLevel=", NextLevelUp) - ProceedToNextLevel(self, NextLevelUp, Enums.ElevatorCallDirection.Up) - end + self.eprintStudio(`No more floors in the direction TravelingUpwards="{self.Attributes.TravelingUpwards.Value}" checking the opposite direction floors`) + if #DirectionToOppositeDirectionQueue ~= 0 then + local NextLevelOpposite = DirectionToOppositeDirectionQueue[1] + if NextLevelOpposite then + local NewDirection = GoingUpDirectionToDirectionEnum(self.Attributes.CurrentFloor.Value, NextLevelOpposite) + self.RelayAlgorithm:Sort(NewDirection :: Enums.ElevatorCallDirectionValues) + self.eprint("Floors found in the opposite direction. Direction=", Enums.ElevatorCallDirection.Down, "NextLevel=", NextLevelOpposite) + ProceedToNextLevel(self, NextLevelOpposite) end end end end -local function CabTraveling(self: ClassConstructor, deltaTime: number, VEC3_Y_WRAP: Vector3, Direction: Enums.ElevatorCallDirectionValues, ElevatorTravelingUpwards: boolean) - local ElevatorPosition = self.Elevator.BoxModel.Position - local AtFloorY = self.FloorLevelingPositions[ElevatorTravelingUpwards and self.Attributes.CurrentFloor.Value+1 or self.Attributes.CurrentFloor.Value-1] +local function FloorsClamp(self: ClassConstructor, n: number): number + return Algebra.minmax(1, n, #self.FloorLevelingPositions) +end - if ElevatorTravelingUpwards then +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 self.Attributes.PreviousFloor.Value = self.Attributes.CurrentFloor.Value self.Attributes.CurrentFloor.Value+=1 - self.Attributes.NextFloor.Value = math.clamp(1, self.Attributes.CurrentFloor.Value+1, #self.FloorLevelingPositions) + self.Attributes.NextFloor.Value = FloorsClamp(self, self.Attributes.CurrentFloor.Value+1) - self.Events.__eventInstances__.CabProgression:Fire(self.Attributes.PreviousFloor.Value, self.Attributes.CurrentFloor.Value, self.Attributes.NextFloor.Value) + self.Events.__eventInstances__.Progression:Fire(self.Attributes.PreviousFloor.Value, self.Attributes.CurrentFloor.Value, self.Attributes.NextFloor.Value) end --Elevator is riding upwards towards the destination - if ElevatorPosition.Y>=VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLevelingDistance then + 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 ElevatorPosition.Y>=VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLeveling3PhaseDistance then + 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 ElevatorPosition.Y>=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() - CheckFloorQueue(self, Direction); + CheckFloorQueue(self); (self.__Connections.Moving :: RBXScriptConnection):Disconnect() end @@ -281,23 +300,23 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, VEC3_Y_WR if ElevatorPosition.Y<=AtFloorY+self.Elevator.Configuration.FloorLevelingDistance then self.Attributes.PreviousFloor.Value = self.Attributes.CurrentFloor.Value self.Attributes.CurrentFloor.Value-=1 - self.Attributes.NextFloor.Value = math.clamp(1, self.Attributes.CurrentFloor.Value-1, #self.FloorLevelingPositions) + self.Attributes.NextFloor.Value = FloorsClamp(self, self.Attributes.CurrentFloor.Value-1) - self.Events.__eventInstances__.CabProgression:Fire(self.Attributes.PreviousFloor.Value, self.Attributes.CurrentFloor.Value, self.Attributes.NextFloor.Value) + self.Events.__eventInstances__.Progression:Fire(self.Attributes.PreviousFloor.Value, self.Attributes.CurrentFloor.Value, self.Attributes.NextFloor.Value) end --Elevator is riding upwards towards the destination - if ElevatorPosition.Y<=VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLevelingDistance then + 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 ElevatorPosition.Y<=VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLeveling3PhaseDistance then + 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 ElevatorPosition.Y<=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() - CheckFloorQueue(self, Direction); + CheckFloorQueue(self); (self.__Connections.Moving :: RBXScriptConnection):Disconnect() end @@ -305,62 +324,61 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, VEC3_Y_WR end end - self.Events.__eventInstances__.CabTraveling:Fire(deltaTime, ElevatorPosition) + self.Events.__eventInstances__.Traveling:Fire(deltaTime, ElevatorPosition) end -function Elevator:GetLevel(LevelInt, Direction) - local Level = self.FloorLevelingPositions[LevelInt] +function Elevator:GetLevel(Level_Int) + local Level = self.FloorLevelingPositions[Level_Int] if Level then - --local VEC3_Y_WRAP_LOSSY = Vector3.yAxis*Level //lossy + --local VEC3_Y_WRAP_LOSSY = Vector3.yAxis*Level return Vector3.new(0, Level, 0) end return nil end -function Elevator:__TravelToFloor(LevelInt, VEC3_Y_WRAP, Direction) +function Elevator:__TravelToFloorAsync(Level_Int, LEVEL_VEC3_Y_WRAP) + if self.Elevator.Configuration.Functions.ManualTravelStart then + self.__functionEvents.StartTraveling.Event:Wait() + end if self.__Connections.Moving and self.__Connections.Moving.Connected then self.__Connections.Moving:Disconnect() end - local ElevatorTravelingUpwards = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, LevelInt) - self.Attributes.Goal.Value = LevelInt + local ElevatorTravelingUpwards = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, Level_Int) + self.Attributes.Goal.Value = Level_Int self.Attributes.TravelingUpwards.Value = ElevatorTravelingUpwards self.__Connections.Moving = RunService.Heartbeat:Connect(function(deltaTime: number) - CabTraveling(self, deltaTime, VEC3_Y_WRAP, Direction :: Enums.ElevatorCallDirectionValues, ElevatorTravelingUpwards) + 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, 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 self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.MaxVelocity end -function Elevator:RequestLevel(RequestedLevel, Direction) - local Level = self:GetLevel(RequestedLevel, Direction :: Enums.ElevatorCallDirectionValues) +function Elevator:RequestLevelAsync(RequestedLevel, Direction) + local Level = self:GetLevel(RequestedLevel) if Level then - if RequestedLevel ~= self.Attributes.CurrentFloor.Value then - if (RequestedLevel == 1 and Direction == Enums.ElevatorCallDirection.Down) or (RequestedLevel == #self.FloorLevelingPositions and Direction == Enums.ElevatorCallDirection.Up) then - self.ewarn(`Impossible direction requested, Direction={Direction}, RequestedLevel={Level}`) - return false - else - local DirectionQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down - self.RelayAlgorithm:AddFloor(Direction :: Enums.ElevatorCallDirectionValues, RequestedLevel) - - if #DirectionQueue == 1 then - self:__TravelToFloor(RequestedLevel, Level, Direction :: Enums.ElevatorCallDirectionValues) - end - end - else - self.ewarn(`The elevator is already at the requested floor. RequestLevel={RequestedLevel}, CurrentLevel={self.Attributes.CurrentFloor.Value}`) + if (RequestedLevel == 1 and Direction == Enums.ElevatorCallDirection.Down) or (RequestedLevel == #self.FloorLevelingPositions and Direction == Enums.ElevatorCallDirection.Up) then + self.ewarn(`Impossible direction requested, Direction={Direction}, RequestedLevel={Level}`) return false + else + local DirectionQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down + self.RelayAlgorithm:AddFloor(Direction :: Enums.ElevatorCallDirectionValues, RequestedLevel) + if #DirectionQueue == 1 then + self:__TravelToFloorAsync(RequestedLevel, Level) + end end return true end - self.ewarn(`Requested floor: "{RequestedLevel}" does not exist for this elevator`) return false end +function Elevator:StartTraveling() + self.__functionEvents.StartTraveling:Fire() +end + return Elevator diff --git a/src/server/main/Elevators/Otis1960/Config.luau b/src/server/main/Elevators/Otis1960/Config.luau index 75546ed..b467669 100644 --- a/src/server/main/Elevators/Otis1960/Config.luau +++ b/src/server/main/Elevators/Otis1960/Config.luau @@ -19,6 +19,10 @@ ElevatorConfiguration.MaxVelocity = 7 ElevatorConfiguration.LevelingVelocity = 2 ElevatorConfiguration.Phase3LevelingVelocity = .5 +ElevatorConfiguration.Functions = { + ManualTravelStart = true +} + ElevatorConfiguration.Sounds = { LanternChimeDirection = SoundEnums.Otis1960.LanternChimeDirection, LanternChimeLanding = SoundEnums.Otis1960.LanternChimeLanding diff --git a/src/server/main/Elevators/Otis1960/init.luau b/src/server/main/Elevators/Otis1960/init.luau index 354a12c..097e985 100644 --- a/src/server/main/Elevators/Otis1960/init.luau +++ b/src/server/main/Elevators/Otis1960/init.luau @@ -34,23 +34,18 @@ return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsMod local Elevator = InitElevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, FloorLevelingPositions) - Elevator.Events.CabTraveling:Connect(function(deltaTime: number, ElevatorPosition: Vector3) - - end) - Elevator.Events.CabProgression:Connect(function(PreviousFloor: number, CurrentFloor: number, NextFloor: number) + Elevator.Events.Progression:Connect(function(PreviousFloor: number, CurrentFloor: number, NextFloor: number) print(CurrentFloor) end) - Elevator.Events.Leveling:Connect(function() - - end) - Elevator.Events.Leveling3Phase:Connect(function() - - end) - Elevator.Events.Parked:Connect(function() - - end) task.wait(1) - Elevator:RequestLevel(10, Enums.ElevatorCallDirection.Down) - Elevator:RequestLevel(6, Enums.ElevatorCallDirection.Down) + task.spawn(function() + Elevator:RequestLevelAsync(2, Enums.ElevatorCallDirection.Down) + end) + Elevator:StartTraveling() + Elevator.Events.Parked:Wait() + task.spawn(function() + Elevator:RequestLevelAsync(1, Enums.ElevatorCallDirection.Up) + end) + Elevator:StartTraveling() end diff --git a/src/server/main/Types/Elevator.luau b/src/server/main/Types/Elevator.luau index 0313236..e67d7aa 100644 --- a/src/server/main/Types/Elevator.luau +++ b/src/server/main/Types/Elevator.luau @@ -15,6 +15,10 @@ export type ElevatorConfigurationTable = { ParkedDistance: number, LevelingVelocity: number, Phase3LevelingVelocity: number, + + Functions: { + ManualTravelStart: boolean, + }, Sounds: { LanternChimeDirection: SoundEnums.ElevatorSoundValues, LanternChimeLanding: SoundEnums.ElevatorSoundValues,