mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 23:01:53 +00:00
Tag service module
This commit is contained in:
@@ -17,7 +17,7 @@ type Impl_Constructor = {
|
||||
constructor: Constructor_Fun,
|
||||
Get: (Tags: Tags.TagsConstructor, Model: Enums.ElevatorValues) -> Lanterns,
|
||||
--Class functions
|
||||
__Activate: (self: ClassConstructor, EnabledState: boolean, IsDirectionLantern: boolean, Lantern: Lantern) -> (),
|
||||
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) -> (),
|
||||
@@ -79,49 +79,9 @@ function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, Lan
|
||||
}, 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)
|
||||
function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern)
|
||||
local Tween = LanternLight:Start(Lantern.Light, {
|
||||
Color = EnabledState and self.Colors.Active or self.Colors.Off
|
||||
})
|
||||
@@ -140,11 +100,11 @@ 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)
|
||||
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:Activate(false, false, self.LanternsMap[n])
|
||||
self.LanternsMap[n].Played = false
|
||||
end
|
||||
end
|
||||
@@ -152,14 +112,14 @@ end
|
||||
function Lanterns:DirectionUp(Enabled)
|
||||
if not self.LanternsMap.Up.Played then
|
||||
self.LanternsMap.Up.Played = true
|
||||
self:__Activate(Enabled, true, self.LanternsMap.Up)
|
||||
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)
|
||||
self:Activate(Enabled, true, self.LanternsMap.Down)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -167,7 +127,7 @@ function Lanterns:Toggle(Enabled, Floor)
|
||||
local f = self.LanternsMap[Floor]
|
||||
if not f.Played then
|
||||
f.Played = true
|
||||
self:__Activate(Enabled, false, f)
|
||||
self:Activate(Enabled, false, f)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user