work on lanterns, doors now properly open

This commit is contained in:
2024-05-05 19:11:50 -04:00
parent 835e1da3ec
commit a06ade478a
5 changed files with 118 additions and 64 deletions

View File

@@ -41,6 +41,7 @@ type Impl_Static_Props = {
Responsiveness: number,
MaxVelocity: number,
ButtonActivatedColor: Color3,
ButtonDeactivatedColor: Color3,
LanternDisplayColorOn: Color3,
LanternDisplayColorOff: Color3,
LanternChimeDirection: rbxassetid,
@@ -90,6 +91,7 @@ Otis1960.LeveledDistance = 0.5
Otis1960.Responsiveness = 50
Otis1960.MaxVelocity = 10
Otis1960.ButtonActivatedColor = Color3.fromRGB(180,0,0)
Otis1960.ButtonDeactivatedColor = Color3.fromRGB(139,139,139)
Otis1960.LanternDisplayColorOn = Color3.fromRGB(255,114,71)
Otis1960.LanternDisplayColorOff = Color3.fromRGB(55,55,55)
Otis1960.LanternChimeDirection = "rbxassetid://16990287228"
@@ -111,10 +113,21 @@ local ButtonFunctions: ButtonFunctions = {
Prompt:AddHookTriggered(function(Player: Player)
if DecodedFloor then
local _ButtonThread = ButtonsConstructor:AestheticActivateButton(ButtonTree.Inst :: BasePart, false, Otis1960.ButtonActivatedColor)
self:GoToLevel(DecodedFloor)
task.spawn(function()
ButtonsConstructor:AestheticActivateButton(ButtonTree.Inst :: BasePart, Otis1960.ButtonActivatedColor)
if DecodedFloor == Otis1960.__CurrentFloor then
ButtonsConstructor:DeactivateButton(ButtonTree.Inst :: BasePart, Otis1960.ButtonDeactivatedColor)
end
end)
if DecodedFloor ~= Otis1960.__CurrentFloor then
self:GoToLevel(DecodedFloor)
end
end
end)
else
warn(`Otis1960: Failed to decode car button, ButtonName={ButtonName}`)
end
end,
@@ -205,7 +218,7 @@ local function FloorLeveled(self: ClassConstructor, RequestedLevel: number)
Otis1960.__CurrentFloor = RequestedLevel
self.BoxAlignPosition.MaxVelocity = Otis1960.MaxVelocity
self.LanternsConstructor:Reset()
self.LanternsConstructor:Reset(Otis1960.__CurrentFloor)
end
function Otis1960:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
@@ -238,7 +251,7 @@ function Otis1960:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
local ElevatorVelocityY: number = self.ElevatorBox_1960:GetVelocityAtPosition(ElevatorPosition).Y
self.MOConstructor:Frame_Pullies(Delta, ElevatorVelocityY)
self.TractionRopes:Move(26.3, ElevatorPosition)
self.TractionRopes:Move(27, ElevatorPosition)
--Kill the connection
if GoingUp then
@@ -257,6 +270,11 @@ function Otis1960:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
else
if ElevatorPositionY<=BoxAlignY+Otis1960.FloorLevelingDistance then
FloorLeveling(self, RequestedLevel)
if ElevatorPositionY>=BoxAlignY-Otis1960.DoorOpeningDistance and not DoorsOpeningEvent then
DoorsOpeningEvent = true
self.ElevatorDoors:ToggleElevatorDoors(true, RequestedLevel)
end
end
if ElevatorPositionY<=BoxAlignY+Otis1960.LeveledDistance then
@@ -273,6 +291,7 @@ function Otis1960:GoToLevel(RequestedLevel)
if GoalLevelVEC and GoalLevelVEC ~= 0 and GoalLevelVEC ~= Otis1960.__CurrentFloor then
local GoingUp: boolean = -(Otis1960.__CurrentFloor-RequestedLevel)>0 --My clever math function for determining if the elevator goal is to move upwards or not
self:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
else
warn(`[{Enums.Elevator.Otis1960}]: landing out of range or equals the same range as goal! requested landing: {tostring(RequestedLevel)}`)