Haughton elevator and work on the buttons and new structure

This commit is contained in:
2024-08-20 16:29:06 -04:00
parent 7bae24c918
commit 8af537f9de
13 changed files with 419 additions and 259 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,86 @@
--!optimize 2
--!native
--!strict
local Elevators = script.Parent
local Main = Elevators.Parent
local Storage = game:GetService("ReplicatedStorage")
local Enums = require(Storage:WaitForChild("Enums"))
local Map = Main:WaitForChild("Map")
local PromptModule = require(Map:WaitForChild("Prompts"))
local Tags = require(Map:WaitForChild("Load"):WaitForChild("Tags"))
type FloorButtonActivatedCallback = (ButtonFloor: number | string) -> ()
type StopButtonActivatedCallback = (Toggled: boolean) -> ()
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
CarButton: (self: ClassConstructor, ButtonID: string, ButtonTree: Tags.ButtonProperties, Callback: FloorButtonActivatedCallback, Fallback: FloorButtonActivatedCallback) -> (),
LandingButton: (self: ClassConstructor, ButtonID: string, ButtonTree: Tags.ButtonProperties, Callback: FloorButtonActivatedCallback, Fallback: FloorButtonActivatedCallback) -> (),
SpecialButton: (self: ClassConstructor, ButtonName: Enums.SpecialButtonValues, ButtonID: string, ButtonTree: Tags.ButtonProperties, Callback: StopButtonActivatedCallback) -> (),
}
type Constructor_Fun = (CurrentFloor: IntValue) -> ClassConstructor
type Constructor_Return_Props = {
CurrentFloor: IntValue
}
export type ButtonsConstructor = ClassConstructor
local ButtonFunctions = {} :: Impl_Constructor
ButtonFunctions.__index = ButtonFunctions
--ButtonTags.ButtonsConstructor
function ButtonFunctions.constructor(CurrentFloor)
return setmetatable({CurrentFloor = CurrentFloor}, ButtonFunctions)
end
function ButtonFunctions:CarButton(ButtonID, ButtonTree, Callback, Fallback)
local DecodedCarFloorTag = Tags.Decoders.CarTag(ButtonID)
if DecodedCarFloorTag then
local Prompt = PromptModule.constructor(ButtonTree.Prompt :: ProximityPrompt, ButtonTree.Inst :: Instance)
Prompt:Triggered(function(Player: Player, _, __)
if DecodedCarFloorTag == self.CurrentFloor.Value then
Fallback(DecodedCarFloorTag)
else
Callback(DecodedCarFloorTag)
end
end)
end
end
function ButtonFunctions:LandingButton(ButtonID, ButtonTree, Callback, Fallback)
local DecodedHallFloorTag = Tags.Decoders.HallTag(ButtonID)
if DecodedHallFloorTag then
local Prompt = PromptModule.constructor(ButtonTree.Prompt :: ProximityPrompt, ButtonTree.Inst :: Instance)
Prompt:Triggered(function(Player: Player, _, __)
if DecodedHallFloorTag == self.CurrentFloor.Value then
Fallback(DecodedHallFloorTag)
else
Callback(DecodedHallFloorTag)
end
end)
end
end
function ButtonFunctions:SpecialButton(ButtonID, ButtonName, ButtonTree, Callback)
--precomputing speed
if ButtonID == Enums.SpecialButton.Stop then
local Prompt = PromptModule.constructor(ButtonTree.Prompt :: ProximityPrompt, ButtonTree.Inst :: Instance)
local Toggled = false
Prompt:Triggered(function(Player: Player, _, __)
Toggled = not Toggled
Callback(Toggled)
end)
else
warn(``)
end
end
return ButtonFunctions

View File

