mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-15 21:51:55 +00:00
work on lanterns, doors now properly open
This commit is contained in:
@@ -116,10 +116,10 @@ local function DoorsAnimationFloor(FloorDoors: {Instance?}, Floor: number, openi
|
||||
|
||||
if not (init_floors_closed[Floor] :: {})[1] and not (init_floors_closed[Floor] :: {})[2] then
|
||||
if FloorDoor1_P then
|
||||
(init_floors_closed[Floor] :: {})[1] = FloorDoor1_P+Doors.Door1Stopped_X
|
||||
(init_floors_closed[Floor] :: {})[1] = FloorDoor1_P-Doors.Door1Stopped_X
|
||||
end
|
||||
if FloorDoor2_P then
|
||||
(init_floors_closed[Floor] :: {})[2] = FloorDoor2_P+Doors.Door2Stopped_X
|
||||
(init_floors_closed[Floor] :: {})[2] = FloorDoor2_P-Doors.Door2Stopped_X
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -175,7 +175,7 @@ local function ElevatorDoorsAnimation(self: ClassConstructor, opening: boolean?,
|
||||
if opening then
|
||||
--This is mega cringe but the doors can open while the elevator is moving now
|
||||
local StartTime = os.clock()
|
||||
local Timing = 2
|
||||
local Timing = Doors.ElevatorDoorTime-1
|
||||
|
||||
while task.wait() do
|
||||
local Time = math.clamp((os.clock()-StartTime)/Timing, 0, 1)
|
||||
@@ -184,19 +184,18 @@ local function ElevatorDoorsAnimation(self: ClassConstructor, opening: boolean?,
|
||||
local Door1Vector = Vector3.new(ElevatorDoor1_P.X, 0, ElevatorDoor1_P.Z)
|
||||
local Door2Vector = Vector3.new(ElevatorDoor2_P.X, 0, ElevatorDoor2_P.Z)
|
||||
|
||||
self.ElevatorDoor1.Position = ElevatorBoxY+ElevatorDoor1_P:Lerp(Door1Vector+Doors.Door1Stopped_X, Time)
|
||||
self.ElevatorDoor2.Position = ElevatorBoxY+ElevatorDoor2_P:Lerp(Door2Vector+Doors.Door2Stopped_X, Time)
|
||||
self.ElevatorDoor1.Position = ElevatorBoxY+Door1Vector:Lerp(Door1Vector-Doors.Door1Stopped_X, Time)
|
||||
self.ElevatorDoor2.Position = ElevatorBoxY+Door2Vector:Lerp(Door2Vector-Doors.Door2Stopped_X, Time)
|
||||
|
||||
if Time>=1 then
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
|
||||
local TweenTime = activated_via_censor and sensor_opening_speed or opening and opening_speed or Doors.ElevatorDoorTime
|
||||
|
||||
local Door1Tween = self.DoorTween1:Start(nil, {
|
||||
Position = ElevatorDoor1_P-Doors.Door1Stopped_X
|
||||
Position = ElevatorDoor1_P+Doors.Door1Stopped_X
|
||||
}, TweenInfo.new(
|
||||
TweenTime,
|
||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
||||
@@ -204,7 +203,7 @@ local function ElevatorDoorsAnimation(self: ClassConstructor, opening: boolean?,
|
||||
))
|
||||
|
||||
local Door2Tween = self.DoorTween2:Start(nil, {
|
||||
Position = ElevatorDoor2_P-Doors.Door2Stopped_X
|
||||
Position = ElevatorDoor2_P+Doors.Door2Stopped_X
|
||||
}, TweenInfo.new(
|
||||
TweenTime,
|
||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
||||
@@ -216,15 +215,13 @@ local function ElevatorDoorsAnimation(self: ClassConstructor, opening: boolean?,
|
||||
end
|
||||
Doors.__DontLeakMemory = self:__DetectSensorHit(Door1Tween, Door2Tween)
|
||||
|
||||
if not opening then
|
||||
--Door clicking noise
|
||||
task.delay(Doors.ElevatorDoorTime-.90, function()
|
||||
--is the door close enough to closing?
|
||||
if (ElevatorDoor2_P+Doors.Door2Stopped_X).X-self.ElevatorDoor2.Position.X>5 then
|
||||
self.DoorClosingClick:Play()
|
||||
end
|
||||
end)
|
||||
end
|
||||
--Door clicking noise
|
||||
task.delay(Doors.ElevatorDoorTime-.90, function()
|
||||
--is the door close enough to closing?
|
||||
if (Doors.Door2Stopped_X-ElevatorDoor2_P).X-self.ElevatorDoor2.Position.X>10 then
|
||||
self.DoorClosingClick:Play()
|
||||
end
|
||||
end)
|
||||
|
||||
return Door2Tween
|
||||
end
|
||||
@@ -285,7 +282,10 @@ function Doors:ToggleElevatorDoors(opening, floor)
|
||||
end
|
||||
end
|
||||
|
||||
local FloorDoors = DoorsAnimationFloor(self.FloorDoorsTags[floor], floor, opening)
|
||||
local FloorDoorsObjects = self.FloorDoorsTags[floor]
|
||||
if FloorDoorsObjects then
|
||||
DoorsAnimationFloor(FloorDoorsObjects, floor, opening)
|
||||
end
|
||||
local Door2Tween = ElevatorDoorsAnimation(self, opening)
|
||||
|
||||
if Door2Tween then
|
||||
@@ -294,7 +294,7 @@ function Doors:ToggleElevatorDoors(opening, floor)
|
||||
self.ElevatorDoor1.CanCollide = true
|
||||
self.ElevatorDoor2.CanCollide = true
|
||||
|
||||
if Doors.__DontLeakMemory then
|
||||
if Doors.__DontLeakMemory and Doors.__DontLeakMemory.Connected then
|
||||
Doors.__DontLeakMemory:Disconnect()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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)}`)
|
||||
|
||||
Reference in New Issue
Block a user