mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
Big elevator refactoring
This commit is contained in:
0
obsidian/Elevators.md
Normal file
0
obsidian/Elevators.md
Normal file
File diff suppressed because one or more lines are too long
@@ -5,67 +5,151 @@
|
||||
local Elevators = script.Parent
|
||||
local Main = Elevators.Parent
|
||||
local Load = Main:WaitForChild("Load")
|
||||
local TagsDir = Load:WaitForChild("Tags")
|
||||
|
||||
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 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.ButtonHoldDuration = .30
|
||||
|
||||
--ButtonTags.ButtonsConstructor
|
||||
function ButtonFunctions.constructor(ElevatorConstructor, ElevatorAttributes, ElevatorEvents, ButtonsConstructor)
|
||||
function ButtonFunctions.constructor(ElevatorAttributes, ElevatorEvents, ElevatorButtonColors)
|
||||
return setmetatable({
|
||||
ElevatorAttributes = ElevatorAttributes,
|
||||
ElevatorEvents = ElevatorEvents,
|
||||
ElevatorConstructor = ElevatorConstructor,
|
||||
ButtonsConstructor = ButtonsConstructor
|
||||
ElevatorButtonColors = ElevatorButtonColors
|
||||
}, ButtonFunctions)
|
||||
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)
|
||||
|
||||
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
|
||||
self.ButtonsConstructor:DeactivateButton(ButtonTree.Inst :: BasePart, Otis1960.ButtonDeactivatedColor)
|
||||
if DecodedCarFloorTag == self.ElevatorAttributes.CurrentFloor.Value then
|
||||
self:__DeactivateButton(ButtonTree.Inst :: BasePart, (ButtonTree.Inst :: Instance):FindFirstChild("Glass") :: BasePart?)
|
||||
else
|
||||
self.ElevatorConstructor:GoToLevel(Floor)
|
||||
Callback(DecodedCarFloorTag)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ButtonFunctions:LandingButton(ButtonName, ButtonsConstructor, ButtonTree)
|
||||
local DecodedFloor = Tags.Decoders.HallTag(ButtonName)
|
||||
|
||||
if DecodedFloor then
|
||||
self:ActivateButton(DecodedFloor, Enums.ButtonTree.Landing, ButtonName, ButtonsConstructor, ButtonTree)
|
||||
else
|
||||
warn(`Otis1960: Failed to decode hall button, ButtonName={ButtonName}`)
|
||||
end
|
||||
end
|
||||
|
||||
function ButtonFunctions:CarButton(ButtonName, ButtonsConstructor, ButtonTree)
|
||||
local DecodedFloor = Tags.Decoders.CarTag(ButtonName)
|
||||
function ButtonFunctions:LandingButton(ButtonName, ButtonTree, Callback)
|
||||
local DecodedHallFloorTag = Tags.Decoders.HallTag(ButtonName)
|
||||
|
||||
if DecodedFloor then
|
||||
self:ActivateButton(DecodedFloor, Enums.ButtonTree.Car, ButtonName, ButtonsConstructor, ButtonTree)
|
||||
if DecodedHallFloorTag then
|
||||
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
|
||||
warn(`Otis1960: Failed to decode car button, ButtonName={ButtonName}`)
|
||||
Callback(DecodedHallFloorTag)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
function ButtonFunctions:SpecialButton(ButtonName, ButtonsConstructor, ButtonTree)
|
||||
|
||||
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
|
||||
@@ -11,6 +11,8 @@ local Tween = require(Storage:WaitForChild("Tween"))
|
||||
local Tags = require(LoadDir:WaitForChild("Tags"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
local SoundEnums = require(MainDir:WaitForChild("Enums"):WaitForChild("Sounds"))
|
||||
|
||||
type rbxassetid = string
|
||||
type TagProduct = Tags.TagProduct
|
||||
|
||||
@@ -32,17 +34,34 @@ type Impl_Static_Props = {
|
||||
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 = {
|
||||
LanternsMap: Tags.Lanterns,
|
||||
AudioChimeDirection: Sound,
|
||||
AudioChimeLanding: Sound,
|
||||
Colors: Colors
|
||||
Colors: ElevatorButtonColors
|
||||
}
|
||||
|
||||
export type Colors = {
|
||||
Active: Color3,
|
||||
Off: Color3
|
||||
type ElevatorAttributes = {
|
||||
PassingFloor: IntValue,
|
||||
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
|
||||
@@ -53,12 +72,12 @@ Lanterns.__index = Lanterns
|
||||
Lanterns.Volume = .5
|
||||
Lanterns.LightTweenTime = 1
|
||||
|
||||
function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, LanternsMap, Colors)
|
||||
function Lanterns.constructor(MainDisplay, LanternsMap, ElevatorSounds, Colors)
|
||||
local AudioChimeDirection = Instance.new("Sound") :: Sound
|
||||
AudioChimeDirection.SoundId = ChimeDirectionID
|
||||
AudioChimeDirection.SoundId = ElevatorSounds.LanternChimeDirection
|
||||
AudioChimeDirection.Volume = Lanterns.Volume
|
||||
local AudioChimeLanding = Instance.new("Sound") :: Sound
|
||||
AudioChimeLanding.SoundId = ChimeLandingID
|
||||
AudioChimeLanding.SoundId = ElevatorSounds.LanternChimeLanding
|
||||
AudioChimeLanding.Volume = Lanterns.Volume
|
||||
|
||||
AudioChimeDirection.Parent = MainDisplay
|
||||
@@ -76,7 +95,7 @@ local LanternLight = Tween.constructor(TweenInfo.new(Lanterns.LightTweenTime))
|
||||
|
||||
function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern, Chime)
|
||||
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
|
||||
@@ -93,7 +112,7 @@ function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern, Chime)
|
||||
if Lantern.PointLight then
|
||||
Lantern.PointLight.Enabled = true
|
||||
LanternLight:Start(Lantern.PointLight, {
|
||||
Color = self.Colors.Active
|
||||
Color = self.Colors.LanternDisplayOn
|
||||
})
|
||||
end
|
||||
else
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local Leveling = {
|
||||
local Leveling: {number} = {
|
||||
[1] = 13.041,
|
||||
[2] = 37.973,
|
||||
[3] = 62.978,
|
||||
|
||||
@@ -4,27 +4,30 @@
|
||||
|
||||
local Elevators = script.Parent
|
||||
local MainDir = Elevators.Parent
|
||||
local EnumsDir = MainDir:WaitForChild("Enums")
|
||||
local LoadDir = MainDir:WaitForChild("Load")
|
||||
local TagsDir = LoadDir:WaitForChild("Tags")
|
||||
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local RS = game:GetService("RunService")
|
||||
|
||||
local ButtonTags = require(TagsDir:WaitForChild("Buttons"))
|
||||
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
local SoundEnums = require(EnumsDir:WaitForChild("Sounds"))
|
||||
|
||||
local Leveling = require(script:WaitForChild("Leveling"))
|
||||
local Doors = require(script:WaitForChild("Doors"))
|
||||
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 ButtonTags = require(Elevators:WaitForChild("Buttons"))
|
||||
local TractionRopes = require(Elevators:WaitForChild("TractionRopes"))
|
||||
local Lanterns = require(Elevators:WaitForChild("Lanterns"))
|
||||
local Buttons = require(Elevators:WaitForChild("Buttons"))
|
||||
|
||||
local Tags = require(LoadDir:WaitForChild("Tags"))
|
||||
|
||||
type rbxassetid = string
|
||||
|
||||
type Tags = Tags.ExportedTags
|
||||
type TagsConstructor = Tags.TagsConstructor
|
||||
|
||||
@@ -34,27 +37,31 @@ type Impl_Constructor = {
|
||||
constructor: Constructor_Fun,
|
||||
--Class functions
|
||||
__MoveFloors: (self: ClassConstructor, Level: number, RequestedLevel: number, GoingUp: boolean) -> (),
|
||||
GoToLevel: (self: ClassConstructor, RequestedLevel: number) -> ()
|
||||
RequestLevel: (self: ClassConstructor, RequestedLevel: number) -> ()
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Impl_Static_Props = {
|
||||
Name: Enums.ElevatorValues,
|
||||
Responsiveness: number,
|
||||
MaxVelocity: number,
|
||||
ButtonActivatedColor: Color3,
|
||||
ButtonDeactivatedColor: Color3,
|
||||
LanternDisplayColorOn: Color3,
|
||||
LanternDisplayColorOff: Color3,
|
||||
LanternChimeDirection: rbxassetid,
|
||||
LanternChimeLanding: rbxassetid,
|
||||
FloorLevelingDistance: number,
|
||||
DoorOpeningDistance: number,
|
||||
LeveledDistance: number,
|
||||
|
||||
Sounds: {
|
||||
LanternChimeDirection: SoundEnums.Otis1960LanternChimeDirection,
|
||||
LanternChimeLanding: SoundEnums.Otis1960LanternChimeLanding,
|
||||
},
|
||||
Colors: {
|
||||
ButtonActivated: Color3,
|
||||
ButtonDeactivated: Color3,
|
||||
LanternDisplayOn: Color3,
|
||||
LanternDisplayOff: Color3,
|
||||
},
|
||||
Attributes: {
|
||||
PassingFloor: IntValue,
|
||||
Moving: BoolValue,
|
||||
CurrentFloor: IntValue
|
||||
CurrentFloor: IntValue,
|
||||
Moving: BoolValue
|
||||
},
|
||||
Events: {
|
||||
ButtonActivated: BindableEvent
|
||||
@@ -98,17 +105,23 @@ Otis1960.DoorOpeningDistance = Otis1960.FloorLevelingDistance/2.8
|
||||
Otis1960.LeveledDistance = 0.5
|
||||
Otis1960.Responsiveness = 50
|
||||
Otis1960.MaxVelocity = 10
|
||||
Otis1960.ButtonActivatedColor = Color3.fromRGB(180,0,0)
|
||||
Otis1960.ButtonDeactivatedColor = Color3.fromRGB(139,139,139)
|
||||
Otis1960.LanternDisplayColorOn = Color3.fromRGB(255,114,71)
|
||||
Otis1960.LanternDisplayColorOff = Color3.fromRGB(55,55,55)
|
||||
Otis1960.LanternChimeDirection = "rbxassetid://16990287228"
|
||||
Otis1960.LanternChimeLanding = "rbxassetid://16990290265"
|
||||
|
||||
Otis1960.Sounds = {
|
||||
LanternChimeDirection = SoundEnums.Otis1960.LanternChimeDirection,
|
||||
LanternChimeLanding = SoundEnums.Otis1960.LanternChimeLanding
|
||||
}
|
||||
|
||||
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 = {
|
||||
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 = {
|
||||
@@ -121,18 +134,34 @@ Otis1960.Attributes.CurrentFloor.Value = 1
|
||||
|
||||
local Attributes = Otis1960.Attributes
|
||||
|
||||
local function HookButtons(self: ClassConstructor, ButtonsConstructor: ButtonTags.ButtonsConstructor, ButtonType: Enums.EnumValue)
|
||||
local ButtonFunctions = require(script:WaitForChild("ButtonFunctions"))
|
||||
local ButtonsConstructor = Buttons.constructor(Otis1960.Attributes, Otis1960.Events, Otis1960.Colors)
|
||||
|
||||
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 ButtonName, ButtonTree in ButtonList do
|
||||
if ButtonTree.Prompt then
|
||||
if ButtonTree.Inst then
|
||||
local Button = ButtonFunctions[ButtonNameType :: Enums.ButtonTreeValues]
|
||||
|
||||
if Button then
|
||||
Button(self, ButtonName, ButtonsConstructor, ButtonTree)
|
||||
end
|
||||
HookButtons(self, ButtonNameType :: Enums.ButtonTreeValues, ButtonName, ButtonTree)
|
||||
else
|
||||
warn(`{ButtonTree} is missing the field "Inst"`)
|
||||
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.TractionRopes = TractionRopes.constructor(self.Ropes, self.ElevatorBox_1960, Leveling)
|
||||
|
||||
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, Otis1960.LanternChimeDirection, Otis1960.LanternChimeLanding, LanternsTags, {
|
||||
Active = Otis1960.LanternDisplayColorOn,
|
||||
Off = Otis1960.LanternDisplayColorOff
|
||||
} :: Lanterns.Colors)
|
||||
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, LanternsTags, Otis1960.Sounds, Otis1960.Colors)
|
||||
|
||||
local ButtonsConstructor = ButtonTags.constructor(TagsConstructor, ButtonsTags)
|
||||
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)
|
||||
|
||||
local ClassConstructor = setmetatable(self, Otis1960)
|
||||
HookButtons(ClassConstructor, ButtonsConstructor, Enums.ButtonTree.Car)
|
||||
IterateButtons(ClassConstructor, ButtonsConstructor)
|
||||
|
||||
--Open the elevator doors on server start
|
||||
task.spawn(function()
|
||||
@@ -301,13 +327,33 @@ function Otis1960:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
|
||||
self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, GoalLevelVEC, ElevatorBoxCurrentPos.Z)
|
||||
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]
|
||||
|
||||
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)
|
||||
end
|
||||
else
|
||||
if Attributes.CurrentFloor.Value>=RequestedLevel then
|
||||
self:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
|
||||
end
|
||||
end
|
||||
else
|
||||
self:__MoveFloors(GoalLevelVEC, RequestedLevel, GoingUp)
|
||||
end
|
||||
else
|
||||
warn(`[{Otis1960.Name}]: landing out of range or equals the same range as the goal, requested landing: {tostring(RequestedLevel)}`)
|
||||
end
|
||||
|
||||
19
src/server/main/Enums/Sounds.lua
Normal file
19
src/server/main/Enums/Sounds.lua
Normal 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
|
||||
@@ -2,11 +2,10 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local ElevatorsDir = script.Parent
|
||||
local MainDir = ElevatorsDir.Parent
|
||||
local LoadDir = MainDir:WaitForChild("Load")
|
||||
local TagsDir = script.Parent
|
||||
local LoadDir = TagsDir.Parent
|
||||
|
||||
local Tags = require(ElevatorsDir:WaitForChild("Tags"))
|
||||
local Tags = require(LoadDir:WaitForChild("Tags"))
|
||||
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
@@ -23,9 +22,6 @@ type Impl_Constructor = {
|
||||
--Class functions
|
||||
DecodeCarTag: (self: ClassConstructor, FloorTag: string) -> number?,
|
||||
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
|
||||
|
||||
type Impl_Static_Props = {
|
||||
@@ -145,38 +141,4 @@ function ButtonsModule:CreatePromptButtons()
|
||||
return self.Buttons
|
||||
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
|
||||
Reference in New Issue
Block a user