@@ -1,135 +0,0 @@
--!optimize 2
--!native
--!strict
local Elevators = script.Parent
local Main = Elevators.Parent
local Load = Main:WaitForChild("Load")
local Storage = game:GetService("ReplicatedStorage")
local Enums = require(Storage:WaitForChild("Enums"))
local PromptModule = require(Main:WaitForChild("Map"):WaitForChild("Prompts"))
local Tags = require(Load:WaitForChild("Tags"))
type FloorButtonActivatedCallback = (ButtonFloor: number) -> ()
type FloorButtonActivatedFallback = FloorButtonActivatedCallback
type StopButtonActivatedCallback = (Toggled: SpecialButtonToggle) -> ()
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
CarButton: (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) -> (),
} & Impl_Static_Props
type Impl_Static_Props = {
ButtonHoldDuration: number,
AestheticDeactivateTime: number
}
type Constructor_Fun = (ElevatorAttributes: ElevatorAttributes, ElevatorButtonColors: ElevatorButtonColors) -> ClassConstructor
type Constructor_Return_Props = {
ElevatorAttributes: ElevatorAttributes,
ElevatorButtonColors: ElevatorButtonColors
}
type ElevatorAttributes = {
CurrentFloor: IntValue,
Moving: BoolValue,
}
type ElevatorEvents = {
ButtonActivated: BindableEvent
}
type ElevatorButtonColors = {
ButtonActivated: Color3,
ButtonDeactivated: Color3,
LanternDisplayOn: Color3,
LanternDisplayOff: Color3,
}
export type SpecialButtonToggle = boolean
export type ButtonsConstructor = ClassConstructor
local ButtonFunctions = {} :: Impl_Constructor
ButtonFunctions.__index = ButtonFunctions
ButtonFunctions.ButtonHoldDuration = .30
ButtonFunctions.AestheticDeactivateTime = .30
--ButtonTags.ButtonsConstructor
function ButtonFunctions.constructor(ElevatorAttributes, ElevatorButtonColors)
return setmetatable({
ElevatorAttributes = ElevatorAttributes,
ElevatorButtonColors = ElevatorButtonColors
}, ButtonFunctions)
end
function ButtonFunctions:CarButton(ButtonID, ButtonTree, Callback, Fallback)
local DecodedCarFloorTag = Tags.Decoders.CarTag(ButtonID)
if DecodedCarFloorTag then
local Prompt = PromptModule.constructor(ButtonTree.Prompt :: ProximityPrompt, ButtonTree.Inst :: Instance)
Prompt:Triggered(function(Player: Player, _, __)
self:AestheticActivateButton(ButtonTree.Inst :: BasePart)
if DecodedCarFloorTag == self.ElevatorAttributes.CurrentFloor.Value then
Fallback(DecodedCarFloorTag)
task.delay(ButtonFunctions.AestheticDeactivateTime, function()
self:__DeactivateButton(ButtonTree.Inst :: BasePart, (ButtonTree.Inst :: Instance):FindFirstChild("Glass") :: BasePart?)
end)
else
Callback(DecodedCarFloorTag)
end
end)
end
end
function ButtonFunctions:LandingButton(ButtonID, ButtonTree, Callback, Fallback)
local DecodedHallFloorTag = Tags.Decoders.HallTag(ButtonID)
if DecodedHallFloorTag then
local Prompt = PromptModule.constructor(ButtonTree.Prompt :: ProximityPrompt, ButtonTree.Inst :: Instance)
Prompt:Triggered(function(Player: Player, _, __)
self:AestheticActivateButton(ButtonTree.Inst :: BasePart)
if DecodedHallFloorTag == self.ElevatorAttributes.CurrentFloor.Value then
Fallback(DecodedHallFloorTag)
task.delay(ButtonFunctions.AestheticDeactivateTime, function()
self:__DeactivateButton(ButtonTree.Inst :: BasePart, (ButtonTree.Inst :: Instance):FindFirstChild("Glass") :: BasePart?)
end)
else
Callback(DecodedHallFloorTag)
end
end)
end
end
function ButtonFunctions:SpecialButton(ButtonID, ButtonName, ButtonTree, Callback)
--precomputing speed
if ButtonID == Enums.SpecialButton.Stop then
local Prompt = PromptModule.constructor(ButtonTree.Prompt :: ProximityPrompt, ButtonTree.Inst :: Instance)
local Toggled = false
Prompt:Triggered(function(Player: Player, _, __)
Toggled = not Toggled
Callback(Toggled)
end)
else
warn(``)
end
end
return ButtonFunctions

View File

@@ -0,0 +1,71 @@
--!optimize 2
--!native
--!strict
local ParentDir = script.Parent
local MapDir = ParentDir.Parent
local ElevatorDir = MapDir.Parent
local MainDir = ElevatorDir.Parent
local TagsModule = MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags")
local StorageService = game:GetService("ReplicatedStorage")
local Enums = require(StorageService:WaitForChild("Enums"))
local ButtonTags = require(TagsModule:WaitForChild("Buttons"))
local Tags = require(TagsModule)
local ButtonManager = require(ElevatorDir:WaitForChild("ButtonManager"))
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
Hook: (self: ClassConstructor) -> ()
}
type Constructor_Fun = (ElevatorModel: Enums.ElevatorValues, ButtonTags: Tags.ElevatorButtons, CurrentFloor: IntValue) -> ClassConstructor
type Constructor_Return_Props = {
ElevatorModel: Enums.ElevatorValues,
ButtonTags: Tags.ElevatorButtons,
CurrentFloor: IntValue
}
local Buttons = {} :: Impl_Constructor
Buttons.__index = Buttons
function Buttons.constructor(ElevatorModel, ButtonTags, CurrentFloor)
return setmetatable({
ElevatorModel = ElevatorModel,
ButtonTags = ButtonTags,
CurrentFloor = CurrentFloor,
}, Buttons)
end
local function CarButtonActivated(ButtonFloor: number | string)
print("Activated", ButtonFloor)
end
function Buttons:Hook()
local ButtonManagerConstructor = ButtonManager.constructor(self.CurrentFloor)
local ButtonTagsConstructor = ButtonTags.constructor(self.ButtonTags, self.ElevatorModel)
local Prompt = ButtonTagsConstructor:CreatePromptButtons()
for ButtonID: string, ButtonInstance: Instance in self.ButtonTags do
local CarButtonPrompts = Prompt[self.ElevatorModel].Car
for PromptType, PromptProperties in CarButtonPrompts do
if PromptProperties.Attachment and PromptProperties.Inst and PromptProperties.Prompt then
PromptProperties.Prompt.MaxActivationDistance = 2
PromptProperties.Attachment.Position-=Vector3.new(.01,0,0)
ButtonManagerConstructor:CarButton(ButtonID, PromptProperties, CarButtonActivated, function(ButtonFloor: number | string)
print("Fallback", ButtonFloor)
end)
else
warn()
end
end
end
end
return Buttons

View File

