Big elevator refactoring

This commit is contained in:
2024-05-11 00:03:21 -04:00
parent 17193ac908
commit 73045d5bf6
9 changed files with 272 additions and 142 deletions

0
obsidian/Elevators.md Normal file
View File

File diff suppressed because one or more lines are too long

View File

@@ -5,67 +5,151 @@
local Elevators = script.Parent local Elevators = script.Parent
local Main = Elevators.Parent local Main = Elevators.Parent
local Load = Main:WaitForChild("Load") local Load = Main:WaitForChild("Load")
local TagsDir = Load:WaitForChild("Tags")
local Storage = game:GetService("ReplicatedStorage") local Storage = game:GetService("ReplicatedStorage")
local PromptModule = require(Main:WaitForChild("Map"):WaitForChild("Prompts"))
local Tags = require(Load:WaitForChild("Tags"))
local Enums = require(Storage:WaitForChild("Enums")) local Enums = require(Storage:WaitForChild("Enums"))
local ButtonTags = require(TagsDir:WaitForChild("Buttons"))
local ButtonFunctions = {} local PromptModule = require(Main:WaitForChild("Map"):WaitForChild("Prompts"))
local Tags = require(Load:WaitForChild("Tags"))
type ButtonActivatedCallback = (Floor: number) -> ()
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
CarButton: (self: ClassConstructor, ButtonName: string, ButtonTree: Tags.ButtonProperties, Callback: ButtonActivatedCallback) -> (),
LandingButton: (self: ClassConstructor, ButtonName: string, ButtonTree: Tags.ButtonProperties, Callback: ButtonActivatedCallback) -> (),
AestheticActivateButton: (self: ClassConstructor, Button: BasePart, Glass: BasePart?) -> (),
__DeactivateButton: (self: ClassConstructor, Button: BasePart, Glass: BasePart?) -> (),
__ActivateButton: (self: ClassConstructor, Button: BasePart, Glass: BasePart?) -> (),
} & Impl_Static_Props
type Impl_Static_Props = {
ButtonHoldDuration: number
}
type Constructor_Fun = (ElevatorAttributes: ElevatorAttributes, ElevatorEvents: ElevatorEvents, ElevatorButtonColors: ElevatorButtonColors) -> ClassConstructor
type Constructor_Return_Props = {
ElevatorAttributes: ElevatorAttributes,
ElevatorEvents: ElevatorEvents,
ElevatorButtonColors: ElevatorButtonColors
}
type ElevatorAttributes = {
PassingFloor: IntValue,
Moving: BoolValue,
CurrentFloor: IntValue
}
type ElevatorEvents = {
ButtonActivated: BindableEvent
}
type ElevatorButtonColors = {
ButtonActivated: Color3,
ButtonDeactivated: Color3,
LanternDisplayOn: Color3,
LanternDisplayOff: Color3,
}
local ButtonFunctions = {} :: Impl_Constructor
ButtonFunctions.__index = ButtonFunctions ButtonFunctions.__index = ButtonFunctions
ButtonFunctions.ButtonHoldDuration = .30
--ButtonTags.ButtonsConstructor --ButtonTags.ButtonsConstructor
function ButtonFunctions.constructor(ElevatorConstructor, ElevatorAttributes, ElevatorEvents, ButtonsConstructor) function ButtonFunctions.constructor(ElevatorAttributes, ElevatorEvents, ElevatorButtonColors)
return setmetatable({ return setmetatable({
ElevatorAttributes = ElevatorAttributes, ElevatorAttributes = ElevatorAttributes,
ElevatorEvents = ElevatorEvents, ElevatorEvents = ElevatorEvents,
ElevatorConstructor = ElevatorConstructor, ElevatorButtonColors = ElevatorButtonColors
ButtonsConstructor = ButtonsConstructor
}, ButtonFunctions) }, ButtonFunctions)
end end
function ButtonFunctions:ActivateButton(Floor: number, ButtonEnum: Enums.ButtonTreeValues, ButtonName: string, ButtonTree: Tags.ButtonProperties) function ButtonFunctions:CarButton(ButtonName, ButtonTree, Callback)
local DecodedCarFloorTag = Tags.Decoders.CarTag(ButtonName)
if DecodedCarFloorTag then
local Prompt = PromptModule.constructor(ButtonTree.Prompt :: ProximityPrompt, ButtonTree.Inst :: Instance) local Prompt = PromptModule.constructor(ButtonTree.Prompt :: ProximityPrompt, ButtonTree.Inst :: Instance)
Prompt:Triggered(function(Player: Player) Prompt:Triggered(function(Player: Player)
self.ElevatorEvents.ButtonActivated:Fire(ButtonEnum, ButtonName, self.ButtonsConstructor, ButtonTree) self.ElevatorEvents.ButtonActivated:Fire(Enums.Button.Car, ButtonName, self, ButtonTree)
self.ButtonsConstructor:AestheticActivateButton(ButtonTree.Inst :: BasePart, Otis1960.ButtonActivatedColor) task.spawn(function()
self:AestheticActivateButton(ButtonTree.Inst :: BasePart)
end)
if Floor == self.ElevatorAttributes.Attributes.CurrentFloor.Value then if DecodedCarFloorTag == self.ElevatorAttributes.CurrentFloor.Value then
self.ButtonsConstructor:DeactivateButton(ButtonTree.Inst :: BasePart, Otis1960.ButtonDeactivatedColor) self:__DeactivateButton(ButtonTree.Inst :: BasePart, (ButtonTree.Inst :: Instance):FindFirstChild("Glass") :: BasePart?)
else else
self.ElevatorConstructor:GoToLevel(Floor) Callback(DecodedCarFloorTag)
end end
end) end)
end end
end
function ButtonFunctions:LandingButton(ButtonName, ButtonsConstructor, ButtonTree) function ButtonFunctions:LandingButton(ButtonName, ButtonTree, Callback)
local DecodedFloor = Tags.Decoders.HallTag(ButtonName) local DecodedHallFloorTag = Tags.Decoders.HallTag(ButtonName)
if DecodedFloor then if DecodedHallFloorTag then
self:ActivateButton(DecodedFloor, Enums.ButtonTree.Landing, ButtonName, ButtonsConstructor, ButtonTree) local Prompt = PromptModule.constructor(ButtonTree.Prompt :: ProximityPrompt, ButtonTree.Inst :: Instance)
Prompt:Triggered(function(Player: Player)
self.ElevatorEvents.ButtonActivated:Fire(Enums.Button.Landing, ButtonName, self, ButtonTree)
task.spawn(function()
self:AestheticActivateButton(ButtonTree.Inst :: BasePart)
end)
if DecodedHallFloorTag == self.ElevatorAttributes.CurrentFloor.Value then
self:__DeactivateButton(ButtonTree.Inst :: BasePart, (ButtonTree.Inst :: Instance):FindFirstChild("Glass") :: BasePart?)
else else
warn(`Otis1960: Failed to decode hall button, ButtonName={ButtonName}`) Callback(DecodedHallFloorTag)
end end
end end)
function ButtonFunctions:CarButton(ButtonName, ButtonsConstructor, ButtonTree)
local DecodedFloor = Tags.Decoders.CarTag(ButtonName)
if DecodedFloor then
self:ActivateButton(DecodedFloor, Enums.ButtonTree.Car, ButtonName, ButtonsConstructor, ButtonTree)
else
warn(`Otis1960: Failed to decode car button, ButtonName={ButtonName}`)
end end
end end
--[[
function ButtonFunctions:SpecialButton(ButtonName, ButtonsConstructor, ButtonTree) function ButtonFunctions:SpecialButton(ButtonName, ButtonsConstructor, ButtonTree)
end end
]]
function ButtonFunctions:__DeactivateButton(Button, Glass)
local Part = Glass and 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 and 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 and Glass or Button).CFrame.LookVector/50
if Glass then
Glass.Position+=LookVec
self:__ActivateButton(Button, Glass)
end
Button.Position+=LookVec
task.wait(.30)
if Glass then
Glass.Position-=LookVec
end
Button.Position-=LookVec
end
return ButtonFunctions return ButtonFunctions

