mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
Idk, some bug with floors equaling each other and CurrentFloor+=1 or -=1 continues counting in the loop.
Hopefully brain work tomorrow
This commit is contained in:
@@ -189,11 +189,11 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo
|
|||||||
}, Elevator)
|
}, Elevator)
|
||||||
|
|
||||||
RelayAlgorithmConstructor.Events.Sorted:Connect(function(AddedFloorDirection: Enums.ElevatorCallDirectionValues, FloorDirectionQueue: RelayAlgorithm.FloorDirectionQueue)
|
RelayAlgorithmConstructor.Events.Sorted:Connect(function(AddedFloorDirection: Enums.ElevatorCallDirectionValues, FloorDirectionQueue: RelayAlgorithm.FloorDirectionQueue)
|
||||||
if AddedFloorDirection == ElevatorClass.Elevator.TravelingDirection then
|
if AddedFloorDirection == (ElevatorClass.Attributes.TravelingUpwards.Value and Enums.ElevatorCallDirection.Up or Enums.ElevatorCallDirection.Down) then
|
||||||
local NextFloorAsTraveling = FloorDirectionQueue[1]
|
local NextFloorAsTraveling = FloorDirectionQueue[1]
|
||||||
if NextFloorAsTraveling then
|
if NextFloorAsTraveling then
|
||||||
local Level = FloorLevelingPositions[NextFloorAsTraveling]
|
local Level = FloorLevelingPositions[NextFloorAsTraveling]
|
||||||
ElevatorClass:__TravelToFloorAsync(Level, Vector3.new(0, Level, 0), AddedFloorDirection)
|
ElevatorClass:__TravelToFloorAsync(Level, Vector3.new(0, Level, 0))
|
||||||
end
|
end
|
||||||
ElevatorClass.eprintStudio(`Floors sorted in proceeding direction. direction={AddedFloorDirection}, FloorDirectionQueue={FloorDirectionQueue}`)
|
ElevatorClass.eprintStudio(`Floors sorted in proceeding direction. direction={AddedFloorDirection}, FloorDirectionQueue={FloorDirectionQueue}`)
|
||||||
end
|
end
|
||||||
@@ -222,8 +222,8 @@ local function CheckFloorQueue(self: ClassConstructor)
|
|||||||
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
|
||||||
|
|
||||||
if DirectionToOppositeDirectionQueue[1] ~= self.Attributes.CurrentFloor.Value then
|
if DirectionToDirectionQueue[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])
|
self.ewarn("The floor queue first index did not match the elevator's current floor, CurrentFloor=", self.Attributes.CurrentFloor.Value, "FloorQueue[1]=", DirectionToDirectionQueue[1])
|
||||||
end
|
end
|
||||||
|
|
||||||
table.remove(DirectionToDirectionQueue, 1)
|
table.remove(DirectionToDirectionQueue, 1)
|
||||||
@@ -291,7 +291,6 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC
|
|||||||
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()
|
||||||
CheckFloorQueue(self);
|
CheckFloorQueue(self);
|
||||||
|
|
||||||
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -317,7 +316,6 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC
|
|||||||
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()
|
||||||
CheckFloorQueue(self);
|
CheckFloorQueue(self);
|
||||||
|
|
||||||
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -366,6 +364,8 @@ function Elevator:RequestLevelAsync(RequestedLevel, Direction)
|
|||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
local DirectionQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down
|
local DirectionQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down
|
||||||
|
-- local OppositeQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Down or self.RelayAlgorithm.FloorQueue.Up
|
||||||
|
|
||||||
self.RelayAlgorithm:AddFloor(Direction :: Enums.ElevatorCallDirectionValues, RequestedLevel)
|
self.RelayAlgorithm:AddFloor(Direction :: Enums.ElevatorCallDirectionValues, RequestedLevel)
|
||||||
if #DirectionQueue == 1 then
|
if #DirectionQueue == 1 then
|
||||||
self:__TravelToFloorAsync(RequestedLevel, Level)
|
self:__TravelToFloorAsync(RequestedLevel, Level)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ ElevatorConfiguration.LevelingVelocity = 2
|
|||||||
ElevatorConfiguration.Phase3LevelingVelocity = .5
|
ElevatorConfiguration.Phase3LevelingVelocity = .5
|
||||||
|
|
||||||
ElevatorConfiguration.Functions = {
|
ElevatorConfiguration.Functions = {
|
||||||
ManualTravelStart = true
|
ManualTravelStart = false
|
||||||
}
|
}
|
||||||
|
|
||||||
ElevatorConfiguration.Sounds = {
|
ElevatorConfiguration.Sounds = {
|
||||||
|
|||||||
@@ -38,14 +38,22 @@ return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsMod
|
|||||||
print(CurrentFloor)
|
print(CurrentFloor)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Elevator.Attributes.Goal:GetPropertyChangedSignal("Value"):Connect(function()
|
||||||
|
print("Goal=", Elevator.Attributes.Goal.Value)
|
||||||
|
end)
|
||||||
|
|
||||||
task.wait(1)
|
task.wait(1)
|
||||||
task.spawn(function()
|
task.spawn(function()
|
||||||
Elevator:RequestLevelAsync(2, Enums.ElevatorCallDirection.Down)
|
Elevator:RequestLevelAsync(2, Enums.ElevatorCallDirection.Up)
|
||||||
end)
|
end)
|
||||||
Elevator:StartTraveling()
|
|
||||||
Elevator.Events.Parked:Wait()
|
|
||||||
task.spawn(function()
|
task.spawn(function()
|
||||||
Elevator:RequestLevelAsync(1, Enums.ElevatorCallDirection.Up)
|
Elevator:RequestLevelAsync(3, Enums.ElevatorCallDirection.Down)
|
||||||
end)
|
end)
|
||||||
Elevator:StartTraveling()
|
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)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user