@@ -11,25 +11,53 @@ local StorageService = game:GetService("ReplicatedStorage")
local Types = MainDir:WaitForChild("Types") local Types = MainDir:WaitForChild("Types")
local Enums = require(StorageService:WaitForChild("Enums")) local Enums = require(StorageService:WaitForChild("Enums"))
local ElevatorTypes = require(Types:WaitForChild("Elevator")) local ElevatorTypes = require(Types:WaitForChild("Elevator"))
local SoundEnums = require(Types:WaitForChild("Enums"):WaitForChild("Sounds")) --local SoundEnums = require(Types:WaitForChild("Enums"):WaitForChild("Sounds"))
local HaughtonConfiguration = {} :: ElevatorTypes.ElevatorConfigurationTable local HaughtonConfiguration = {} :: ElevatorTypes.ElevatorConfigurationTable
HaughtonConfiguration.Name = Enums.Elevator.Haughton HaughtonConfiguration.Name = Enums.Elevator.Haughton
HaughtonConfiguration.FloorLevelingDistance = 4 HaughtonConfiguration.FloorLevelingDistance = 6
HaughtonConfiguration.FloorLeveling3PhaseDistance = 1.5 HaughtonConfiguration.FloorLeveling3PhaseDistance = 1.5
HaughtonConfiguration.LevelingVelocity = 1 HaughtonConfiguration.LevelingVelocity = .5
HaughtonConfiguration.Phase3LevelingVelocity = 1 HaughtonConfiguration.Phase3LevelingVelocity = .5
HaughtonConfiguration.ParkedDistance = 0.2 HaughtonConfiguration.ParkedDistance = 0.2
HaughtonConfiguration.Responsiveness = 5 HaughtonConfiguration.Responsiveness = 5
HaughtonConfiguration.MaxVelocity = 10 HaughtonConfiguration.MaxVelocity = 7
HaughtonConfiguration.Functions = { HaughtonConfiguration.Functions = {
ManualTravelStart = true ManualTravelStart = true
} }
HaughtonConfiguration.Colors = { HaughtonConfiguration.Colors = {
ButtonActivated = Color3.fromRGB(180,0,0), ButtonActivated = {
ButtonDeactivated = Color3.fromRGB(139,139,139), Color = Color3.fromRGB(162, 106, 76),
LanternDisplayOn = Color3.fromRGB(44,255,157), Material = Enum.Material.Neon
LanternDisplayOff = Color3.fromRGB(255,29,101), },
ButtonDeactivated = {
Color = Color3.fromRGB(136, 143, 145),
Material = Enum.Material.SmoothPlastic
},
LanternIndicator = {
On = {
Up = {
Color = Color3.fromRGB(44, 255, 157),
Material = Enum.Material.Neon
},
Down = {
Color = Color3.fromRGB(255, 29, 101),
Material = Enum.Material.Neon
},
},
Off = {
Up = {
Color = Color3.fromRGB(172, 174, 197),
Material = Enum.Material.SmoothPlastic
},
Down = {
Color = Color3.fromRGB(172, 174, 197),
Material = Enum.Material.SmoothPlastic
},
}
}
} }
return HaughtonConfiguration return HaughtonConfiguration

View File

@@ -3,6 +3,12 @@
--!strict --!strict
return { return {
[1] = 1.163, [1] = 1.163, --Basement
[2] = 19.163, [2] = 19.163,
[3] = 37.507,
[4] = 55.464,
[5] = 73.383,
[6] = 91.301,
[7] = 109.243,
[8] = 127.185,
} }

View File