View File

@@ -11,6 +11,8 @@ local Tween = require(Storage:WaitForChild("Tween"))
local Tags = require(LoadDir:WaitForChild("Tags")) local Tags = require(LoadDir:WaitForChild("Tags"))
local Enums = require(Storage:WaitForChild("Enums")) local Enums = require(Storage:WaitForChild("Enums"))
local SoundEnums = require(MainDir:WaitForChild("Enums"):WaitForChild("Sounds"))
type rbxassetid = string type rbxassetid = string
type TagProduct = Tags.TagProduct type TagProduct = Tags.TagProduct
@@ -32,17 +34,34 @@ type Impl_Static_Props = {
LightTweenTime: number LightTweenTime: number
} }
type Constructor_Fun = (MainDisplay: UnionOperation, ChimeDirectionID: rbxassetid, ChimeLandingID: rbxassetid, Lanterns: Tags.Lanterns, Colors: Colors) -> ClassConstructor type Constructor_Fun = (MainDisplay: UnionOperation, LanternsMap: Tags.Lanterns, ElevatorSounds: ElevatorSounds, Colors: ElevatorButtonColors) -> ClassConstructor
type Constructor_Return_Props = { type Constructor_Return_Props = {
LanternsMap: Tags.Lanterns, LanternsMap: Tags.Lanterns,
AudioChimeDirection: Sound, AudioChimeDirection: Sound,
AudioChimeLanding: Sound, AudioChimeLanding: Sound,
Colors: Colors Colors: ElevatorButtonColors
} }
export type Colors = { type ElevatorAttributes = {
Active: Color3, PassingFloor: IntValue,
Off: Color3 Moving: BoolValue,
CurrentFloor: IntValue
}
type ElevatorEvents = {
ButtonActivated: BindableEvent
}
type ElevatorButtonColors = {
ButtonActivated: Color3,
ButtonDeactivated: Color3,
LanternDisplayOn: Color3,
LanternDisplayOff: Color3,
}
type ElevatorSounds = {
LanternChimeDirection: SoundEnums.Otis1960LanternChimeDirection,
LanternChimeLanding: SoundEnums.Otis1960LanternChimeLanding,
} }
export type LanternsConstructor = ClassConstructor export type LanternsConstructor = ClassConstructor
@@ -53,12 +72,12 @@ Lanterns.__index = Lanterns
Lanterns.Volume = .5 Lanterns.Volume = .5
Lanterns.LightTweenTime = 1 Lanterns.LightTweenTime = 1
function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, LanternsMap, Colors) function Lanterns.constructor(MainDisplay, LanternsMap, ElevatorSounds, Colors)
local AudioChimeDirection = Instance.new("Sound") :: Sound local AudioChimeDirection = Instance.new("Sound") :: Sound
AudioChimeDirection.SoundId = ChimeDirectionID AudioChimeDirection.SoundId = ElevatorSounds.LanternChimeDirection
AudioChimeDirection.Volume = Lanterns.Volume AudioChimeDirection.Volume = Lanterns.Volume
local AudioChimeLanding = Instance.new("Sound") :: Sound local AudioChimeLanding = Instance.new("Sound") :: Sound
AudioChimeLanding.SoundId = ChimeLandingID AudioChimeLanding.SoundId = ElevatorSounds.LanternChimeLanding
AudioChimeLanding.Volume = Lanterns.Volume AudioChimeLanding.Volume = Lanterns.Volume
AudioChimeDirection.Parent = MainDisplay AudioChimeDirection.Parent = MainDisplay
@@ -76,7 +95,7 @@ local LanternLight = Tween.constructor(TweenInfo.new(Lanterns.LightTweenTime))
function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern, Chime) function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern, Chime)
local Tween = LanternLight:Start(Lantern.Light, { local Tween = LanternLight:Start(Lantern.Light, {
Color = EnabledState and self.Colors.Active or self.Colors.Off Color = EnabledState and self.Colors.LanternDisplayOn or self.Colors.LanternDisplayOff
}) })
if EnabledState then if EnabledState then
@@ -93,7 +112,7 @@ function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern, Chime)
if Lantern.PointLight then if Lantern.PointLight then
Lantern.PointLight.Enabled = true Lantern.PointLight.Enabled = true
LanternLight:Start(Lantern.PointLight, { LanternLight:Start(Lantern.PointLight, {
Color = self.Colors.Active Color = self.Colors.LanternDisplayOn
}) })
end end
else else

