mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
Restructure and get a working state for the Haughton elevator
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -18,7 +18,6 @@ end
|
|||||||
local UI = script:WaitForChild("UI")
|
local UI = script:WaitForChild("UI")
|
||||||
local CrosshairSettings = require(UI:WaitForChild("Crosshair"))
|
local CrosshairSettings = require(UI:WaitForChild("Crosshair"))
|
||||||
local VignetteSettings = require(UI:WaitForChild("Vignette"))
|
local VignetteSettings = require(UI:WaitForChild("Vignette"))
|
||||||
local HealthSettings = require(UI:WaitForChild("Health"))
|
|
||||||
local CoreGuis = require(script:WaitForChild("CoreGuis"))
|
local CoreGuis = require(script:WaitForChild("CoreGuis"))
|
||||||
local Mouse = require(script:WaitForChild("Mouse"))
|
local Mouse = require(script:WaitForChild("Mouse"))
|
||||||
local Character = require(script:WaitForChild("Character"))
|
local Character = require(script:WaitForChild("Character"))
|
||||||
@@ -84,7 +83,6 @@ CoreGuis:Off()
|
|||||||
Camera:FirstPerson()
|
Camera:FirstPerson()
|
||||||
Mouse:DisablePointer()
|
Mouse:DisablePointer()
|
||||||
Crosshair:Enable()
|
Crosshair:Enable()
|
||||||
HealthSettings:Enable()
|
|
||||||
|
|
||||||
CameraBinds()
|
CameraBinds()
|
||||||
Crosshair3DEffect()
|
Crosshair3DEffect()
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ type Scalar = {
|
|||||||
type GuiDependencies = {
|
type GuiDependencies = {
|
||||||
IntroGui: ScreenGui,
|
IntroGui: ScreenGui,
|
||||||
Frame: Frame,
|
Frame: Frame,
|
||||||
FrameGradient: UIGradient,
|
|
||||||
TextShadow: TextLabel,
|
TextShadow: TextLabel,
|
||||||
ShadowGradient: UIGradient,
|
ShadowGradient: UIGradient,
|
||||||
FrameworkText: TextLabel,
|
FrameworkText: TextLabel,
|
||||||
@@ -45,7 +44,6 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
|||||||
|
|
||||||
local Frame = IntroGui:WaitForChild("Frame") :: Frame
|
local Frame = IntroGui:WaitForChild("Frame") :: Frame
|
||||||
|
|
||||||
local FrameGradient = Frame:WaitForChild("UIGradient") :: UIGradient
|
|
||||||
local TextShadow = Frame:WaitForChild("TextShadow") :: TextLabel
|
local TextShadow = Frame:WaitForChild("TextShadow") :: TextLabel
|
||||||
local FrameworkText = Frame:WaitForChild("Framework") :: TextLabel
|
local FrameworkText = Frame:WaitForChild("Framework") :: TextLabel
|
||||||
local SandboxText = Frame:WaitForChild("Sandbox") :: TextLabel
|
local SandboxText = Frame:WaitForChild("Sandbox") :: TextLabel
|
||||||
@@ -63,7 +61,6 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
|||||||
return {
|
return {
|
||||||
IntroGui = IntroGui,
|
IntroGui = IntroGui,
|
||||||
Frame = Frame,
|
Frame = Frame,
|
||||||
FrameGradient = FrameGradient,
|
|
||||||
TextShadow = TextShadow,
|
TextShadow = TextShadow,
|
||||||
ShadowGradient = ShadowGradient,
|
ShadowGradient = ShadowGradient,
|
||||||
FrameworkText = FrameworkText,
|
FrameworkText = FrameworkText,
|
||||||
|
|||||||
@@ -32,8 +32,26 @@ Otis1960Configuration.Colors = {
|
|||||||
LanternDisplayOff = Color3.fromRGB(55,55,55),
|
LanternDisplayOff = Color3.fromRGB(55,55,55),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local HaughtonConfiguration = {} :: ElevatorTypes.ElevatorConfigurationTable
|
||||||
|
HaughtonConfiguration.Name = Enums.Elevator.Haughton
|
||||||
|
HaughtonConfiguration.FloorLevelingDistance = 4
|
||||||
|
HaughtonConfiguration.FloorLeveling3PhaseDistance = 1.5
|
||||||
|
HaughtonConfiguration.ParkedDistance = 0.2
|
||||||
|
HaughtonConfiguration.Responsiveness = 20
|
||||||
|
HaughtonConfiguration.MaxVelocity = 7
|
||||||
|
HaughtonConfiguration.LevelingVelocity = 2
|
||||||
|
HaughtonConfiguration.Phase3LevelingVelocity = .5
|
||||||
|
HaughtonConfiguration.Functions = {
|
||||||
|
ManualTravelStart = true
|
||||||
|
}
|
||||||
|
HaughtonConfiguration.Colors = {
|
||||||
|
ButtonActivated = Color3.fromRGB(180,0,0),
|
||||||
|
ButtonDeactivated = Color3.fromRGB(139,139,139),
|
||||||
|
LanternDisplayOn = Color3.fromRGB(44,255,157),
|
||||||
|
LanternDisplayOff = Color3.fromRGB(255,29,101),
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Otis1960Configuration = Otis1960Configuration
|
Otis1960Configuration = Otis1960Configuration,
|
||||||
|
HaughtonConfiguration = HaughtonConfiguration
|
||||||
}
|
}
|
||||||
@@ -1,282 +0,0 @@
|
|||||||
--!optimize 2
|
|
||||||
--!native
|
|
||||||
--!strict
|
|
||||||
|
|
||||||
local RS: RunService = game:GetService("RunService")
|
|
||||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
||||||
|
|
||||||
local Main = script.Parent.Parent.Parent
|
|
||||||
local Load = Main:WaitForChild("Load")
|
|
||||||
|
|
||||||
local Tween = require(Storage:WaitForChild("Tween"))
|
|
||||||
local Algebra = require(Storage:WaitForChild("Algebra"))
|
|
||||||
|
|
||||||
local Tags = require(Load:WaitForChild("Tags"))
|
|
||||||
local SoundEnums = require(Main:WaitForChild("Enums"):WaitForChild("Sounds"))
|
|
||||||
|
|
||||||
type DoorSensors = {
|
|
||||||
[string]: BasePart
|
|
||||||
}
|
|
||||||
|
|
||||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
|
||||||
type Impl_Constructor = {
|
|
||||||
__index: Impl_Constructor,
|
|
||||||
constructor: Constructor_Fun,
|
|
||||||
--Class functions
|
|
||||||
__DetectSensorHit: (self: ClassConstructor, DoorTween1: Tween, DoorTween2: Tween) -> RBXScriptConnection,
|
|
||||||
ToggleElevatorDoorsAsync: (self: ClassConstructor, opening: boolean, floor: number) -> ()
|
|
||||||
} & Impl_Static_Props
|
|
||||||
|
|
||||||
type Constructor_Fun = (FloorDoorsTags: Tags.LandingTags, ElevatorBox: BasePart, ElevatorDoor1: BasePart, ElevatorDoor2: BasePart, ElevatorDoorSensor: Folder) -> ClassConstructor
|
|
||||||
type Impl_Static_Props = {
|
|
||||||
Sensors: boolean,
|
|
||||||
Door1Stopped_X: Vector3,
|
|
||||||
Door2Stopped_X: Vector3,
|
|
||||||
ElevatorDoorTime: number,
|
|
||||||
ElevatorDoorStyle: Enum.EasingStyle,
|
|
||||||
__DoorSensors: RBXScriptConnection?,
|
|
||||||
|
|
||||||
Attributes: {} & RelayAttributes
|
|
||||||
}
|
|
||||||
|
|
||||||
type Constructor_Return_Props = {
|
|
||||||
FloorDoorsTags: Tags.LandingTags,
|
|
||||||
DoorSensor: DoorSensors,
|
|
||||||
ElevatorBox: BasePart,
|
|
||||||
ElevatorDoor1: BasePart,
|
|
||||||
ElevatorDoor2: BasePart,
|
|
||||||
DoorClosingClick: Sound
|
|
||||||
}
|
|
||||||
|
|
||||||
type Floor = number
|
|
||||||
type FloorDoors = {
|
|
||||||
[Floor]: {Vector3}?
|
|
||||||
}
|
|
||||||
|
|
||||||
export type RelayAttributes = {
|
|
||||||
Relay: {
|
|
||||||
Open: BoolValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type DoorConstructor = ClassConstructor
|
|
||||||
|
|
||||||
local Doors = {} :: Impl_Constructor
|
|
||||||
Doors.__index = Doors
|
|
||||||
|
|
||||||
Doors.Sensors = true
|
|
||||||
Doors.Door1Stopped_X = Vector3.xAxis*2.9
|
|
||||||
Doors.Door2Stopped_X = Vector3.xAxis*5.8
|
|
||||||
Doors.ElevatorDoorTime = 4
|
|
||||||
Doors.ElevatorDoorStyle = Enum.EasingStyle.Quad
|
|
||||||
|
|
||||||
Doors.Attributes = {
|
|
||||||
Relay = {
|
|
||||||
Open = Instance.new("BoolValue") :: BoolValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Doors.Attributes.Relay.Open.Value = false
|
|
||||||
|
|
||||||
local Attributes = Doors.Attributes
|
|
||||||
|
|
||||||
function Doors.constructor(FloorDoorsTags, ElevatorBox, ElevatorDoor1, ElevatorDoor2, ElevatorDoorSensor)
|
|
||||||
local DoorSensor: DoorSensors = {
|
|
||||||
Start = ElevatorDoorSensor:WaitForChild("Start") :: BasePart,
|
|
||||||
End = ElevatorDoorSensor:WaitForChild("End") :: BasePart
|
|
||||||
}
|
|
||||||
|
|
||||||
local DoorClosingClick = Instance.new("Sound") :: Sound
|
|
||||||
DoorClosingClick.SoundId = SoundEnums.Otis1960.DoorClosingClick
|
|
||||||
DoorClosingClick.Volume = .1
|
|
||||||
DoorClosingClick.Parent = ElevatorDoor2
|
|
||||||
|
|
||||||
return setmetatable({
|
|
||||||
FloorDoorsTags = FloorDoorsTags,
|
|
||||||
DoorSensor = DoorSensor,
|
|
||||||
ElevatorBox = ElevatorBox,
|
|
||||||
ElevatorDoor1 = ElevatorDoor1,
|
|
||||||
ElevatorDoor2 = ElevatorDoor2,
|
|
||||||
DoorClosingClick = DoorClosingClick
|
|
||||||
}, Doors)
|
|
||||||
end
|
|
||||||
|
|
||||||
--speed
|
|
||||||
local init_floors_opened: FloorDoors = {}
|
|
||||||
local init_floors_closed: FloorDoors = {}
|
|
||||||
|
|
||||||
local function DoorsAnimationFloor(FloorDoors: {Instance?}, Floor: number, opening: boolean?, activated_via_censor: boolean?): (Tween?, Tween?)
|
|
||||||
local Door2Tween_Floor: Tween?
|
|
||||||
local Door1Tween_Floor: Tween?
|
|
||||||
local FloorDoor1 = FloorDoors[1] :: BasePart?
|
|
||||||
local FloorDoor2 = FloorDoors[2] :: BasePart?
|
|
||||||
local FloorDoor1_P = FloorDoor1 and FloorDoor1.Position
|
|
||||||
local FloorDoor2_P = FloorDoor2 and FloorDoor2.Position
|
|
||||||
|
|
||||||
if opening then
|
|
||||||
if not init_floors_closed[Floor] then
|
|
||||||
init_floors_closed[Floor] = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
|
||||||
end
|
|
||||||
if FloorDoor2_P then
|
|
||||||
(init_floors_closed[Floor] :: {})[2] = FloorDoor2_P-Doors.Door2Stopped_X
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if not init_floors_opened[Floor] then
|
|
||||||
init_floors_opened[Floor] = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
if not (init_floors_opened[Floor] :: {})[1] and not (init_floors_opened[Floor] :: {})[2] then
|
|
||||||
if FloorDoor1_P then
|
|
||||||
(init_floors_opened[Floor] :: {})[1] = FloorDoor1_P+Doors.Door1Stopped_X
|
|
||||||
end
|
|
||||||
if FloorDoor2_P then
|
|
||||||
(init_floors_opened[Floor] :: {})[2] = FloorDoor2_P+Doors.Door2Stopped_X
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if FloorDoor1 then
|
|
||||||
local DoorTween1 = Tween.constructor(TweenInfo.new(
|
|
||||||
Doors.ElevatorDoorTime,
|
|
||||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
|
||||||
Enum.EasingDirection.Out
|
|
||||||
), FloorDoor1)
|
|
||||||
|
|
||||||
Door1Tween_Floor = DoorTween1:Start(nil, {
|
|
||||||
Position = opening and (init_floors_closed[Floor] :: {Vector3})[1] or (init_floors_opened[Floor] :: {Vector3})[1]
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
if FloorDoor2 then
|
|
||||||
local DoorTween2 = Tween.constructor(TweenInfo.new(
|
|
||||||
Doors.ElevatorDoorTime,
|
|
||||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
|
||||||
Enum.EasingDirection.Out
|
|
||||||
), FloorDoor2)
|
|
||||||
|
|
||||||
Door2Tween_Floor = DoorTween2:Start(nil, {
|
|
||||||
Position = opening and (init_floors_closed[Floor] :: {Vector3})[2] or (init_floors_opened[Floor] :: {Vector3})[2]
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
return Door1Tween_Floor, Door2Tween_Floor
|
|
||||||
end
|
|
||||||
|
|
||||||
local function ElevatorDoorsAnimationAsync(self: ClassConstructor, opening: boolean, activated_via_censor: boolean?)
|
|
||||||
--Roblox physics will freak out
|
|
||||||
self.ElevatorDoor1.CanCollide = false
|
|
||||||
self.ElevatorDoor2.CanCollide = false
|
|
||||||
|
|
||||||
local ElevatorDoor1_P = self.ElevatorDoor1.Position
|
|
||||||
local ElevatorDoor2_P = self.ElevatorDoor2.Position
|
|
||||||
|
|
||||||
local StartTime = os.clock()
|
|
||||||
local Timing = Doors.ElevatorDoorTime-1
|
|
||||||
|
|
||||||
if opening then
|
|
||||||
while task.wait() do
|
|
||||||
local Time = Algebra.LinearElapse(StartTime, Timing)
|
|
||||||
local Ease = Algebra.Easing.InOutQuart(Time)
|
|
||||||
|
|
||||||
local ElevatorBoxY = Vector3.new(0, self.ElevatorBox.Position.Y, 0)
|
|
||||||
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+Door1Vector:Lerp(Door1Vector-Doors.Door1Stopped_X, Ease)
|
|
||||||
self.ElevatorDoor2.Position = ElevatorBoxY+Door2Vector:Lerp(Door2Vector-Doors.Door2Stopped_X, Ease)
|
|
||||||
|
|
||||||
if Time>=1 then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
while task.wait() do
|
|
||||||
local Time = Algebra.LinearElapse(StartTime, Timing)
|
|
||||||
local Ease = Algebra.Easing.InOutQuart(Time)
|
|
||||||
|
|
||||||
local ElevatorBoxY = Vector3.new(0, self.ElevatorBox.Position.Y, 0)
|
|
||||||
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+Door1Vector:Lerp(Door1Vector+Doors.Door1Stopped_X, Ease)
|
|
||||||
self.ElevatorDoor2.Position = ElevatorBoxY+Door2Vector:Lerp(Door2Vector+Doors.Door2Stopped_X, Ease)
|
|
||||||
|
|
||||||
if Time>=1 then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local raycastParams = RaycastParams.new()
|
|
||||||
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
|
|
||||||
|
|
||||||
--heh..
|
|
||||||
local RayIgnoring = {}
|
|
||||||
local workspace_items = workspace:GetChildren()
|
|
||||||
for n: number = 1, #workspace_items do
|
|
||||||
local Inst = workspace_items[n]
|
|
||||||
if Inst:IsA("Folder") or Inst:IsA("BasePart") then
|
|
||||||
table.insert(RayIgnoring, workspace_items[n])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Doors:__DetectSensorHit(DoorTween1, DoorTween2)
|
|
||||||
local Step = nil
|
|
||||||
|
|
||||||
if Doors.Sensors and Attributes.Relay.Open.Value then
|
|
||||||
raycastParams.FilterDescendantsInstances = {self.ElevatorBox, table.unpack(RayIgnoring)}
|
|
||||||
|
|
||||||
Step = RS.Heartbeat:Connect(function(_dt)
|
|
||||||
local DoorSensor = workspace:Raycast(self.DoorSensor.Start.Position, self.DoorSensor.End.Position, raycastParams)
|
|
||||||
|
|
||||||
if DoorSensor and DoorSensor.Instance and DoorSensor.Instance:IsA("BasePart") then
|
|
||||||
Step:Disconnect()
|
|
||||||
DoorTween1:Pause()
|
|
||||||
DoorTween2:Pause()
|
|
||||||
task.wait(1) --elevators irl have this delay
|
|
||||||
ElevatorDoorsAnimationAsync(self, true, true)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
return Step
|
|
||||||
end
|
|
||||||
|
|
||||||
function Doors:ToggleElevatorDoorsAsync(opening, floor)
|
|
||||||
--short circuiting central
|
|
||||||
if opening then
|
|
||||||
if Attributes.Relay.Open.Value then
|
|
||||||
warn("Doors are already closed, doing nothing")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if not Attributes.Relay.Open.Value then
|
|
||||||
warn("Doors are already open, doing nothing")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local FloorDoorsObjects = self.FloorDoorsTags[floor]
|
|
||||||
if FloorDoorsObjects then
|
|
||||||
DoorsAnimationFloor(FloorDoorsObjects, floor, opening)
|
|
||||||
end
|
|
||||||
|
|
||||||
Attributes.Relay.Open.Value = opening
|
|
||||||
ElevatorDoorsAnimationAsync(self, opening)
|
|
||||||
|
|
||||||
self.ElevatorDoor1.CanCollide = true
|
|
||||||
self.ElevatorDoor2.CanCollide = true
|
|
||||||
|
|
||||||
if Doors.__DoorSensors and Doors.__DoorSensors.Connected then
|
|
||||||
Doors.__DoorSensors:Disconnect()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return Doors
|
|
||||||
@@ -25,9 +25,6 @@ type Impl_Constructor = {
|
|||||||
CarButton: (self: ClassConstructor, ButtonID: string, ButtonTree: Tags.ButtonProperties, Callback: FloorButtonActivatedCallback, Fallback: FloorButtonActivatedFallback) -> (),
|
CarButton: (self: ClassConstructor, ButtonID: string, ButtonTree: Tags.ButtonProperties, Callback: FloorButtonActivatedCallback, Fallback: FloorButtonActivatedFallback) -> (),
|
||||||
LandingButton: (self: ClassConstructor, ButtonID: string, ButtonTree: Tags.ButtonProperties, Callback: FloorButtonActivatedCallback, Fallback: FloorButtonActivatedFallback) -> (),
|
LandingButton: (self: ClassConstructor, ButtonID: string, ButtonTree: Tags.ButtonProperties, Callback: FloorButtonActivatedCallback, Fallback: FloorButtonActivatedFallback) -> (),
|
||||||
SpecialButton: (self: ClassConstructor, ButtonName: Enums.SpecialButtonValues, ButtonID: string, ButtonTree: Tags.ButtonProperties, Callback: StopButtonActivatedCallback) -> (),
|
SpecialButton: (self: ClassConstructor, ButtonName: Enums.SpecialButtonValues, ButtonID: string, ButtonTree: Tags.ButtonProperties, Callback: StopButtonActivatedCallback) -> (),
|
||||||
AestheticActivateButton: (self: ClassConstructor, Button: BasePart, Glass: BasePart?) -> (),
|
|
||||||
__DeactivateButton: (self: ClassConstructor, Button: BasePart, Glass: BasePart?) -> (),
|
|
||||||
__ActivateButton: (self: ClassConstructor, Button: BasePart, Glass: BasePart?) -> (),
|
|
||||||
} & Impl_Static_Props
|
} & Impl_Static_Props
|
||||||
|
|
||||||
type Impl_Static_Props = {
|
type Impl_Static_Props = {
|
||||||
@@ -135,38 +132,4 @@ function ButtonFunctions:SpecialButton(ButtonID, ButtonName, ButtonTree, Callbac
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ButtonFunctions:__DeactivateButton(Button, Glass)
|
|
||||||
local Part = Glass or Button
|
|
||||||
|
|
||||||
Part.Material = Enum.Material.Glass
|
|
||||||
Part.Color = self.ElevatorButtonColors.ButtonDeactivated
|
|
||||||
Part.Transparency = 0.3
|
|
||||||
end
|
|
||||||
|
|
||||||
function ButtonFunctions:__ActivateButton(Button, Glass)
|
|
||||||
local Part = Glass or Button
|
|
||||||
|
|
||||||
Part.Material = Enum.Material.Neon
|
|
||||||
Part.Color = self.ElevatorButtonColors.ButtonActivated
|
|
||||||
Part.Transparency = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function ButtonFunctions:AestheticActivateButton(Button)
|
|
||||||
local Glass = Button:FindFirstChild("Glass") :: BasePart?
|
|
||||||
local LookVec = (Glass or Button).CFrame.LookVector/50
|
|
||||||
if Glass then
|
|
||||||
Glass.Position+=LookVec
|
|
||||||
self:__ActivateButton(Button, Glass)
|
|
||||||
end
|
|
||||||
|
|
||||||
Button.Position+=LookVec
|
|
||||||
|
|
||||||
task.delay(ButtonFunctions.ButtonHoldDuration, function()
|
|
||||||
if Glass then
|
|
||||||
Glass.Position-=LookVec
|
|
||||||
end
|
|
||||||
Button.Position-=LookVec
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
return ButtonFunctions
|
return ButtonFunctions
|
||||||
38
src/server/main/Elevators/Elevator/Haughton/init.luau
Normal file
38
src/server/main/Elevators/Elevator/Haughton/init.luau
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
--!optimize 2
|
||||||
|
--!native
|
||||||
|
--!strict
|
||||||
|
|
||||||
|
local ParentDir = script.Parent
|
||||||
|
local ElevatorDir = ParentDir.Parent
|
||||||
|
local MainDir = ElevatorDir.Parent
|
||||||
|
|
||||||
|
local StorageService = game:GetService("ReplicatedStorage")
|
||||||
|
|
||||||
|
local InitElevator = require(ParentDir)
|
||||||
|
local TagsModule = require(MainDir:WaitForChild("Load"):WaitForChild("Tags"))
|
||||||
|
local Enums = require(StorageService:WaitForChild("Enums"))
|
||||||
|
|
||||||
|
local ElevatorConfigurationTable = require(ElevatorDir:WaitForChild("Configs"))
|
||||||
|
local FloorLevelingPositions = require(ElevatorDir:WaitForChild("Leveling"))
|
||||||
|
local TractionRopes = require(ElevatorDir:WaitForChild("TractionRopes"))
|
||||||
|
|
||||||
|
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
|
||||||
|
local ElevatorBoxModel = TagsConstructor:Request("ElevatorMover_Haughton") :: BasePart
|
||||||
|
local RopeTags = TagsConstructor:Request("ElevatorRope_Haughton") :: {Instance}
|
||||||
|
|
||||||
|
local Elevator = InitElevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable.HaughtonConfiguration, FloorLevelingPositions.HaughtonLeveling)
|
||||||
|
local TractionRopesConstructor = TractionRopes.constructor(RopeTags, ElevatorBoxModel, FloorLevelingPositions.HaughtonLeveling)
|
||||||
|
|
||||||
|
task.wait(3)
|
||||||
|
task.spawn(function()
|
||||||
|
Elevator:RequestLevelAsync(2, Enums.ElevatorCallDirection.Down)
|
||||||
|
end)
|
||||||
|
|
||||||
|
Elevator.Events.Traveling:Connect(function(deltaTime: number, cabPosition: Vector3)
|
||||||
|
--TractionRopesConstructor:Move(10, cabPosition)
|
||||||
|
warn("This is impossible to be firing during parked")
|
||||||
|
end)
|
||||||
|
Elevator:StartTraveling()
|
||||||
|
Elevator.Events.Parked:Wait()
|
||||||
|
Elevator.__Connections.Moving:Disconnect()
|
||||||
|
end
|
||||||
@@ -7,18 +7,18 @@ local MainDir = ParentDir.Parent
|
|||||||
|
|
||||||
local StorageService = game:GetService("ReplicatedStorage")
|
local StorageService = game:GetService("ReplicatedStorage")
|
||||||
|
|
||||||
local Enums = require(StorageService:WaitForChild("Enums"))
|
local Enums = require(StorageService:WaitForChild("Enums"))
|
||||||
local InitElevator = require(ParentDir:WaitForChild("InitElevator"))
|
local InitElevator = require(ParentDir:WaitForChild("InitElevator"))
|
||||||
local TagsModule = require(MainDir:WaitForChild("Load"):WaitForChild("Tags"))
|
local TagsModule = require(MainDir:WaitForChild("Load"):WaitForChild("Tags"))
|
||||||
|
|
||||||
local ElevatorConfigurationTable = require(ParentDir:WaitForChild("Config"))
|
local ElevatorConfigurationTable = require(ParentDir:WaitForChild("Configs"))
|
||||||
local FloorLevelingPositions = require(ParentDir:WaitForChild("Leveling"))
|
local FloorLevelingPositions = require(ParentDir:WaitForChild("Leveling"))
|
||||||
|
|
||||||
-- self.ElevatorBox_1960 = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
|
-- self.ElevatorBox_1960 = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
|
||||||
-- self.ElevatorDoor1 = TagsConstructor:Request("ElevatorDoor_1960_1") :: BasePart
|
-- self.ElevatorDoor1 = TagsConstructor:Request("ElevatorDoor_1960_1") :: BasePart
|
||||||
-- self.ElevatorDoor2 = TagsConstructor:Request("ElevatorDoor_1960_2") :: BasePart
|
-- self.ElevatorDoor2 = TagsConstructor:Request("ElevatorDoor_1960_2") :: BasePart
|
||||||
-- self.ElevatorDoorSensor = TagsConstructor:Request("ElevatorDoor_Sensor_1960") :: Folder
|
-- self.ElevatorDoorSensor = TagsConstructor:Request("ElevatorDoor_Sensor_1960") :: Folder
|
||||||
-- self.Ropes = TagsConstructor:Request("1960_ElevatorPulleyRope") :: {Instance}
|
-- self.Ropes = TagsConstructor:Request("1960_ElevatorPulleyRope") :: {Instance}
|
||||||
-- self.HallDisplays = TagsConstructor:Request("Otis1960_LandingFloorDisplay") :: {Instance}
|
-- self.HallDisplays = TagsConstructor:Request("Otis1960_LandingFloorDisplay") :: {Instance}
|
||||||
|
|
||||||
-- self.MachineRoom.Pulley = TagsConstructor:Request("Otis1960_Pulley") :: UnionOperation
|
-- self.MachineRoom.Pulley = TagsConstructor:Request("Otis1960_Pulley") :: UnionOperation
|
||||||
@@ -30,21 +30,7 @@ local FloorLevelingPositions = require(ParentDir:WaitForChild("Leveling"))
|
|||||||
-- self.MachineRoom.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation
|
-- self.MachineRoom.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation
|
||||||
|
|
||||||
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
|
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
|
||||||
local ElevatorBoxModel = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
|
--local ElevatorBoxModel = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
|
||||||
|
|
||||||
local Elevator = InitElevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable.Otis1960Configuration, FloorLevelingPositions)
|
--local Elevator = InitElevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable.Otis1960Configuration, FloorLevelingPositions)
|
||||||
|
|
||||||
Elevator.Events.Progression:Connect(function(PreviousFloor: number, CurrentFloor: number, NextFloor: number)
|
|
||||||
print(CurrentFloor)
|
|
||||||
end)
|
|
||||||
Elevator.Attributes.Goal:GetPropertyChangedSignal("Value"):Connect(function()
|
|
||||||
print("Goal=", Elevator.Attributes.Goal.Value)
|
|
||||||
end)
|
|
||||||
|
|
||||||
task.wait(1)
|
|
||||||
task.spawn(function()
|
|
||||||
Elevator:RequestLevelAsync(2, Enums.ElevatorCallDirection.Up)
|
|
||||||
end)
|
|
||||||
|
|
||||||
print(Elevator.RelayAlgorithm.FloorQueue.Up)
|
|
||||||
end
|
end
|
||||||
@@ -31,7 +31,7 @@ type Impl_Constructor = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FloorLevelingPositions = {number}
|
type FloorLevelingPositions = {number}
|
||||||
type Constructor_Fun = (ElevatorBoxModel: UnionOperation, ElevatorConfigurationTable: ElevatorTypes.ElevatorConfigurationTable, FloorLevelingPositions: FloorLevelingPositions) -> ClassConstructor
|
type Constructor_Fun = (ElevatorBoxModel: BasePart, ElevatorConfigurationTable: ElevatorTypes.ElevatorConfigurationTable, FloorLevelingPositions: FloorLevelingPositions) -> ClassConstructor
|
||||||
|
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
RelayAlgorithm: RelayAlgorithm.RelayAlgorithmConstructor,
|
RelayAlgorithm: RelayAlgorithm.RelayAlgorithmConstructor,
|
||||||
@@ -86,7 +86,7 @@ local function ElevatorGoingUpDirection(CurrentFloor: number, RequestedFloor: nu
|
|||||||
return CurrentFloor<RequestedFloor
|
return CurrentFloor<RequestedFloor
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Mover(ElevatorBoxModel: UnionOperation, Responsiveness: number, MaxVelocity: number): (Attachment, AlignPosition, AlignOrientation)
|
local function Mover(ElevatorBoxModel: BasePart, Responsiveness: number, MaxVelocity: number): (Attachment, AlignPosition, AlignOrientation)
|
||||||
local BoxAttachment = Instance.new("Attachment")
|
local BoxAttachment = Instance.new("Attachment")
|
||||||
BoxAttachment.Parent = ElevatorBoxModel
|
BoxAttachment.Parent = ElevatorBoxModel
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ local function Mover(ElevatorBoxModel: UnionOperation, Responsiveness: number, M
|
|||||||
BoxAlignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
|
BoxAlignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
|
||||||
BoxAlignOrientation.Attachment0 = BoxAttachment
|
BoxAlignOrientation.Attachment0 = BoxAttachment
|
||||||
BoxAlignOrientation.RigidityEnabled = true
|
BoxAlignOrientation.RigidityEnabled = true
|
||||||
BoxAlignOrientation.CFrame = CFrame.new(0,0,0)*CFrame.fromOrientation(0,0,0)
|
BoxAlignOrientation.CFrame = ElevatorBoxModel.CFrame
|
||||||
BoxAlignOrientation.Parent = ElevatorBoxModel
|
BoxAlignOrientation.Parent = ElevatorBoxModel
|
||||||
|
|
||||||
return BoxAttachment, BoxAlignPosition, BoxAlignOrientation
|
return BoxAttachment, BoxAlignPosition, BoxAlignOrientation
|
||||||
@@ -120,6 +120,7 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo
|
|||||||
end
|
end
|
||||||
local function ewarn<T...>(...: T...)
|
local function ewarn<T...>(...: T...)
|
||||||
warn(`[{ElevatorConfigurationTable.Name}]:`, ...)
|
warn(`[{ElevatorConfigurationTable.Name}]:`, ...)
|
||||||
|
warn(debug.traceback())
|
||||||
end
|
end
|
||||||
local function eprintStudio<T...>(...: T...)
|
local function eprintStudio<T...>(...: T...)
|
||||||
Out.printStudio(`[{ElevatorConfigurationTable.Name}]:`, ...)
|
Out.printStudio(`[{ElevatorConfigurationTable.Name}]:`, ...)
|
||||||
@@ -342,7 +343,8 @@ function Elevator:__TravelToFloorAsync(Level_Int, LEVEL_VEC3_Y_WRAP)
|
|||||||
self.__Connections.Moving:Disconnect()
|
self.__Connections.Moving:Disconnect()
|
||||||
end
|
end
|
||||||
|
|
||||||
print("TravelingToFloorAsync")
|
assert(not self.Elevator.BoxModel.Anchored, "The elevator cannot move! Its box model is Anchored.")
|
||||||
|
|
||||||
local ElevatorTravelingUpwards = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, Level_Int)
|
local ElevatorTravelingUpwards = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, Level_Int)
|
||||||
self.Attributes.Goal.Value = Level_Int
|
self.Attributes.Goal.Value = Level_Int
|
||||||
self.Attributes.TravelingUpwards.Value = ElevatorTravelingUpwards
|
self.Attributes.TravelingUpwards.Value = ElevatorTravelingUpwards
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
--!optimize 2
|
|
||||||
--!native
|
|
||||||
--!strict
|
|
||||||
|
|
||||||
type HallDisplays = {Instance}
|
|
||||||
|
|
||||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
|
||||||
type Impl_Constructor = {
|
|
||||||
__index: Impl_Constructor,
|
|
||||||
constructor: Constructor_Fun,
|
|
||||||
--Class functions
|
|
||||||
BindHallDisplays: (self: ClassConstructor) -> (),
|
|
||||||
UnBindHallDisplays: (self: ClassConstructor) -> (),
|
|
||||||
SetHallDisplays: (self: ClassConstructor, floor: string | number) -> ()
|
|
||||||
}
|
|
||||||
|
|
||||||
type Constructor_Fun = (CurrentFloorAttribute: IntValue, HallDisplayTags: HallDisplays) -> ClassConstructor
|
|
||||||
type Constructor_Return_Props = {
|
|
||||||
CurrentFloorAttribute: IntValue,
|
|
||||||
HallDisplayTags: HallDisplays,
|
|
||||||
__CurrentFloorConnection: RBXScriptConnection?
|
|
||||||
}
|
|
||||||
|
|
||||||
export type HallDisplaysConstructor = ClassConstructor
|
|
||||||
|
|
||||||
local HallDisplays = {} :: Impl_Constructor
|
|
||||||
HallDisplays.__index = HallDisplays
|
|
||||||
|
|
||||||
function HallDisplays.constructor(CurrentFloorAttribute, HallDisplayTags)
|
|
||||||
return setmetatable({
|
|
||||||
CurrentFloorAttribute = CurrentFloorAttribute,
|
|
||||||
HallDisplayTags = HallDisplayTags
|
|
||||||
}, HallDisplays)
|
|
||||||
end
|
|
||||||
|
|
||||||
function HallDisplays:SetHallDisplays(floor)
|
|
||||||
local FloorString = tostring(floor)
|
|
||||||
|
|
||||||
for i = 1, #self.HallDisplayTags do
|
|
||||||
(self.HallDisplayTags[i] :: TextLabel).Text = FloorString
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function HallDisplays:BindHallDisplays()
|
|
||||||
self:UnBindHallDisplays()
|
|
||||||
self.__CurrentFloorConnection = self.CurrentFloorAttribute:GetPropertyChangedSignal("Value"):Connect(function()
|
|
||||||
self:SetHallDisplays(self.CurrentFloorAttribute.Value)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function HallDisplays:UnBindHallDisplays()
|
|
||||||
if self.__CurrentFloorConnection and self.__CurrentFloorConnection.Connected then
|
|
||||||
self.__CurrentFloorConnection:Disconnect()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return HallDisplays
|
|
||||||
@@ -16,11 +16,8 @@ local Otis1960Leveling: {number} = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local HaughtonLeveling: {number} = {
|
local HaughtonLeveling: {number} = {
|
||||||
[1] = 0,
|
[1] = 1.163,
|
||||||
[2] = 0,
|
[2] = 19.163,
|
||||||
[3] = 0,
|
|
||||||
[4] = 0,
|
|
||||||
[5] = 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type Impl_Constructor = {
|
|||||||
Stopped: (self: ClassConstructor) -> (),
|
Stopped: (self: ClassConstructor) -> (),
|
||||||
}
|
}
|
||||||
|
|
||||||
type Constructor_Fun = (RopeTags: RopeTags, ElevatorBox: UnionOperation, Leveling: Leveling) -> ClassConstructor
|
type Constructor_Fun = (RopeTags: RopeTags, ElevatorBox: BasePart, Leveling: Leveling) -> ClassConstructor
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
Ropes: RopeTags,
|
Ropes: RopeTags,
|
||||||
Leveling: Leveling,
|
Leveling: Leveling,
|
||||||
|
|||||||
@@ -16,11 +16,14 @@ local Workspace_Stuff = require(Load:WaitForChild("Workspace"))
|
|||||||
local StarterPlayer_Stuff = require(Load:WaitForChild("StarterPlayer"))
|
local StarterPlayer_Stuff = require(Load:WaitForChild("StarterPlayer"))
|
||||||
|
|
||||||
local Elevators = script:WaitForChild("Elevators")
|
local Elevators = script:WaitForChild("Elevators")
|
||||||
|
local Elevator = Elevators:WaitForChild("Elevator")
|
||||||
local Maps = script:WaitForChild("Map")
|
local Maps = script:WaitForChild("Map")
|
||||||
|
|
||||||
local Interactions = Maps:WaitForChild("Interactions")
|
local Interactions = Maps:WaitForChild("Interactions")
|
||||||
local LightSwitches = require(Interactions:WaitForChild("LightSwitches"))
|
local LightSwitches = require(Interactions:WaitForChild("LightSwitches"))
|
||||||
local Otis1960 = require(Elevators:WaitForChild("Otis1960"))
|
|
||||||
|
--local Otis1960 = require(Elevators:WaitForChild("Elevator"):WaitForChild("Otis1960"))
|
||||||
|
local Haughton = require(Elevator:WaitForChild("Haughton"))
|
||||||
|
|
||||||
local Enums = require(Storage:WaitForChild("Enums"))
|
local Enums = require(Storage:WaitForChild("Enums"))
|
||||||
|
|
||||||
@@ -50,4 +53,5 @@ print("[DEBUG] Lanterns=", Lanterns)
|
|||||||
local LandingDoors = TagsConstructor:__ElevatorDoors()
|
local LandingDoors = TagsConstructor:__ElevatorDoors()
|
||||||
print("[DEBUG] Elevator Landing Doors=", LandingDoors)
|
print("[DEBUG] Elevator Landing Doors=", LandingDoors)
|
||||||
|
|
||||||
Otis1960(TagsConstructor, Buttons[Enums.Elevator.Otis1960], Lanterns[Enums.Elevator.Otis1960], LandingDoors[Enums.Elevator.Otis1960])
|
-- Otis1960(TagsConstructor, Buttons[Enums.Elevator.Otis1960], Lanterns[Enums.Elevator.Otis1960], LandingDoors[Enums.Elevator.Otis1960])
|
||||||
|
Haughton(TagsConstructor, Buttons[Enums.Elevator.Haughton], Lanterns[Enums.Elevator.Haughton], LandingDoors[Enums.Elevator.Haughton])
|
||||||
|
|||||||
@@ -23,16 +23,19 @@ end
|
|||||||
local function warnStudio<T...>(...: T...)
|
local function warnStudio<T...>(...: T...)
|
||||||
if RunService:IsStudio() then
|
if RunService:IsStudio() then
|
||||||
warn(...)
|
warn(...)
|
||||||
|
warn(debug.traceback())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function warnServer<T...>(...: T...)
|
local function warnServer<T...>(...: T...)
|
||||||
if RunService:IsServer() then
|
if RunService:IsServer() then
|
||||||
warn(...)
|
warn(...)
|
||||||
|
warn(debug.traceback())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function warnClient<T...>(...: T...)
|
local function warnClient<T...>(...: T...)
|
||||||
if RunService:IsClient() then
|
if RunService:IsClient() then
|
||||||
warn(...)
|
warn(...)
|
||||||
|
warn(debug.traceback())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
--!optimize 2
|
|
||||||
--!native
|
|
||||||
--!strict
|
|
||||||
|
|
||||||
local function MakeEvent<T,U>()
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
|
||||||
MakeEvent = MakeEvent
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user