@@ -2,28 +2,127 @@
--!native --!native
--!strict --!strict
local ParentDir = script.Parent
local ElevatorsDir = ParentDir.Parent
local MainDir = ElevatorsDir.Parent.Parent
local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags"))
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor)) type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = { type Impl_Constructor = {
__index: Impl_Constructor, __index: Impl_Constructor,
constructor: Constructor_Fun, constructor: Constructor_Fun,
--Class functions --Class functions
RotateRelayCogs: (self: ClassConstructor, InwardsDirection: boolean, SextetRow: boolean, Faulting: boolean, MagnetCog: BasePart, Cog2: BasePart, CounterWeight: BasePart, Row3_RelayDown: BasePart) -> Tween RotateRelayCogs1Async: (self: ClassConstructor) -> (),
RotateRelayCogs2Async: (self: ClassConstructor) -> (),
RotateRelayCogs3: (self: ClassConstructor) -> (),
RotateRotodials: (self: ClassConstructor, Elevator_Y_Velocity: number) -> (),
RotatePulleyWheel: (self: ClassConstructor, TravelingUpwards: boolean, Elevator_Y_Velocity: number) -> (),
} & Impl_Static_Props
type Impl_Static_Props = {
RotateRotodialsSensitivity: number,
PulleyWheelRotationSensitivity: number
} }
type Constructor_Fun = () -> ClassConstructor type Constructor_Fun = (TagsConstructor: TagsModule.TagsConstructor) -> ClassConstructor
type Constructor_Return_Props = {} type Constructor_Return_Props = {
PulleyWheel: BasePart,
Cog2_Row1: BasePart,
Cog2_Row2: BasePart,
Cog2_Row3: BasePart,
Cog2_Row4: BasePart,
Relay_Close: Sound,
Relay_FullOpen: Sound,
Relay_Open: Sound,
MagnetCog_Row1: BasePart,
MagnetCog_Row2: BasePart,
MagnetCog_Row3: BasePart,
MagnetCog_Row4: BasePart,
Row1_CounterWeight: BasePart,
Row1_Flash: PointLight,
Row1_Relays: BasePart,
Row2_CounterWeight: BasePart,
Row2_Flash: PointLight,
Row2_Relays: BasePart,
Row3_CounterWeight: BasePart,
Row3_RelayDown: BasePart,
Row4_CounterWeight: BasePart,
Row4_Flash: PointLight,
Row4_Relays: BasePart,
Rotodials: {Instance}
}
local TS = game:GetService("TweenService") local TS = game:GetService("TweenService")
local MovingObjects = {} :: Impl_Constructor local MovingObjects = {} :: Impl_Constructor
MovingObjects.__index = MovingObjects MovingObjects.__index = MovingObjects
function MovingObjects.constructor() MovingObjects.RotateRotodialsSensitivity = 40
return setmetatable({}, MovingObjects) MovingObjects.PulleyWheelRotationSensitivity = 2
function MovingObjects.constructor(TagsConstructor)
local PulleyWheel = TagsConstructor:Request("Haughton_PulleyWheel") :: BasePart
local Cog2_Row1 = TagsConstructor:Request("Haughton_Cog2_Row1") :: BasePart
local Cog2_Row2 = TagsConstructor:Request("Haughton_Cog2_Row2") :: BasePart
local Cog2_Row3 = TagsConstructor:Request("Haughton_Cog2_Row3") :: BasePart
local Cog2_Row4 = TagsConstructor:Request("Haughton_Cog2_Row4") :: BasePart
local Haughton_Relay_Close = TagsConstructor:Request("Haughton_Relay_Close") :: Sound
local Haughton_Relay_FullOpen = TagsConstructor:Request("Haughton_Relay_FullOpen") :: Sound
local Haughton_Relay_Open = TagsConstructor:Request("Haughton_Relay_Open") :: Sound
local MagnetCog_Row1 = TagsConstructor:Request("Haughton_MagnetCog_Row1") :: BasePart
local MagnetCog_Row2 = TagsConstructor:Request("Haughton_MagnetCog_Row2") :: BasePart
local MagnetCog_Row3 = TagsConstructor:Request("Haughton_MagnetCog_Row3") :: BasePart
local MagnetCog_Row4 = TagsConstructor:Request("Haughton_MagnetCog_Row4") :: BasePart
local Row1_CounterWeight = TagsConstructor:Request("Haughton_Row1_CounterWeight") :: BasePart
local Row1_Flash = TagsConstructor:Request("Haughton_Row1_Flash") :: PointLight
local Row1_Relays = TagsConstructor:Request("Haughton_Row1_Relays") :: BasePart
local Row2_CounterWeight = TagsConstructor:Request("Haughton_Row2_CounterWeight") :: BasePart
local Row2_Flash = TagsConstructor:Request("Haughton_Row2_Flash") :: PointLight
local Row2_Relays = TagsConstructor:Request("Haughton_Row2_Relays") :: BasePart
local Row3_CounterWeight = TagsConstructor:Request("Haughton_Row3_CounterWeight") :: BasePart
local Row3_RelayDown = TagsConstructor:Request("Haughton_Row3_Relay_Down") :: BasePart
local Row4_CounterWeight = TagsConstructor:Request("Haughton_Row4_CounterWeight") :: BasePart
local Row4_Flash = TagsConstructor:Request("Haughton_Row4_Flash") :: PointLight
local Row4_Relays = TagsConstructor:Request("Haughton_Row4_Relays") :: BasePart
local Rotodials = TagsConstructor:Request("Haughton_Rotodial") :: {Instance}
return setmetatable({
PulleyWheel = PulleyWheel,
Cog2_Row1 = Cog2_Row1,
Cog2_Row2 = Cog2_Row2,
Cog2_Row3 = Cog2_Row3,
Cog2_Row4 = Cog2_Row4,
Relay_Close = Haughton_Relay_Close,
Relay_FullOpen = Haughton_Relay_FullOpen,
Relay_Open = Haughton_Relay_Open,
MagnetCog_Row1 = MagnetCog_Row1,
MagnetCog_Row2 = MagnetCog_Row2,
MagnetCog_Row3 = MagnetCog_Row3,
MagnetCog_Row4 = MagnetCog_Row4,
Row1_CounterWeight = Row1_CounterWeight,
Row1_Flash = Row1_Flash,
Row1_Relays = Row1_Relays,
Row2_CounterWeight = Row2_CounterWeight,
Row2_Flash = Row2_Flash,
Row2_Relays = Row2_Relays,
Row3_CounterWeight = Row3_CounterWeight,
Row3_RelayDown = Row3_RelayDown,
Row4_CounterWeight = Row4_CounterWeight,
Row4_Flash = Row4_Flash,
Row4_Relays = Row4_Relays,
Rotodials = Rotodials,
}, MovingObjects)
end end
function MovingObjects:RotateRelayCogs(InwardsDirection, SextetRow, Faulting, MagnetCog, Cog2, CounterWeight, Row_Relays) local function RotateRelayCogs(InwardsDirection: boolean, SextetRow: boolean, MagnetCog: BasePart, Cog2: BasePart, CounterWeight: BasePart, Row_Relays: BasePart): Tween
local CogTweenInfo = TweenInfo.new(InwardsDirection and .25 or (Faulting and 5 or 3), InwardsDirection and Enum.EasingStyle.Quad or Enum.EasingStyle.Elastic) local CogTweenInfo = TweenInfo.new(InwardsDirection and .105 or 3, InwardsDirection and Enum.EasingStyle.Quad or Enum.EasingStyle.Elastic)
local LinearTween = TweenInfo.new(.105, Enum.EasingStyle.Linear)
local MagnetCogTween = TS:Create(MagnetCog, CogTweenInfo, { local MagnetCogTween = TS:Create(MagnetCog, CogTweenInfo, {
CFrame = MagnetCog.CFrame*CFrame.Angles(math.rad(InwardsDirection and -90 or 90), 0, 0) CFrame = MagnetCog.CFrame*CFrame.Angles(math.rad(InwardsDirection and -90 or 90), 0, 0)
@@ -32,10 +131,10 @@ function MovingObjects:RotateRelayCogs(InwardsDirection, SextetRow, Faulting, Ma
CFrame = Cog2.CFrame*CFrame.Angles(math.rad(InwardsDirection and 90 or -90), 0, 0) CFrame = Cog2.CFrame*CFrame.Angles(math.rad(InwardsDirection and 90 or -90), 0, 0)
}) })
local CounterWeightTween = TS:Create(CounterWeight, TweenInfo.new(.105, Enum.EasingStyle.Linear), { local CounterWeightTween = TS:Create(CounterWeight, LinearTween, {
Position = InwardsDirection and CounterWeight.Position+Vector3.new(0,.23,0) or CounterWeight.Position-Vector3.new(0,.23,0) Position = CounterWeight.Position+Vector3.new(0,InwardsDirection and .23 or -.23,0)
}) })
local RelaysTween = TS:Create(Row_Relays, TweenInfo.new(.105, Enum.EasingStyle.Linear), { local RelaysTween = TS:Create(Row_Relays, LinearTween, {
CFrame = Row_Relays.CFrame*CFrame.Angles(0,0,math.rad(SextetRow and (InwardsDirection and 6 or -6) or InwardsDirection and -6 or 6)) CFrame = Row_Relays.CFrame*CFrame.Angles(0,0,math.rad(SextetRow and (InwardsDirection and 6 or -6) or InwardsDirection and -6 or 6))
}) })
@@ -47,4 +146,49 @@ function MovingObjects:RotateRelayCogs(InwardsDirection, SextetRow, Faulting, Ma
return MagnetCogTween return MagnetCogTween
end end
local function ElectricalFlash(Flash: PointLight)
Flash.Enabled = true
task.delay(.07, function()
Flash.Enabled = false
end)
end
function MovingObjects:RotateRelayCogs1Async()
self.Relay_Close:Play()
RotateRelayCogs(true, false, self.MagnetCog_Row3, self.Cog2_Row3, self.Row3_CounterWeight, self.Row3_RelayDown)
task.wait(.30)
RotateRelayCogs(true, false, self.MagnetCog_Row2, self.Cog2_Row2, self.Row2_CounterWeight, self.Row2_Relays)
task.wait(.30)
RotateRelayCogs(true, true, self.MagnetCog_Row4, self.Cog2_Row4, self.Row4_CounterWeight, self.Row4_Relays)
end
function MovingObjects:RotateRelayCogs2Async()
self.Relay_Open:Play()
RotateRelayCogs(false, false, self.MagnetCog_Row2, self.Cog2_Row2, self.Row2_CounterWeight, self.Row2_Relays)
ElectricalFlash(self.Row2_Flash)
RotateRelayCogs(true, true, self.MagnetCog_Row1, self.Cog2_Row1, self.Row1_CounterWeight, self.Row1_Relays)
task.wait(.1)
RotateRelayCogs(false, true,self.MagnetCog_Row4, self.Cog2_Row4, self.Row4_CounterWeight, self.Row4_Relays)
ElectricalFlash(self.Row4_Flash)
end
function MovingObjects:RotateRelayCogs3()
RotateRelayCogs(false, true, self.MagnetCog_Row1, self.Cog2_Row1, self.Row1_CounterWeight, self.Row1_Relays)
ElectricalFlash(self.Row1_Flash)
RotateRelayCogs(false, false, self.MagnetCog_Row3, self.Cog2_Row3, self.Row3_CounterWeight, self.Row3_RelayDown)
self.Relay_FullOpen:Play()
end
function MovingObjects:RotateRotodials(Elevator_Y_Velocity)
for n: number = 1, #self.Rotodials do
(self.Rotodials[n] :: BasePart).CFrame*=CFrame.Angles(math.rad(Elevator_Y_Velocity/MovingObjects.RotateRotodialsSensitivity),0,0)
end
end
function MovingObjects:RotatePulleyWheel(TravelingUpwards, Elevator_Y_Velocity)
self.PulleyWheel.CFrame*=CFrame.Angles(math.rad((TravelingUpwards and -Elevator_Y_Velocity or Elevator_Y_Velocity)/MovingObjects.PulleyWheelRotationSensitivity),0,0)
end
return MovingObjects return MovingObjects

View File

@@ -6,103 +6,45 @@ local ParentDir = script.Parent
local ElevatorsDir = ParentDir.Parent local ElevatorsDir = ParentDir.Parent
local MainDir = ElevatorsDir.Parent local MainDir = ElevatorsDir.Parent
local StorageService = game:GetService("ReplicatedStorage")
local Enums = require(StorageService:WaitForChild("Enums"))
local InitElevator = require(ElevatorsDir:WaitForChild("System")) local InitElevator = require(ElevatorsDir:WaitForChild("System"))
local Config = require(script:WaitForChild("Config")) local Config = require(script:WaitForChild("Config"))
local Buttons = require(script:WaitForChild("Buttons"))
local Leveling = require(script:WaitForChild("Leveling")) local Leveling = require(script:WaitForChild("Leveling"))
local MovingObjects = require(script:WaitForChild("MovingObjects")) local MovingObjects = require(script:WaitForChild("MovingObjects"))
local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags")) local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags"))
local function ElectricalFlash(Flash: PointLight)
Flash.Enabled = true
task.delay(.07, function()
Flash.Enabled = false
end)
end
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 ElevatorModel = TagsConstructor:Request("Elevator_Haughton") :: Model local ElevatorModel = TagsConstructor:Request("Elevator_Haughton") :: Model
local ElevatorBoxModel = ElevatorModel:WaitForChild("Mover") :: BasePart local ElevatorBoxModel = ElevatorModel:WaitForChild("Mover") :: BasePart
local MagnetCog_Row3 = TagsConstructor:Request("Haughton_MagnetCog_Row3") :: BasePart
local Cog2_Row3 = TagsConstructor:Request("Haughton_Cog2_Row3") :: BasePart
local Row3_CounterWeight = TagsConstructor:Request("Haughton_Row3_CounterWeight") :: BasePart
local Row3_RelayDown = TagsConstructor:Request("Haughton_Row3_Relay_Down") :: BasePart
local Haughton_Relay_Close = TagsConstructor:Request("Haughton_Relay_Close") :: Sound
local Haughton_Relay_Open = TagsConstructor:Request("Haughton_Relay_Open") :: Sound
local Haughton_Relay_FullOpen = TagsConstructor:Request("Haughton_Relay_FullOpen") :: Sound
local MagnetCog_Row1 = TagsConstructor:Request("Haughton_MagnetCog_Row1") :: BasePart
local Cog2_Row1 = TagsConstructor:Request("Haughton_Cog2_Row1") :: BasePart
local Row1_CounterWeight = TagsConstructor:Request("Haughton_Row1_CounterWeight") :: BasePart
local Row1_Relays = TagsConstructor:Request("Haughton_Row1_Relays") :: BasePart
local Row1_Flash = TagsConstructor:Request("Haughton_Row1_Flash") :: PointLight
local MagnetCog_Row2 = TagsConstructor:Request("Haughton_MagnetCog_Row2") :: BasePart
local Cog2_Row2 = TagsConstructor:Request("Haughton_Cog2_Row2") :: BasePart
local Row2_CounterWeight = TagsConstructor:Request("Haughton_Row2_CounterWeight") :: BasePart
local Row2_Relays = TagsConstructor:Request("Haughton_Row2_Relays") :: BasePart
local Row2_Flash = TagsConstructor:Request("Haughton_Row2_Flash") :: PointLight
local MagnetCog_Row4 = TagsConstructor:Request("Haughton_MagnetCog_Row4") :: BasePart
local Cog2_Row4 = TagsConstructor:Request("Haughton_Cog2_Row4") :: BasePart
local Row4_CounterWeight = TagsConstructor:Request("Haughton_Row4_CounterWeight") :: BasePart
local Row4_Relays = TagsConstructor:Request("Haughton_Row4_Relays") :: BasePart
local Row4_Flash = TagsConstructor:Request("Haughton_Row4_Flash") :: PointLight
--sneaky Machine room stuff hehe
local PulleyWheel = TagsConstructor:Request("Haughton_PulleyWheel") :: BasePart
local Elevator = InitElevator.constructor(ElevatorBoxModel, Config, Leveling) local Elevator = InitElevator.constructor(ElevatorBoxModel, Config, Leveling)
local MovingObjectsConstructor = MovingObjects.constructor()
task.wait(3) local MovingObjectsConstructor = MovingObjects.constructor(TagsConstructor)
task.spawn(function() local ButtonsConstructor = Buttons.constructor(Config.Name, ButtonTags, Elevator.Attributes.CurrentFloor)
Elevator:RequestLevelAsync(2, Enums.ElevatorCallDirection.Down)
end)
Elevator.Events.Traveling:Connect(function(_DeltaTime: number, CabPosition: Vector3) Elevator.Events.Traveling:Connect(function(_DeltaTime: number, CabPosition: Vector3)
local CabVelocity = ElevatorBoxModel:GetVelocityAtPosition(CabPosition) local CabVelocity = ElevatorBoxModel:GetVelocityAtPosition(CabPosition)
local Pulley_Y_Direction = (Elevator.Attributes.TravelingUpwards.Value and -CabVelocity.Y or CabVelocity.Y) local TravelingUpwards = Elevator.Attributes.TravelingUpwards.Value
PulleyWheel.CFrame*=CFrame.Angles(math.rad(Pulley_Y_Direction/2),0,0) MovingObjectsConstructor:RotatePulleyWheel(TravelingUpwards, CabVelocity.Y)
MovingObjectsConstructor:RotateRotodials(CabVelocity.Y)
end) end)
Elevator.Events.Progression:Connect(function(previousFloor: number, CurrentFloor: number, NextFloor: number) Elevator.Events.Progression:Connect(function(previousFloor: number, CurrentFloor: number, NextFloor: number)
warn("previousFloor=",previousFloor,"CurrentFloor=", CurrentFloor, "NextFloor=",NextFloor) warn("previousFloor=",previousFloor,"CurrentFloor=", CurrentFloor, "NextFloor=",NextFloor)
end) end)
Elevator.Events.Leveling:Connect(function() Elevator.Events.Leveling:Connect(function()
Haughton_Relay_Open:Play() MovingObjectsConstructor:RotateRelayCogs2Async()
MovingObjectsConstructor:RotateRelayCogs(false, false, false, MagnetCog_Row2, Cog2_Row2, Row2_CounterWeight, Row2_Relays)
ElectricalFlash(Row2_Flash)
MovingObjectsConstructor:RotateRelayCogs(true, true, false, MagnetCog_Row1, Cog2_Row1, Row1_CounterWeight, Row1_Relays)
task.wait(.1)
MovingObjectsConstructor:RotateRelayCogs(false, true, false, MagnetCog_Row4, Cog2_Row4, Row4_CounterWeight, Row4_Relays)
ElectricalFlash(Row4_Flash)
end) end)
Elevator.Events.Parked:Connect(function() Elevator.Events.Parked:Connect(function()
MovingObjectsConstructor:RotateRelayCogs(false, true, false, MagnetCog_Row1, Cog2_Row1, Row1_CounterWeight, Row1_Relays) MovingObjectsConstructor:RotateRelayCogs3()
ElectricalFlash(Row1_Flash)
MovingObjectsConstructor:RotateRelayCogs(false, false, false, MagnetCog_Row3, Cog2_Row3, Row3_CounterWeight, Row3_RelayDown)
Haughton_Relay_FullOpen:Play()
end) end)
Haughton_Relay_Close:Play() ButtonsConstructor:Hook()
MovingObjectsConstructor:RotateRelayCogs(true, false, false, MagnetCog_Row3, Cog2_Row3, Row3_CounterWeight, Row3_RelayDown)
task.wait(.30)
MovingObjectsConstructor:RotateRelayCogs(true, false, false, MagnetCog_Row2, Cog2_Row2, Row2_CounterWeight, Row2_Relays).Completed:Once(function()
MovingObjectsConstructor:RotateRelayCogs(true, true, true, MagnetCog_Row1, Cog2_Row1, Row1_CounterWeight, Row1_Relays)
task.wait(.35)
MovingObjectsConstructor:RotateRelayCogs(false, true, true, MagnetCog_Row1, Cog2_Row1, Row1_CounterWeight, Row1_Relays)
end)
task.wait(.30)
MovingObjectsConstructor:RotateRelayCogs(true, true, false, MagnetCog_Row4, Cog2_Row4, Row4_CounterWeight, Row4_Relays)
Elevator:StartTraveling() -- MovingObjectsConstructor:RotateRelayCogs1Async()
-- Elevator:StartTraveling()
end end