View File

@@ -2,7 +2,7 @@
--!native --!native
--!strict --!strict
local Leveling = { local Leveling: {number} = {
[1] = 13.041, [1] = 13.041,
[2] = 37.973, [2] = 37.973,
[3] = 62.978, [3] = 62.978,

View File

@@ -4,27 +4,30 @@
local Elevators = script.Parent local Elevators = script.Parent
local MainDir = Elevators.Parent local MainDir = Elevators.Parent
local EnumsDir = MainDir:WaitForChild("Enums")
local LoadDir = MainDir:WaitForChild("Load") local LoadDir = MainDir:WaitForChild("Load")
local TagsDir = LoadDir:WaitForChild("Tags")
local Storage = game:GetService("ReplicatedStorage") local Storage = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService") local RS = game:GetService("RunService")
local ButtonTags = require(TagsDir:WaitForChild("Buttons"))
local Enums = require(Storage:WaitForChild("Enums")) local Enums = require(Storage:WaitForChild("Enums"))
local SoundEnums = require(EnumsDir:WaitForChild("Sounds"))
local Leveling = require(script:WaitForChild("Leveling")) local Leveling = require(script:WaitForChild("Leveling"))
local Doors = require(script:WaitForChild("Doors")) local Doors = require(script:WaitForChild("Doors"))
local MovingObjects = require(script:WaitForChild("MovingObjects")) local MovingObjects = require(script:WaitForChild("MovingObjects"))
local HallDisplays = require(script:WaitForChild("HallDisplays"))
local HallDisplays = require(Elevators:WaitForChild("HallDisplays"))
local ElevatorMover = require(Elevators:WaitForChild("Mover")) local ElevatorMover = require(Elevators:WaitForChild("Mover"))
local ButtonTags = require(Elevators:WaitForChild("Buttons"))
local TractionRopes = require(Elevators:WaitForChild("TractionRopes")) local TractionRopes = require(Elevators:WaitForChild("TractionRopes"))
local Lanterns = require(Elevators:WaitForChild("Lanterns")) local Lanterns = require(Elevators:WaitForChild("Lanterns"))
local Buttons = require(Elevators:WaitForChild("Buttons"))
local Tags = require(LoadDir:WaitForChild("Tags")) local Tags = require(LoadDir:WaitForChild("Tags"))
type rbxassetid = string
type Tags = Tags.ExportedTags type Tags = Tags.ExportedTags
type TagsConstructor = Tags.TagsConstructor type TagsConstructor = Tags.TagsConstructor
@@ -34,27 +37,31 @@ type Impl_Constructor = {
constructor: Constructor_Fun, constructor: Constructor_Fun,
--Class functions --Class functions
__MoveFloors: (self: ClassConstructor, Level: number, RequestedLevel: number, GoingUp: boolean) -> (), __MoveFloors: (self: ClassConstructor, Level: number, RequestedLevel: number, GoingUp: boolean) -> (),
GoToLevel: (self: ClassConstructor, RequestedLevel: number) -> () RequestLevel: (self: ClassConstructor, RequestedLevel: number) -> ()
} & Impl_Static_Props } & Impl_Static_Props
type Impl_Static_Props = { type Impl_Static_Props = {
Name: Enums.ElevatorValues, Name: Enums.ElevatorValues,
Responsiveness: number, Responsiveness: number,
MaxVelocity: number, MaxVelocity: number,
ButtonActivatedColor: Color3,
ButtonDeactivatedColor: Color3,
LanternDisplayColorOn: Color3,
LanternDisplayColorOff: Color3,
LanternChimeDirection: rbxassetid,
LanternChimeLanding: rbxassetid,
FloorLevelingDistance: number, FloorLevelingDistance: number,
DoorOpeningDistance: number, DoorOpeningDistance: number,
LeveledDistance: number, LeveledDistance: number,
Sounds: {
LanternChimeDirection: SoundEnums.Otis1960LanternChimeDirection,
LanternChimeLanding: SoundEnums.Otis1960LanternChimeLanding,
},
Colors: {
ButtonActivated: Color3,
ButtonDeactivated: Color3,
LanternDisplayOn: Color3,
LanternDisplayOff: Color3,
},
Attributes: { Attributes: {
PassingFloor: IntValue, PassingFloor: IntValue,
Moving: BoolValue, CurrentFloor: IntValue,
CurrentFloor: IntValue Moving: BoolValue
}, },
Events: { Events: {
ButtonActivated: BindableEvent ButtonActivated: BindableEvent
@@ -98,17 +105,23 @@ Otis1960.DoorOpeningDistance = Otis1960.FloorLevelingDistance/2.8
Otis1960.LeveledDistance = 0.5 Otis1960.LeveledDistance = 0.5
Otis1960.Responsiveness = 50 Otis1960.Responsiveness = 50
Otis1960.MaxVelocity = 10 Otis1960.MaxVelocity = 10
Otis1960.ButtonActivatedColor = Color3.fromRGB(180,0,0)
Otis1960.ButtonDeactivatedColor = Color3.fromRGB(139,139,139) Otis1960.Sounds = {
Otis1960.LanternDisplayColorOn = Color3.fromRGB(255,114,71) LanternChimeDirection = SoundEnums.Otis1960.LanternChimeDirection,
Otis1960.LanternDisplayColorOff = Color3.fromRGB(55,55,55) LanternChimeLanding = SoundEnums.Otis1960.LanternChimeLanding
Otis1960.LanternChimeDirection = "rbxassetid://16990287228" }
Otis1960.LanternChimeLanding = "rbxassetid://16990290265"
Otis1960.Colors = {
ButtonActivated = Color3.fromRGB(180,0,0),
ButtonDeactivated = Color3.fromRGB(139,139,139),
LanternDisplayOn = Color3.fromRGB(255,114,71),
LanternDisplayOff = Color3.fromRGB(55,55,55),
}
Otis1960.Attributes = { Otis1960.Attributes = {
PassingFloor = Instance.new("IntValue") :: IntValue, PassingFloor = Instance.new("IntValue") :: IntValue,
Moving = Instance.new("BoolValue") :: BoolValue, CurrentFloor = Instance.new("IntValue") :: IntValue,
CurrentFloor = Instance.new("IntValue") :: IntValue Moving = Instance.new("BoolValue") :: BoolValue
} }
Otis1960.Events = { Otis1960.Events = {
@@ -121,18 +134,34 @@ Otis1960.Attributes.CurrentFloor.Value = 1
local Attributes = Otis1960.Attributes local Attributes = Otis1960.Attributes
local function HookButtons(self: ClassConstructor, ButtonsConstructor: ButtonTags.ButtonsConstructor, ButtonType: Enums.EnumValue) local ButtonsConstructor = Buttons.constructor(Otis1960.Attributes, Otis1960.Events, Otis1960.Colors)
local ButtonFunctions = require(script:WaitForChild("ButtonFunctions"))
local function HookButtons(self: ClassConstructor, ButtonNameType: Enums.ButtonTreeValues, ButtonName: string, ButtonTree)
if ButtonNameType == Enums.ButtonTree.Car then
ButtonsConstructor:CarButton(ButtonName, ButtonTree, function(Floor: number)
self:RequestLevel(Floor)
end)
elseif ButtonNameType == Enums.ButtonTree.Landing then
ButtonsConstructor:LandingButton(ButtonName, ButtonTree, function(Floor: number)
self:RequestLevel(Floor)
end)
elseif ButtonNameType == Enums.ButtonTree.Special then
elseif ButtonNameType == Enums.ButtonTree.Relays then
elseif ButtonNameType == Enums.ButtonTree.Unknown then
else
warn(`[{Otis1960.Name}]: Could not iterate a button, ButtonNameType={ButtonNameType}`)
end
end
local function IterateButtons(self: ClassConstructor, ButtonsConstructor: ButtonTags.ButtonsConstructor)
for ButtonNameType, ButtonList in ButtonsConstructor.Buttons do for ButtonNameType, ButtonList in ButtonsConstructor.Buttons do
for ButtonName, ButtonTree in ButtonList do for ButtonName, ButtonTree in ButtonList do
if ButtonTree.Prompt then if ButtonTree.Prompt then
if ButtonTree.Inst then if ButtonTree.Inst then
local Button = ButtonFunctions[ButtonNameType :: Enums.ButtonTreeValues] HookButtons(self, ButtonNameType :: Enums.ButtonTreeValues, ButtonName, ButtonTree)
if Button then
Button(self, ButtonName, ButtonsConstructor, ButtonTree)
end
else else
warn(`{ButtonTree} is missing the field "Inst"`) warn(`{ButtonTree} is missing the field "Inst"`)
end end
@@ -172,10 +201,7 @@ function Otis1960.constructor(TagsConstructor, ButtonsTags, LanternsTags, Landin
self.ElevatorDoors = Doors.constructor(LandingDoors, self.ElevatorBox_1960, self.ElevatorDoor1, self.ElevatorDoor2, self.ElevatorDoorSensor) self.ElevatorDoors = Doors.constructor(LandingDoors, self.ElevatorBox_1960, self.ElevatorDoor1, self.ElevatorDoor2, self.ElevatorDoorSensor)
self.TractionRopes = TractionRopes.constructor(self.Ropes, self.ElevatorBox_1960, Leveling) self.TractionRopes = TractionRopes.constructor(self.Ropes, self.ElevatorBox_1960, Leveling)
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, Otis1960.LanternChimeDirection, Otis1960.LanternChimeLanding, LanternsTags, { self.LanternsConstructor = Lanterns.constructor(LanternDisplay, LanternsTags, Otis1960.Sounds, Otis1960.Colors)
Active = Otis1960.LanternDisplayColorOn,
Off = Otis1960.LanternDisplayColorOff
} :: Lanterns.Colors)
local ButtonsConstructor = ButtonTags.constructor(TagsConstructor, ButtonsTags) local ButtonsConstructor = ButtonTags.constructor(TagsConstructor, ButtonsTags)
local Otis1960_Buttons = ButtonsConstructor:CreatePromptButtons() local Otis1960_Buttons = ButtonsConstructor:CreatePromptButtons()
@@ -187,7 +213,7 @@ function Otis1960.constructor(TagsConstructor, ButtonsTags, LanternsTags, Landin
self.BoxAlignOrientation = ElevatorMover(self.ElevatorBox_1960, self.ElevatorBox_1960.Position, Otis1960.Responsiveness, Otis1960.MaxVelocity) self.BoxAlignOrientation = ElevatorMover(self.ElevatorBox_1960, self.ElevatorBox_1960.Position, Otis1960.Responsiveness, Otis1960.MaxVelocity)
local ClassConstructor = setmetatable(self, Otis1960) local ClassConstructor = setmetatable(self, Otis1960)
HookButtons(ClassConstructor, ButtonsConstructor, Enums.ButtonTree.Car) IterateButtons(ClassConstructor, ButtonsConstructor)
--Open the elevator doors on server start --Open the elevator doors on server start
task.spawn(function() task.spawn(function()
@@ -301,13 +327,33 @@ function Otis1960:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, GoalLevelVEC, ElevatorBoxCurrentPos.Z) self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, GoalLevelVEC, ElevatorBoxCurrentPos.Z)
end end
function Otis1960:GoToLevel(RequestedLevel) local FloorAdvancer = {}
--My clever math function for determining if the elevator goal is to move upwards or not
local function ElevatorDirectionGoingUp(Floor: number, RequestedFloor: number): boolean
return -(Floor-RequestedFloor)>0
end
function Otis1960:RequestLevel(RequestedLevel)
local GoalLevelVEC: number = Leveling[RequestedLevel] local GoalLevelVEC: number = Leveling[RequestedLevel]
if GoalLevelVEC and GoalLevelVEC ~= Attributes.CurrentFloor.Value then if GoalLevelVEC and GoalLevelVEC ~= Attributes.CurrentFloor.Value then
local GoingUp: boolean = -(Attributes.CurrentFloor.Value-RequestedLevel)>0 --My clever math function for determining if the elevator goal is to move upwards or not --My clever math function for determining if the elevator goal is to move upwards or not
local GoingUp = ElevatorDirectionGoingUp(Attributes.CurrentFloor.Value, RequestedLevel)
if Attributes.Moving.Value then
if GoingUp then
if Attributes.CurrentFloor.Value<=RequestedLevel then
self:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp) self:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
end
else
if Attributes.CurrentFloor.Value>=RequestedLevel then
self:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
end
end
else
self:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
end
else else
warn(`[{Otis1960.Name}]: landing out of range or equals the same range as the goal, requested landing: {tostring(RequestedLevel)}`) warn(`[{Otis1960.Name}]: landing out of range or equals the same range as the goal, requested landing: {tostring(RequestedLevel)}`)
end end

View File

@@ -0,0 +1,19 @@
--!optimize 2
--!native
--!strict
local SoundEnums = {}
export type Otis1960Sounds = typeof(SoundEnums.Otis1960)
export type Otis1960LanternChimeDirection = "rbxassetid://16990287228"
export type Otis1960LanternChimeLanding = "rbxassetid://16990290265"
export type Otis1960SoundValues = Otis1960LanternChimeDirection | Otis1960LanternChimeLanding
SoundEnums.Otis1960 = {
LanternChimeDirection = "rbxassetid://16990287228" :: Otis1960LanternChimeDirection,
LanternChimeLanding = "rbxassetid://16990290265" :: Otis1960LanternChimeLanding
}
return SoundEnums

View File

@@ -2,11 +2,10 @@
--!native --!native
--!strict --!strict
local ElevatorsDir = script.Parent local TagsDir = script.Parent
local MainDir = ElevatorsDir.Parent local LoadDir = TagsDir.Parent
local LoadDir = MainDir:WaitForChild("Load")
local Tags = require(ElevatorsDir:WaitForChild("Tags")) local Tags = require(LoadDir:WaitForChild("Tags"))
local Storage = game:GetService("ReplicatedStorage") local Storage = game:GetService("ReplicatedStorage")
local Enums = require(Storage:WaitForChild("Enums")) local Enums = require(Storage:WaitForChild("Enums"))
@@ -23,9 +22,6 @@ type Impl_Constructor = {
--Class functions --Class functions
DecodeCarTag: (self: ClassConstructor, FloorTag: string) -> number?, DecodeCarTag: (self: ClassConstructor, FloorTag: string) -> number?,
CreatePromptButtons: (self: ClassConstructor) -> Tags.ButtonsTree, CreatePromptButtons: (self: ClassConstructor) -> Tags.ButtonsTree,
AestheticActivateButton: (self: ClassConstructor, Button: BasePart, ActivatedColor: Color3) -> (),
DeactivateButton: (self: ClassConstructor, Button: BasePart, DeactivatedColor: Color3) -> (),
ActivateButton: (self: ClassConstructor, Button: BasePart, ActivatedColor: Color3) -> (),
} & Impl_Static_Props } & Impl_Static_Props
type Impl_Static_Props = { type Impl_Static_Props = {
@@ -145,38 +141,4 @@ function ButtonsModule:CreatePromptButtons()
return self.Buttons return self.Buttons
end end
function ButtonsModule:DeactivateButton(Button, DeactivatedColor)
local Glass = Button:FindFirstChild("Glass") :: BasePart?
local Part = Glass and Glass or Button
Part.Material = Enum.Material.Glass
Part.Color = DeactivatedColor
Part.Transparency = 0.3
end
function ButtonsModule:ActivateButton(Button, ActivatedColor)
local Glass = Button:FindFirstChild("Glass") :: BasePart?
local Part = Glass and Glass or Button
Part.Material = Enum.Material.Neon
Part.Color = ActivatedColor
Part.Transparency = 0
end
function ButtonsModule:AestheticActivateButton(Button, ActivatedColor)
local Glass = Button:FindFirstChild("Glass") :: BasePart?
local LookVec = (Glass and Glass or Button).CFrame.LookVector/50
if Glass then
Glass.Position+=LookVec
self:ActivateButton(Glass, ActivatedColor)
end
Button.Position+=LookVec
task.wait(.30)
if Glass then
Glass.Position-=LookVec
end
Button.Position-=LookVec
end
return ButtonsModule return ButtonsModule