Lantern config and working lantern state

This commit is contained in:
2024-09-13 00:11:12 -04:00
parent 80b0edeca8
commit 192a971723
4 changed files with 53 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
--!optimize 2
--!strict
local MainDir = script.Parent.Parent.Parent
local MainDir = script.Parent.Parent.Parent.Parent
local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags"))
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator"))
@@ -12,7 +12,7 @@ type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
Toggle: (self: ClassConstructor, OnState: boolean, UpDirection: boolean) -> Tween?,
Toggle: (self: ClassConstructor, OnState: boolean, UpLantern: boolean) -> Tween?,
Off: (self: ClassConstructor) -> (Tween?, Tween?),
}
@@ -22,6 +22,8 @@ type Constructor_Return_Props = {
ElevatorConfig: ElevatorTypes.ElevatorConfigurationTable
}
export type constructor = ClassConstructor
local ArrowLanterns = {} :: Impl_Constructor
ArrowLanterns.__index = ArrowLanterns
@@ -32,15 +34,15 @@ function ArrowLanterns.constructor(Lanterns, ElevatorConfig)
}, ArrowLanterns)
end
function ArrowLanterns:Toggle(OnState, UpDirection)
local LanternType = UpDirection and self.Lanterns.Up or self.Lanterns.Down
function ArrowLanterns:Toggle(OnState, UpLantern)
local LanternType = UpLantern and self.Lanterns.Up or self.Lanterns.Down
if LanternType then
--mega boolean short circuit
local ConfigState = OnState and (UpDirection and self.ElevatorConfig.Lanterns.On.Up or self.ElevatorConfig.Lanterns.On.Down) or (UpDirection and self.ElevatorConfig.Lanterns.Off.Up or self.ElevatorConfig.Lanterns.Off.Down)
local ConfigState = OnState and (UpLantern and self.ElevatorConfig.Lanterns.On.Up or self.ElevatorConfig.Lanterns.On.Down) or (UpLantern and self.ElevatorConfig.Lanterns.Off.Up or self.ElevatorConfig.Lanterns.Off.Down)
LanternType.Inst.Material = ConfigState.Material
local TweenTime = TweenInfo.new(ConfigState.Time)
local TweenTime = TweenInfo.new(ConfigState.Time, Enum.EasingStyle.Linear)
local UpArrowTween = TS:Create(LanternType.Inst, TweenTime, {
Color = ConfigState.Color
})
@@ -51,7 +53,7 @@ function ArrowLanterns:Toggle(OnState, UpDirection)
return UpArrowTween
else
warn(`[{self.ElevatorConfig.Name}]: Could not toggle a direction lantern. UpDirection={UpDirection} OnState={OnState}, LaternType={LanternType}`)
warn(`[{self.ElevatorConfig.Name}]: Could not toggle a direction lantern. UpLantern={UpLantern} OnState={OnState}, LaternType={LanternType}`)
end
return nil
end