View File

@@ -306,7 +306,7 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC
if ElevatorPosition.Y>=LEVEL_VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLevelingDistance then if ElevatorPosition.Y>=LEVEL_VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLevelingDistance then
if not Debounce.Leveling then if not Debounce.Leveling then
self.Events.__eventInstances__.Leveling:Fire() self.Events.__eventInstances__.Leveling:Fire()
SmoothVelocity(self, self.Elevator.Configuration.LevelingVelocity, .5) SmoothVelocity(self, self.Elevator.Configuration.LevelingVelocity, 1)
Debounce.Leveling = true Debounce.Leveling = true
end end
@@ -338,7 +338,7 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LEVEL_VEC
if ElevatorPosition.Y<=LEVEL_VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLevelingDistance then if ElevatorPosition.Y<=LEVEL_VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLevelingDistance then
if not Debounce.Leveling then if not Debounce.Leveling then
self.Events.__eventInstances__.Leveling:Fire() self.Events.__eventInstances__.Leveling:Fire()
SmoothVelocity(self, self.Elevator.Configuration.LevelingVelocity, .5) SmoothVelocity(self, self.Elevator.Configuration.LevelingVelocity, 1)
Debounce.Leveling = true Debounce.Leveling = true
end end
@@ -394,7 +394,7 @@ function Elevator:__TravelToFloorAsync(Level_Int, LEVEL_VEC3_Y_WRAP)
--Set the elevator's AlignPosition to the floor Y vector --Set the elevator's AlignPosition to the floor Y vector
self.Elevator.AlignPosition.Position = Vector3.new(self.Elevator.AlignPosition.Position.X, LEVEL_VEC3_Y_WRAP.Y, self.Elevator.AlignPosition.Position.Z) self.Elevator.AlignPosition.Position = Vector3.new(self.Elevator.AlignPosition.Position.X, LEVEL_VEC3_Y_WRAP.Y, self.Elevator.AlignPosition.Position.Z)
--Set the elevator's velocity --Set the elevator's velocity
SmoothVelocity(self, self.Elevator.Configuration.MaxVelocity, 10) SmoothVelocity(self, self.Elevator.Configuration.MaxVelocity, 3)
end end
function Elevator:RequestLevelAsync(RequestedLevel, Direction) function Elevator:RequestLevelAsync(RequestedLevel, Direction)

