mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
elevator lanterns
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -31,7 +31,7 @@ CrosshairModule.__index = CrosshairModule
|
||||
CrosshairModule.Icon = "rbxassetid://12643750723"
|
||||
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local Easings = require(Storage:WaitForChild("AlgebraEasings"))
|
||||
local Easings = require(Storage:WaitForChild("Algebra"))
|
||||
|
||||
function CrosshairModule.constructor(PlayerGui: PlayerGui)
|
||||
local Screen = PlayerGui:WaitForChild("Crosshair") :: ScreenGui
|
||||
|
||||
@@ -11,7 +11,6 @@ local Mouse = require(script:WaitForChild("Mouse"))
|
||||
|
||||
local Players: Players = game:GetService("Players")
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RS: RunService = game:GetService("RunService")
|
||||
|
||||
local ClientStorage = Storage:WaitForChild("Client")
|
||||
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
|
||||
|
||||
@@ -24,17 +24,18 @@ type Impl_Constructor = {
|
||||
DecodeCarTag: (self: ClassConstructor, FloorTag: string) -> number?,
|
||||
Get: (self: ClassConstructor) -> GetButtons,
|
||||
CreatePromptButtons: (self: ClassConstructor) -> ButtonsTree,
|
||||
HookPromptButtonsGroup: (self: ClassConstructor, Prompt: ProximityPrompt, Inst: BasePart, PromptCallback: PromptCallback) -> ()
|
||||
HookPromptButtonsGroup: (self: ClassConstructor, Prompt: ProximityPrompt?, Inst: BasePart?, PromptCallback: PromptCallback) -> (),
|
||||
AestheticActivateButton: (self: ClassConstructor, Button: BasePart, ActivatedState: boolean, ActivatedColor: Color3) -> ()
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Impl_Static_Props = {
|
||||
ButtonEnum: any
|
||||
}
|
||||
|
||||
type Constructor_Fun = (TagsConstructor: TagsConstructor, Model: string) -> ClassConstructor
|
||||
type Constructor_Fun = (TagsConstructor: TagsConstructor, Model: Enums.ElevatorValues) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
Tags: TagsConstructor,
|
||||
Model: string,
|
||||
Model: Enums.ElevatorValues,
|
||||
Buttons: ButtonsTree
|
||||
}
|
||||
|
||||
@@ -83,10 +84,11 @@ function ButtonsModule:Get()
|
||||
if typeof(Inst) == "Instance" then
|
||||
Buttons[TagName] = Inst
|
||||
else
|
||||
warn("TODO block hit,", debug.traceback())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
return Buttons
|
||||
end
|
||||
|
||||
@@ -182,6 +184,8 @@ function ButtonsModule:CreatePromptButtons()
|
||||
end
|
||||
|
||||
function ButtonsModule:HookPromptButtonsGroup(Prompt, Inst, PromptCallback)
|
||||
if Prompt then
|
||||
if Inst then
|
||||
Prompt.Triggered:Connect(function(Player)
|
||||
local PlayerCharacter = Player.Character
|
||||
local Root = PlayerCharacter and PlayerCharacter:FindFirstChild("HumanoidRootPart") :: HumanoidRootPart?
|
||||
@@ -194,6 +198,35 @@ function ButtonsModule:HookPromptButtonsGroup(Prompt, Inst, PromptCallback)
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
warn("Button Hook Error! Inst is missing", debug.traceback())
|
||||
end
|
||||
else
|
||||
warn("Button Hook Error! Prompt is missing", debug.traceback())
|
||||
end
|
||||
end
|
||||
|
||||
function ButtonsModule:AestheticActivateButton(Button, ActivatedState, ActivatedColor)
|
||||
task.spawn(function()
|
||||
local Glass = Button:FindFirstChild("Glass") :: BasePart
|
||||
local LookVec = Glass.CFrame.LookVector/50
|
||||
if Glass then
|
||||
Glass.Position+=LookVec
|
||||
|
||||
if not ActivatedState then
|
||||
Glass.Material = Enum.Material.Neon
|
||||
Glass.Color = ActivatedColor
|
||||
Glass.Transparency = 0
|
||||
end
|
||||
end
|
||||
Button.Position+=LookVec
|
||||
|
||||
task.wait(.30)
|
||||
if Glass then
|
||||
Glass.Position-=LookVec
|
||||
end
|
||||
Button.Position-=LookVec
|
||||
end)
|
||||
end
|
||||
|
||||
return ButtonsModule
|
||||
@@ -10,6 +10,14 @@ export type EnumButton = typeof(Enums.Button)
|
||||
export type EnumButtonTree = typeof(Enums.ButtonTree)
|
||||
export type EnumElevator = typeof(Enums.Elevator)
|
||||
|
||||
export type ButtonTreeValues = typeof(Enums.ButtonTree.Car) |
|
||||
typeof(Enums.ButtonTree.Landing) |
|
||||
typeof(Enums.ButtonTree.Special) |
|
||||
typeof(Enums.ButtonTree.Relays) |
|
||||
typeof(Enums.ButtonTree.Unknown)
|
||||
|
||||
export type ElevatorValues = typeof(Enums.Elevator.Otis1960)
|
||||
|
||||
Enums.Button = {
|
||||
Car = "CarButton" :: "CarButton",
|
||||
Landing = "LandingButton" :: "LandingButton",
|
||||
|
||||
174
src/server/main/Elevators/Lanterns.lua
Normal file
174
src/server/main/Elevators/Lanterns.lua
Normal file
@@ -0,0 +1,174 @@
|
||||
--!optimize 2
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
local Tags = require(Storage:WaitForChild("Tags"))
|
||||
|
||||
local Enums = require(script.Parent:WaitForChild("Enums"))
|
||||
|
||||
type rbxassetid = string
|
||||
type TagProduct = Tags.TagProduct
|
||||
|
||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||
type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
Get: (Tags: Tags.TagsConstructor, Model: Enums.ElevatorValues) -> Lanterns,
|
||||
--Class functions
|
||||
__Activate: (self: ClassConstructor, EnabledState: boolean, IsDirectionLantern: boolean, Lantern: Lantern) -> (),
|
||||
DirectionUp: (self: ClassConstructor, Enabled: boolean) -> (),
|
||||
DirectionDown: (self: ClassConstructor, Enabled: boolean) -> (),
|
||||
Toggle: (self: ClassConstructor, Enabled: boolean, Floor: number) -> (),
|
||||
Reset: (self: ClassConstructor) -> ()
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Impl_Static_Props = {
|
||||
Volume: number
|
||||
}
|
||||
|
||||
type Constructor_Fun = (MainDisplay: UnionOperation, ChimeDirectionID: rbxassetid, ChimeLandingID: rbxassetid, Lanterns: Lanterns, Colors: Colors) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
LanternsMap: Lanterns,
|
||||
AudioChimeDirection: Sound,
|
||||
AudioChimeLanding: Sound,
|
||||
Colors: Colors
|
||||
}
|
||||
|
||||
type Lantern = {
|
||||
Inst: BasePart,
|
||||
Light: BasePart?,
|
||||
Played: boolean
|
||||
}
|
||||
|
||||
export type Lanterns = {
|
||||
[number]: Lantern,
|
||||
Up: Lantern,
|
||||
Down: Lantern
|
||||
}
|
||||
|
||||
export type Colors = {
|
||||
Active: Color3,
|
||||
Off: Color3
|
||||
}
|
||||
|
||||
export type LanternsConstructor = ClassConstructor
|
||||
|
||||
local Lanterns = {} :: Impl_Constructor
|
||||
Lanterns.__index = Lanterns
|
||||
|
||||
Lanterns.Volume = .8
|
||||
|
||||
function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, LanternsMap, Colors)
|
||||
local AudioChimeDirection = Instance.new("Sound") :: Sound
|
||||
AudioChimeDirection.SoundId = ChimeDirectionID
|
||||
AudioChimeDirection.Volume = Lanterns.Volume
|
||||
local AudioChimeLanding = Instance.new("Sound") :: Sound
|
||||
AudioChimeLanding.SoundId = ChimeLandingID
|
||||
AudioChimeLanding.Volume = Lanterns.Volume
|
||||
|
||||
AudioChimeDirection.Parent = MainDisplay
|
||||
AudioChimeLanding.Parent = MainDisplay
|
||||
|
||||
return setmetatable({
|
||||
LanternsMap = LanternsMap,
|
||||
AudioChimeDirection = AudioChimeDirection,
|
||||
AudioChimeLanding = AudioChimeLanding,
|
||||
Colors = Colors
|
||||
}, Lanterns)
|
||||
end
|
||||
|
||||
function Lanterns.Get(Tags, Model)
|
||||
local Lanterns = {} :: Lanterns
|
||||
|
||||
for TagName: string, Inst: TagProduct in Tags.__export do
|
||||
local Split = TagName:split('_')
|
||||
if Split[1] == Model and Split[2] == "DirectionIndicator" then
|
||||
local Floor = tonumber(Split[3])
|
||||
if Floor then
|
||||
if not Lanterns[Floor] then
|
||||
Lanterns[Floor] = {
|
||||
Inst = Inst :: BasePart,
|
||||
Light = (Inst :: BasePart).Parent:FindFirstChild("Light") :: BasePart?,
|
||||
Played = false
|
||||
}
|
||||
else
|
||||
warn(`Lanterns: Floor "{tostring(Floor)}" was already wrote while parsing`)
|
||||
end
|
||||
else
|
||||
if Split[3] == "Up" then
|
||||
Lanterns.Up = {
|
||||
Inst = Inst :: BasePart,
|
||||
Light = (Inst :: BasePart).Parent:FindFirstChild("Light") :: BasePart?,
|
||||
Played = false
|
||||
}
|
||||
elseif Split[3] == "Down" then
|
||||
Lanterns.Down = {
|
||||
Inst = Inst :: BasePart,
|
||||
Light = (Inst :: BasePart).Parent:FindFirstChild("Light") :: BasePart?,
|
||||
Played = false
|
||||
}
|
||||
else
|
||||
warn(`Lanterns: Unknown type paired with "DirectionIndicator", {Split[3]}`)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Lanterns
|
||||
end
|
||||
|
||||
local LanternLight = Tween.constructor(TweenInfo.new(1))
|
||||
|
||||
function Lanterns:__Activate(EnabledState, IsDirectionLantern, Lantern)
|
||||
local Tween = LanternLight:Start(Lantern.Light, {
|
||||
Color = EnabledState and self.Colors.Active or self.Colors.Off
|
||||
})
|
||||
|
||||
if EnabledState then
|
||||
if IsDirectionLantern then
|
||||
self.AudioChimeDirection:Play()
|
||||
else
|
||||
Tween.Completed:Connect(function()
|
||||
self.AudioChimeLanding:Play()
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Lanterns:Reset()
|
||||
self.LanternsMap.Up.Played = false
|
||||
self.LanternsMap.Down.Played = false
|
||||
self:__Activate(false, true, self.LanternsMap.Up)
|
||||
self:__Activate(false, true, self.LanternsMap.Down)
|
||||
|
||||
for n: number = 1, #self.LanternsMap do
|
||||
self:__Activate(false, false, self.LanternsMap[n])
|
||||
self.LanternsMap[n].Played = false
|
||||
end
|
||||
end
|
||||
|
||||
function Lanterns:DirectionUp(Enabled)
|
||||
if not self.LanternsMap.Up.Played then
|
||||
self.LanternsMap.Up.Played = true
|
||||
self:__Activate(Enabled, true, self.LanternsMap.Up)
|
||||
end
|
||||
end
|
||||
|
||||
function Lanterns:DirectionDown(Enabled)
|
||||
if not self.LanternsMap.Down.Played then
|
||||
self.LanternsMap.Down.Played = true
|
||||
self:__Activate(Enabled, true, self.LanternsMap.Down)
|
||||
end
|
||||
end
|
||||
|
||||
function Lanterns:Toggle(Enabled, Floor)
|
||||
local f = self.LanternsMap[Floor]
|
||||
if not f.Played then
|
||||
f.Played = true
|
||||
self:__Activate(Enabled, false, f)
|
||||
end
|
||||
end
|
||||
|
||||
return Lanterns
|
||||
@@ -2,7 +2,7 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local Leveling: {number} = {
|
||||
local Leveling = {
|
||||
[1] = 13.041,
|
||||
[2] = 37.973,
|
||||
[3] = 62.978,
|
||||
@@ -12,7 +12,13 @@ local Leveling: {number} = {
|
||||
[7] = 163.009,
|
||||
[8] = 188.007,
|
||||
[9] = 213.058,
|
||||
[10] = 239.245
|
||||
[10] = 239.245,
|
||||
|
||||
Between = {}
|
||||
}
|
||||
|
||||
for n: number = 1, #Leveling, 2 do
|
||||
Leveling.Between[n]=(Leveling[n+1]+Leveling[n])/2
|
||||
end
|
||||
|
||||
return Leveling
|
||||
@@ -9,17 +9,20 @@ type Impl_Constructor = {
|
||||
--Class functions
|
||||
UpdateCFrame: (self: ClassConstructor) -> (),
|
||||
Frame_Pullies: (self: ClassConstructor, Delta: number, ElevatorVelocity_Y: number) -> (),
|
||||
Frame_PiePlate: (self: ClassConstructor) -> ()
|
||||
Frame_PiePlate: (self: ClassConstructor, Delta: number, ElevatorVelocity_Y: number) -> ()
|
||||
}
|
||||
|
||||
type Constructor_Fun = (InstanceTree: InstanceTree) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
MachineRoom: {
|
||||
type Constructor_Return_Props = InstanceTree
|
||||
|
||||
export type MachineRoom = {
|
||||
Pulley: UnionOperation,
|
||||
Pulley2: UnionOperation,
|
||||
Governor: UnionOperation,
|
||||
GovernorFlyballs: UnionOperation,
|
||||
PieplatePulley: UnionOperation,
|
||||
GovernorFlyballs: Part,
|
||||
PiePlatePulley: UnionOperation,
|
||||
PiePlateSelector: UnionOperation,
|
||||
PiePlatePlates: UnionOperation,
|
||||
|
||||
_CFrame: {
|
||||
PulleyCFrame: CFrame,
|
||||
@@ -27,17 +30,10 @@ type Constructor_Return_Props = {
|
||||
GovernorCFrame: CFrame,
|
||||
GovernorFlyballsCFrame: CFrame,
|
||||
PieplatePulleyCFrame: CFrame,
|
||||
PieplateSelectorCFrame: CFrame,
|
||||
PiePlatePlatesCFrame: CFrame
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type MachineRoom = {
|
||||
Pulley: UnionOperation,
|
||||
Pulley2: UnionOperation,
|
||||
Governor: UnionOperation,
|
||||
GovernorFlyballs: UnionOperation,
|
||||
PieplatePulley: UnionOperation,
|
||||
}
|
||||
|
||||
export type InstanceTree = {
|
||||
MachineRoom: MachineRoom
|
||||
@@ -50,7 +46,7 @@ MovingObjects.__index = MovingObjects
|
||||
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
local Easing = require(Storage:WaitForChild("AlgebraEasings"))
|
||||
local Easing = require(Storage:WaitForChild("Algebra"))
|
||||
|
||||
function MovingObjects.constructor(InstanceTree)
|
||||
local self = InstanceTree :: Constructor_Return_Props
|
||||
@@ -58,7 +54,11 @@ function MovingObjects.constructor(InstanceTree)
|
||||
self.MachineRoom._CFrame.Pulley2CFrame = InstanceTree.MachineRoom.Pulley2.CFrame
|
||||
self.MachineRoom._CFrame.GovernorCFrame = InstanceTree.MachineRoom.Governor.CFrame
|
||||
self.MachineRoom._CFrame.GovernorFlyballsCFrame = InstanceTree.MachineRoom.GovernorFlyballs.CFrame
|
||||
self.MachineRoom._CFrame.PieplatePulleyCFrame = InstanceTree.MachineRoom.PieplatePulley.CFrame
|
||||
self.MachineRoom._CFrame.PieplatePulleyCFrame = InstanceTree.MachineRoom.PiePlatePulley.CFrame
|
||||
self.MachineRoom._CFrame.PiePlatePlatesCFrame = InstanceTree.MachineRoom.PiePlatePlates.CFrame
|
||||
|
||||
--static
|
||||
self.MachineRoom._CFrame.PieplateSelectorCFrame = InstanceTree.MachineRoom.PiePlateSelector.CFrame
|
||||
|
||||
return setmetatable(self, MovingObjects)
|
||||
end
|
||||
@@ -68,23 +68,31 @@ function MovingObjects:UpdateCFrame()
|
||||
self.MachineRoom._CFrame.Pulley2CFrame = self.MachineRoom.Pulley2.CFrame
|
||||
self.MachineRoom._CFrame.GovernorCFrame = self.MachineRoom.Governor.CFrame
|
||||
self.MachineRoom._CFrame.GovernorFlyballsCFrame = self.MachineRoom.GovernorFlyballs.CFrame
|
||||
self.MachineRoom._CFrame.PieplatePulleyCFrame = self.MachineRoom.PieplatePulley.CFrame
|
||||
self.MachineRoom._CFrame.PieplatePulleyCFrame = self.MachineRoom.PiePlatePulley.CFrame
|
||||
self.MachineRoom._CFrame.PieplateSelectorCFrame = self.MachineRoom.PiePlateSelector.CFrame
|
||||
end
|
||||
|
||||
function MovingObjects:Frame_Pullies(Delta, ElevatorVelocity_Y)
|
||||
local MR = self.MachineRoom
|
||||
local MR_C = MR._CFrame
|
||||
|
||||
local RotAngle = Delta*ElevatorVelocity_Y
|
||||
local PullAngle_2 = math.rad(RotAngle/2)
|
||||
local PullAngle = math.rad(RotAngle)
|
||||
|
||||
self.MachineRoom.Pulley.CFrame = self.MachineRoom._CFrame.PulleyCFrame *CFrame.Angles(-PullAngle_2, 0, 0)
|
||||
self.MachineRoom.Pulley2.CFrame = self.MachineRoom._CFrame.Pulley2CFrame *CFrame.Angles(PullAngle_2, 0, 0)
|
||||
self.MachineRoom.Governor.CFrame = self.MachineRoom._CFrame.GovernorCFrame *CFrame.Angles(0, PullAngle_2, 0)
|
||||
self.MachineRoom.GovernorFlyballs.CFrame = self.MachineRoom._CFrame.GovernorFlyballsCFrame*CFrame.Angles(PullAngle, 0, 0)
|
||||
self.MachineRoom.PieplatePulley.CFrame = self.MachineRoom._CFrame.PieplatePulleyCFrame *CFrame.Angles(PullAngle_2, 0, 0)
|
||||
MR.Pulley.CFrame = MR_C.PulleyCFrame *CFrame.Angles(-PullAngle_2, 0, 0)
|
||||
MR.Pulley2.CFrame = MR_C.Pulley2CFrame *CFrame.Angles(PullAngle_2, 0, 0)
|
||||
MR.Governor.CFrame = MR_C.GovernorCFrame *CFrame.Angles(0, PullAngle_2, 0)
|
||||
MR.GovernorFlyballs.CFrame = MR_C.GovernorFlyballsCFrame*CFrame.Angles(PullAngle, 0, 0)
|
||||
MR.PiePlatePulley.CFrame = MR_C.PieplatePulleyCFrame *CFrame.Angles(PullAngle_2, 0, 0)
|
||||
end
|
||||
|
||||
function MovingObjects:Frame_PiePlate()
|
||||
function MovingObjects:Frame_PiePlate(Delta, ElevatorVelocity_Y)
|
||||
local MR = self.MachineRoom
|
||||
local MR_C = MR._CFrame
|
||||
|
||||
MR.PiePlateSelector.CFrame = MR_C.PieplateSelectorCFrame+Vector3.new(0, Delta/580, 0)
|
||||
MR.PiePlatePlates.CFrame = MR_C.PiePlatePlatesCFrame *CFrame.Angles(-math.rad(Delta*5), 0, 0)
|
||||
end
|
||||
|
||||
return MovingObjects
|
||||
@@ -1,38 +0,0 @@
|
||||
local PPSModule = {}
|
||||
PPSModule.__index = PPSModule
|
||||
|
||||
PPSModule.Delta = 0
|
||||
|
||||
local RS: RunService = game:GetService("RunService")
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
local Easing = require(Storage:WaitForChild("AlgebraEasings"))
|
||||
|
||||
function PPSModule.constructor(PieplateSelector: UnionOperation, PiePlatePlates: UnionOperation, ElevatorBox: UnionOperation)
|
||||
return setmetatable({
|
||||
PieplateSelector = PieplateSelector,
|
||||
PiePlatePlates = PiePlatePlates,
|
||||
ElevatorBox = ElevatorBox
|
||||
}, PPSModule)
|
||||
end
|
||||
|
||||
local SelectorTween = Tween.constructor()
|
||||
|
||||
function PPSModule:test()
|
||||
self.PieplateSelector.CFrame=self.PieplateSelector.CFrame+Vector3.yAxis/20
|
||||
|
||||
local OriginalAngleDelta = self.PiePlatePlates.CFrame
|
||||
local OriginalPositionDelta = self.PieplateSelector.CFrame
|
||||
|
||||
self.__SelectorConnection = RS.Heartbeat:Connect(function(_dt)
|
||||
PPSModule.Delta+=1
|
||||
|
||||
self.PieplateSelector.CFrame=OriginalPositionDelta+Vector3.new(0, PPSModule.Delta/580, 0)
|
||||
self.PiePlatePlates.CFrame=OriginalAngleDelta*CFrame.Angles(-math.rad(PPSModule.Delta*5), 0, 0)
|
||||
end)
|
||||
|
||||
return self.__SelectorConnection
|
||||
end
|
||||
|
||||
return PPSModule
|
||||
@@ -8,17 +8,19 @@ local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RS: RunService = game:GetService("RunService")
|
||||
|
||||
local TagsModule = require(Storage:WaitForChild("Tags"))
|
||||
local Easings = require(Storage:WaitForChild("AlgebraEasings"))
|
||||
local Easings = require(Storage:WaitForChild("Algebra"))
|
||||
|
||||
local Leveling = require(script:WaitForChild("Leveling"))
|
||||
local Doors = require(script:WaitForChild("Doors"))
|
||||
local PieplateModule = require(script:WaitForChild("PiePlateSelector"))
|
||||
local MovingObjects = require(script:WaitForChild("MovingObjects"))
|
||||
|
||||
local Enums = require(Elevators:WaitForChild("Enums"))
|
||||
local ElevatorMover = require(Elevators:WaitForChild("Mover"))
|
||||
local ButtonTags = require(Elevators:WaitForChild("Buttons"))
|
||||
local TractionRopes = require(Elevators:WaitForChild("TractionRopes"))
|
||||
local Lanterns = require(Elevators:WaitForChild("Lanterns"))
|
||||
|
||||
type rbxassetid = string
|
||||
|
||||
type Tags = TagsModule.ExportedTags
|
||||
type TagsConstructor = TagsModule.TagsConstructor
|
||||
@@ -28,20 +30,27 @@ type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
--Class functions
|
||||
_MoveFloors: (self: ClassConstructor, Level: number) -> (),
|
||||
__MoveFloors: (self: ClassConstructor, Level: number, RequestedLevel: number, GoingUp: boolean) -> (),
|
||||
GoToLevel: (self: ClassConstructor, RequestedLevel: number) -> ()
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Impl_Static_Props = {
|
||||
Moving: boolean,
|
||||
Responsiveness: number,
|
||||
MaxVelocity: number
|
||||
MaxVelocity: number,
|
||||
ButtonActivatedColor: Color3,
|
||||
LanternDisplayColorOn: Color3,
|
||||
LanternDisplayColorOff: Color3,
|
||||
LanternChimeDirection: rbxassetid,
|
||||
LanternChimeLanding: rbxassetid,
|
||||
__Moving: boolean,
|
||||
__CurrentFloor: number
|
||||
}
|
||||
|
||||
type Constructor_Fun = (TagsConstructor: TagsConstructor) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
Tags: Tags,
|
||||
MOConstructor: MovingObjects.MovingObjectsConstructor,
|
||||
LanternsConstructor: Lanterns.LanternsConstructor,
|
||||
ElevatorBox_1960: UnionOperation,
|
||||
ElevatorDoor1: BasePart,
|
||||
ElevatorDoor2: BasePart,
|
||||
@@ -52,59 +61,52 @@ type Constructor_Return_Props = {
|
||||
ElevatorDoors: Doors.DoorConstructor,
|
||||
Ropes: {Instance},
|
||||
TractionRopes: TractionRopes.TractionRopesConstructor,
|
||||
PiePlateSelector: UnionOperation,
|
||||
Pulley: UnionOperation,
|
||||
Pulley2: UnionOperation,
|
||||
Governor: UnionOperation,
|
||||
GovernorFlyballs: UnionOperation,
|
||||
GovernorFlyballs: Part,
|
||||
PieplatePulley: UnionOperation,
|
||||
Audio_ChimeDirection: Sound,
|
||||
Audio_ChimeLanding: Sound,
|
||||
MachineRoom: MovingObjects.MachineRoom,
|
||||
__MovingConnection: RBXScriptConnection?,
|
||||
}
|
||||
|
||||
type ButtonFunction = () -> ()
|
||||
type ButtonFunction = (self: ClassConstructor, ButtonName: string, ButtonsConstructor: ButtonTags.ButtonsConstructor, ButtonTree: ButtonTags.ButtonProperties) -> ()
|
||||
|
||||
local Otis1960 = {} :: Impl_Constructor
|
||||
Otis1960.__index = Otis1960
|
||||
|
||||
Otis1960.Moving = false
|
||||
Otis1960.Responsiveness = 50
|
||||
Otis1960.MaxVelocity = 10
|
||||
Otis1960.ButtonActivatedColor = Color3.fromRGB(180,0,0)
|
||||
Otis1960.LanternDisplayColorOn = Color3.fromRGB(255,114,71)
|
||||
Otis1960.LanternDisplayColorOff = Color3.fromRGB(55,55,55)
|
||||
Otis1960.LanternChimeDirection = "rbxassetid://16990287228"
|
||||
Otis1960.LanternChimeLanding = "rbxassetid://16990290265"
|
||||
--*read-only*
|
||||
Otis1960.__Moving = false
|
||||
Otis1960.__CurrentFloor = 1
|
||||
|
||||
local function ButtonPress(Button: BasePart, Activated: boolean)
|
||||
task.spawn(function()
|
||||
local Glass = Button:FindFirstChild("Glass") :: BasePart
|
||||
if Glass then
|
||||
Glass.Position+=Glass.CFrame.LookVector/50
|
||||
local ButtonFunctions: {[Enums.ButtonTreeValues]: ButtonFunction} = {
|
||||
[Enums.ButtonTree.Landing] = function(self, ButtonName, ButtonsConstructor, ButtonTree)
|
||||
|
||||
if not Activated then
|
||||
Glass.Material = Enum.Material.Neon
|
||||
Glass.Color = Color3.fromRGB(180,0,0)
|
||||
Glass.Transparency = 0
|
||||
end
|
||||
end
|
||||
Button.Position+=Glass.CFrame.LookVector/50
|
||||
end,
|
||||
|
||||
[Enums.ButtonTree.Car] = function(self, ButtonName, ButtonsConstructor, ButtonTree)
|
||||
local DecodedFloor = ButtonsConstructor:DecodeCarTag(ButtonName)
|
||||
if not DecodedFloor then
|
||||
|
||||
task.wait(.30)
|
||||
if Glass then
|
||||
Glass.Position-=Glass.CFrame.LookVector/50
|
||||
end
|
||||
Button.Position-=Glass.CFrame.LookVector/50
|
||||
|
||||
ButtonsConstructor:HookPromptButtonsGroup(ButtonTree.Prompt, ButtonTree.Inst :: BasePart?, function(_Player: Player)
|
||||
if DecodedFloor then
|
||||
--ButtonTree.Prompt.Enabled = false
|
||||
ButtonsConstructor:AestheticActivateButton(ButtonTree.Inst :: BasePart, false, Otis1960.ButtonActivatedColor)
|
||||
self:GoToLevel(DecodedFloor)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local ButtonFunctions: {[Enums.EnumButtonTree]: ButtonFunction} = {
|
||||
[Enums.ButtonTree.Landing] = function()
|
||||
|
||||
end,
|
||||
|
||||
[Enums.ButtonTree.Car] = function()
|
||||
|
||||
end,
|
||||
|
||||
[Enums.ButtonTree.Special] = function()
|
||||
[Enums.ButtonTree.Special] = function(self, ButtonName, ButtonsConstructor, ButtonTree)
|
||||
|
||||
end
|
||||
}
|
||||
@@ -114,26 +116,9 @@ local function HookButtons(self: ClassConstructor, ButtonsConstructor: ButtonTag
|
||||
for ButtonName, ButtonTree in ButtonList do
|
||||
if ButtonTree.Prompt then
|
||||
if ButtonTree.Inst then
|
||||
if ButtonNameType == Enums.ButtonTree.Car then
|
||||
local DecodedFloor = ButtonsConstructor:DecodeCarTag(ButtonName)
|
||||
|
||||
ButtonsConstructor:HookPromptButtonsGroup(ButtonTree.Prompt, ButtonTree.Inst, function(_Player: Player)
|
||||
if DecodedFloor then
|
||||
--ButtonTree.Prompt.Enabled = false
|
||||
ButtonPress(ButtonTree.Inst, false)
|
||||
|
||||
self:GoToLevel(DecodedFloor)
|
||||
end
|
||||
end)
|
||||
elseif ButtonNameType == Enums.ButtonTree.Special then
|
||||
|
||||
elseif ButtonNameType == Enums.ButtonTree.Landing then
|
||||
ButtonsConstructor:HookPromptButtonsGroup(ButtonTree.Prompt, ButtonTree.Inst, function(_Player: Player)
|
||||
ButtonTree.Prompt.Enabled = false
|
||||
ButtonPress(ButtonTree.Inst, false)
|
||||
|
||||
|
||||
end)
|
||||
local Button = ButtonFunctions[ButtonNameType :: Enums.ButtonTreeValues]
|
||||
if Button then
|
||||
Button(self, ButtonName, ButtonsConstructor, ButtonTree)
|
||||
end
|
||||
else
|
||||
warn(`{ButtonTree} is missing the field "Inst"`)
|
||||
@@ -152,31 +137,27 @@ function Otis1960.constructor(TagsConstructor)
|
||||
self.ElevatorDoor2 = TagsConstructor:Request("ElevatorDoor_1960_2") :: BasePart
|
||||
self.ElevatorDoorSensor = TagsConstructor:Request("ElevatorDoor_Sensor_1960") :: Folder
|
||||
self.Ropes = TagsConstructor:Request("1960_ElevatorPulleyRope") :: {Instance}
|
||||
self.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation
|
||||
self.PiePlatePlates = TagsConstructor:Request("Otis1960_PiePlatePlates") :: UnionOperation
|
||||
|
||||
--Rotation objects
|
||||
self.MachineRoom = {} :: MovingObjects.MachineRoom
|
||||
self.MachineRoom = {_CFrame = {}} :: MovingObjects.MachineRoom
|
||||
self.MachineRoom.Pulley = TagsConstructor:Request("Otis1960_Pulley") :: UnionOperation
|
||||
self.MachineRoom.Pulley2 = TagsConstructor:Request("Otis1960_Pulley2") :: UnionOperation
|
||||
self.MachineRoom.Governor = TagsConstructor:Request("Otis1960_Governor") :: UnionOperation
|
||||
self.MachineRoom.GovernorFlyballs = TagsConstructor:Request("Otis1960_GovernorFlyballs") :: UnionOperation
|
||||
self.MachineRoom.PieplatePulley = TagsConstructor:Request("Otis1960_PieplatePulley") :: UnionOperation
|
||||
self.MachineRoom.GovernorFlyballs = TagsConstructor:Request("Otis1960_GovernorFlyballs") :: Part
|
||||
self.MachineRoom.PiePlatePulley = TagsConstructor:Request("Otis1960_PieplatePulley") :: UnionOperation
|
||||
self.MachineRoom.PiePlatePlates = TagsConstructor:Request("Otis1960_PiePlatePlates") :: UnionOperation
|
||||
self.MachineRoom.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation
|
||||
|
||||
self.MOConstructor = MovingObjects.constructor({
|
||||
MachineRoom = self.MachineRoom
|
||||
} :: MovingObjects.InstanceTree)
|
||||
self.MOConstructor = MovingObjects.constructor({MachineRoom = self.MachineRoom} :: MovingObjects.InstanceTree)
|
||||
|
||||
--Audio
|
||||
local Lantern = TagsConstructor:Request("Otis1960_LanternDisplayMain") :: UnionOperation
|
||||
local LanternDisplay = TagsConstructor:Request("Otis1960_LanternDisplayMain") :: UnionOperation
|
||||
local LaternTags = Lanterns.Get(TagsConstructor, Enums.Elevator.Otis1960) :: Lanterns.Lanterns
|
||||
|
||||
self.Audio_ChimeDirection = Instance.new("Sound") :: Sound
|
||||
self.Audio_ChimeDirection.SoundId = "rbxassetid://16990287228"
|
||||
self.Audio_ChimeDirection.Parent = Lantern
|
||||
|
||||
self.Audio_ChimeLanding = Instance.new("Sound") :: Sound
|
||||
self.Audio_ChimeLanding.SoundId = "rbxassetid://16990290265"
|
||||
self.Audio_ChimeLanding.Parent = Lantern
|
||||
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, Otis1960.LanternChimeDirection, Otis1960.LanternChimeLanding, LaternTags, {
|
||||
Active = Otis1960.LanternDisplayColorOn,
|
||||
Off = Otis1960.LanternDisplayColorOff
|
||||
} :: Lanterns.Colors)
|
||||
|
||||
self.BoxAttachment,
|
||||
self.BoxAlignPosition,
|
||||
@@ -184,7 +165,6 @@ function Otis1960.constructor(TagsConstructor)
|
||||
|
||||
self.ElevatorDoors = Doors.constructor(self.ElevatorBox_1960, self.ElevatorDoor1, self.ElevatorDoor2, self.ElevatorDoorSensor)
|
||||
self.TractionRopes = TractionRopes.constructor(self.Ropes, self.ElevatorBox_1960, Leveling)
|
||||
self.PiePlate = PieplateModule.constructor(self.PiePlateSelector, self.PiePlatePlates, self.ElevatorBox_1960)
|
||||
|
||||
--Buttons
|
||||
local ButtonsConstructor = ButtonTags.constructor(TagsConstructor, Enums.Elevator.Otis1960)
|
||||
@@ -193,22 +173,32 @@ function Otis1960.constructor(TagsConstructor)
|
||||
local ClassConstructor = setmetatable(self, Otis1960)
|
||||
HookButtons(ClassConstructor, ButtonsConstructor, Enums.ButtonTree.Car)
|
||||
|
||||
print("[DEBUG] Otis1960 Lanterns=", LaternTags)
|
||||
print("[DEBUG] Otis1960 Buttons=", Otis1960_Buttons)
|
||||
print("🔝 Otis1960 initialized and ready")
|
||||
return ClassConstructor
|
||||
end
|
||||
|
||||
function Otis1960:_MoveFloors(Level)
|
||||
function Otis1960:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
|
||||
local RotationDelta = 0
|
||||
local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position
|
||||
|
||||
if self.__MovingConnection and self.__MovingConnection.Connected then
|
||||
self.__MovingConnection:Disconnect()
|
||||
end
|
||||
--Otis1960_ShaftGovernor
|
||||
|
||||
self.__MovingConnection = RS.Heartbeat:Connect(function(_dt) --Not safe for parallel
|
||||
self.MOConstructor:UpdateCFrame()
|
||||
|
||||
if GoingUp then
|
||||
self.LanternsConstructor:DirectionUp(true)
|
||||
else
|
||||
self.LanternsConstructor:DirectionDown(true)
|
||||
end
|
||||
|
||||
--Otis1960_ShaftGovernor
|
||||
self.__MovingConnection = RS.Stepped:Connect(function(_delta, _dt) --Not safe for parallel
|
||||
RotationDelta+=1
|
||||
Otis1960.__Moving = true
|
||||
|
||||
local ElevatorPosition: Vector3 = self.ElevatorBox_1960.Position
|
||||
local ElevatorVelocityY: number = self.ElevatorBox_1960:GetVelocityAtPosition(ElevatorPosition).Y
|
||||
@@ -216,21 +206,51 @@ function Otis1960:_MoveFloors(Level)
|
||||
self.MOConstructor:Frame_Pullies(RotationDelta, ElevatorVelocityY)
|
||||
self.TractionRopes:Move(26.3, ElevatorPosition)
|
||||
|
||||
if ElevatorPosition.Y>=self.BoxAlignPosition.Position.Y then
|
||||
--Kill the connection
|
||||
if GoingUp then
|
||||
if ElevatorPosition.Y>=self.BoxAlignPosition.Position.Y-4 then
|
||||
self.BoxAlignPosition.MaxVelocity = .35
|
||||
self.LanternsConstructor:Toggle(true, RequestedLevel)
|
||||
end
|
||||
|
||||
if ElevatorPosition.Y>=self.BoxAlignPosition.Position.Y-.5 then
|
||||
(self.__MovingConnection :: RBXScriptConnection):Disconnect()
|
||||
print("Dead")
|
||||
|
||||
Otis1960.__Moving = false
|
||||
Otis1960.__CurrentFloor = RequestedLevel
|
||||
self.BoxAlignPosition.MaxVelocity = Otis1960.MaxVelocity
|
||||
|
||||
self.LanternsConstructor:Reset()
|
||||
end
|
||||
else
|
||||
if ElevatorPosition.Y<=self.BoxAlignPosition.Position.Y+4 then
|
||||
self.BoxAlignPosition.MaxVelocity = .35
|
||||
self.LanternsConstructor:Toggle(true, RequestedLevel)
|
||||
end
|
||||
|
||||
if ElevatorPosition.Y<=self.BoxAlignPosition.Position.Y+.5 then
|
||||
(self.__MovingConnection :: RBXScriptConnection):Disconnect()
|
||||
|
||||
Otis1960.__Moving = false
|
||||
Otis1960.__CurrentFloor = RequestedLevel
|
||||
self.BoxAlignPosition.MaxVelocity = Otis1960.MaxVelocity
|
||||
|
||||
self.LanternsConstructor:Reset()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, Level, ElevatorBoxCurrentPos.Z)
|
||||
self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, GoalLevelVEC, ElevatorBoxCurrentPos.Z)
|
||||
end
|
||||
|
||||
function Otis1960:GoToLevel(RequestedLevel)
|
||||
local level: number = Leveling[RequestedLevel]
|
||||
if level and level ~= 0 then
|
||||
self:_MoveFloors(level)
|
||||
local GoalLevelVEC: number = Leveling[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! requested landing: {tostring(RequestedLevel)}`)
|
||||
warn(`[{Enums.Elevator.Otis1960}]: landing out of range or equals the same range as goal! requested landing: {tostring(RequestedLevel)}`)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -7,34 +7,34 @@
|
||||
type EaseFunction = (n: number) -> number
|
||||
type LinearFunction = (a: number, b: number, t: number) -> number
|
||||
|
||||
export type EasingStyles = {
|
||||
export type Math = {
|
||||
Linear: LinearFunction,
|
||||
InOutBack: EaseFunction,
|
||||
OutBounce: EaseFunction,
|
||||
InQuad: EaseFunction
|
||||
InQuad: EaseFunction,
|
||||
}
|
||||
|
||||
local Ease = {} :: EasingStyles
|
||||
local Math = {} :: Math
|
||||
--Google straight up gives wrong/bad math
|
||||
|
||||
function Ease.Linear(a,b,t)
|
||||
function Math.Linear(a,b,t)
|
||||
return a-a*t+b*t
|
||||
end
|
||||
|
||||
local c = 2.59491
|
||||
function Ease.InOutBack(n)
|
||||
function Math.InOutBack(n)
|
||||
return n<.5 and 2*n*n*(-c+2*n+2*c*n) or 3*(-1+n)*(-1+n)*(-2-c+2*n+2*c*n)
|
||||
end
|
||||
|
||||
local n1, d1 = 7.5625, 2.75
|
||||
function Ease.OutBounce(n)
|
||||
function Math.OutBounce(n)
|
||||
return (n<0.363636 and n*n*n1 or
|
||||
n<0.727273 and (.75*(1.*d1-2.*n*n1)) or
|
||||
n<0.909091 and (.9375*(1.*d1-2.4*n*n1)/d1)) or (.984375*(1.*d1-2.66667*n*n1))/d1
|
||||
end
|
||||
|
||||
function Ease.InQuad(n)
|
||||
function Math.InQuad(n)
|
||||
return n*n
|
||||
end
|
||||
|
||||
return Ease
|
||||
return Math
|
||||
@@ -43,7 +43,7 @@ function Tags.constructor()
|
||||
end
|
||||
|
||||
function Tags:Request(Name)
|
||||
return self.__export[Name] or error(`Error requesting tag name, tag name "{Name}" does not exist`, 2)
|
||||
return self.__export[Name] or error(`Error requesting tag name, tag name "{Name}" does not exist.`, 2)
|
||||
end
|
||||
|
||||
function Tags:Nuke()
|
||||
|
||||
Reference in New Issue
Block a user