View File

@@ -7,9 +7,10 @@
type HideEditor = (a1: BasePart | Folder, a2: boolean) -> () type HideEditor = (a1: BasePart | Folder, a2: boolean) -> ()
type LuaChangeableContainer = Script | LocalScript type LuaChangeableContainer = Script | LocalScript
local Players: Players = game:GetService("Players") local Players = game:GetService("Players")
local CS: CollectionService = game:GetService("CollectionService") local CS = game:GetService("CollectionService")
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage") local Storage = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService")
local ServerStorage = Storage:WaitForChild("Server") local ServerStorage = Storage:WaitForChild("Server")
@@ -70,7 +71,7 @@ function StudioEntities.indexAll(enabled: boolean)
if #StudioEntities.IndexedEntities == 0 then if #StudioEntities.IndexedEntities == 0 then
--Run when the server starts --Run when the server starts
local WorkspaceEnt = workspace:GetDescendants() local WorkspaceEnt = workspace:GetDescendants()
for i = 1, #WorkspaceEnt do for i = 1, #WorkspaceEnt do
local Item: Instance = WorkspaceEnt[i] local Item: Instance = WorkspaceEnt[i]
local Case: HideEditor = EditorEntities[Item.Name] local Case: HideEditor = EditorEntities[Item.Name]
@@ -80,8 +81,10 @@ function StudioEntities.indexAll(enabled: boolean)
end end
if Item:IsA("BasePart") then if Item:IsA("BasePart") then
if not RS:IsStudio() then
Item.Locked = true
end
Item.CanTouch = false --Do micro optimizations Item.CanTouch = false --Do micro optimizations
Item.Locked = true
--Security from exploiters --Security from exploiters
if not Item.Anchored and table.find(CS:GetTags(Item), "ServerGuard_Physics") then if not Item.Anchored and table.find(CS:GetTags(Item), "ServerGuard_Physics") then
@@ -96,7 +99,7 @@ function StudioEntities.indexAll(enabled: boolean)
elseif Item:IsA("LuaSourceContainer") then --Cant allow scripts outside of the framework elseif Item:IsA("LuaSourceContainer") then --Cant allow scripts outside of the framework
--mini algIsAorthim to see if the script is part of the rhpid-framework character or not --mini algIsAorthim to see if the script is part of the rhpid-framework character or not
local Model = Item:FindFirstAncestorOfClass("Model") local Model = Item:FindFirstAncestorOfClass("Model")
if Model and not Players:GetPlayerFromCharacter(Model) then if Model and not Players:GetPlayerFromCharacter(Model) then
if Item:IsA("Script") or Item:IsA("LocalScript") then if Item:IsA("Script") or Item:IsA("LocalScript") then
Item.Enabled = false Item.Enabled = false

View File

@@ -29,9 +29,8 @@ type Impl_Static_Props = {
DefaultHoldDuration: number DefaultHoldDuration: number
} }
type Constructor_Fun = (TagsConstructor: TagsConstructor, ModelButtons: Tags.ElevatorButtons, ElevatorModel: Enums.ElevatorValues) -> ClassConstructor type Constructor_Fun = (ModelButtons: Tags.ElevatorButtons, ElevatorModel: Enums.ElevatorValues) -> ClassConstructor
type Constructor_Return_Props = { type Constructor_Return_Props = {
Tags: TagsConstructor,
ModelButtons: Tags.ElevatorButtons, ModelButtons: Tags.ElevatorButtons,
ElevatorModel: Enums.ElevatorValues, ElevatorModel: Enums.ElevatorValues,
Buttons: Tags.ButtonsTree Buttons: Tags.ButtonsTree
@@ -45,14 +44,13 @@ ButtonsModule.__index = ButtonsModule
ButtonsModule.DefaultMaxActivationDistance = 3 ButtonsModule.DefaultMaxActivationDistance = 3
ButtonsModule.DefaultHoldDuration = .30 ButtonsModule.DefaultHoldDuration = .30
function ButtonsModule.constructor(TagsConstructor, ModelButtons, ElevatorModel) function ButtonsModule.constructor(ModelButtons, ElevatorModel)
return setmetatable({ return setmetatable({
Tags = TagsConstructor,
ModelButtons = ModelButtons, ModelButtons = ModelButtons,
ElevatorModel = ElevatorModel, ElevatorModel = ElevatorModel,
Buttons = { Buttons = {
[ElevatorModel] = { [ElevatorModel] = {
Landing = {}, Landing = {},
Car = {}, Car = {},
Special = {}, Special = {},
@@ -79,7 +77,7 @@ function ButtonsModule:CreatePromptButtons()
local Split = TagName:split('_') local Split = TagName:split('_')
local ButtonType: Enums.ButtonValues? = if tonumber(Split[3]) then local ButtonType: Enums.ButtonValues? = if tonumber(Split[3]) then
Enums.Button.Car Enums.Button.Car
elseif Split[3] == "Floor" and Split[4]:match('%d') then elseif Split[3] == "Floor" and Split[4]:match('%d') then
Enums.Button.Landing Enums.Button.Landing

View File

@@ -25,7 +25,7 @@ type Impl_Constructor = {
type Impl_Static_Props = { type Impl_Static_Props = {
Decoders: { Decoders: {
CarTag: (FloorTag: string) -> number?, CarTag: (FloorTag: string) -> (number | string)?,
HallTag: (FloorTag: string) -> number? HallTag: (FloorTag: string) -> number?
} }
} }
@@ -154,8 +154,9 @@ Tags.__index = Tags
Tags.Decoders = { Tags.Decoders = {
CarTag = function(FloorTag) CarTag = function(FloorTag)
local Match = FloorTag:match('%d+$') local Match = FloorTag:match('%w+$')
return Match and tonumber(Match)
return Match and (tonumber(Match) or tostring(Match))
end, end,
HallTag = function(FloorTag) HallTag = function(FloorTag)
@@ -369,7 +370,6 @@ function Tags:__Interactables()
ptr.ColorDeactivated = LightAddress.ColorDeactivated ptr.ColorDeactivated = LightAddress.ColorDeactivated
ptr.ActivatedMaterial = LightAddress.ActivatedMaterial ptr.ActivatedMaterial = LightAddress.ActivatedMaterial
ptr.DeactivatedMaterial = LightAddress.DeactivatedMaterial ptr.DeactivatedMaterial = LightAddress.DeactivatedMaterial
elseif InteractType == Enums.InteractType.Light then elseif InteractType == Enums.InteractType.Light then
if type(Inst) == "table" then if type(Inst) == "table" then
ptr.Lights = Inst ptr.Lights = Inst

View File

@@ -1,3 +1,7 @@
--!optimize 2
--!native
--!strict
local EnumsDir = script.Parent:WaitForChild("Enums") local EnumsDir = script.Parent:WaitForChild("Enums")
local StorageService = game:GetService("ReplicatedStorage") local StorageService = game:GetService("ReplicatedStorage")
@@ -5,28 +9,41 @@ local StorageService = game:GetService("ReplicatedStorage")
local Enums = require(StorageService:WaitForChild("Enums")) local Enums = require(StorageService:WaitForChild("Enums"))
local SoundEnums = require(EnumsDir:WaitForChild("Sounds")) local SoundEnums = require(EnumsDir:WaitForChild("Sounds"))
type ButtonProperties = {
Color: Color3,
Material: Enum.Material
}
export type ElevatorConfigurationTable = { export type ElevatorConfigurationTable = {
Name: Enums.ElevatorValues, Name: Enums.ElevatorValues,
Responsiveness: number, Responsiveness: number,
MaxVelocity: number, MaxVelocity: number,
FloorLevelingDistance: number, FloorLevelingDistance: number,
FloorLeveling3PhaseDistance: number, FloorLeveling3PhaseDistance: number,
ParkedDistance: number, ParkedDistance: number,
LevelingVelocity: number, LevelingVelocity: number,
Phase3LevelingVelocity: number, Phase3LevelingVelocity: number,
Functions: { Functions: {
ManualTravelStart: boolean, ManualTravelStart: boolean,
}, },
Sounds: { Sounds: {
LanternChimeDirection: SoundEnums.ElevatorSoundValues, LanternChimeDirection: SoundEnums.ElevatorSoundValues,
LanternChimeLanding: SoundEnums.ElevatorSoundValues, LanternChimeLanding: SoundEnums.ElevatorSoundValues,
}, },
Colors: { Colors: {
ButtonActivated: Color3, ButtonActivated: ButtonProperties,
ButtonDeactivated: Color3, ButtonDeactivated: ButtonProperties,
LanternDisplayOn: Color3, LanternIndicator: {
LanternDisplayOff: Color3, On: {
Up: ButtonProperties,
Down: ButtonProperties
},
Off: {
Up: ButtonProperties,
Down: ButtonProperties
}
},
}, },
} }