motivation 0

This commit is contained in:
2024-04-13 01:14:02 -04:00
parent 5556006c83
commit 0b0a4fc4bc

View File

@@ -4,28 +4,35 @@
local ParentDir = script.Parent local ParentDir = script.Parent
local Elevators = ParentDir:WaitForChild("Elevators") local Elevators = ParentDir:WaitForChild("Elevators")
local ElevatorEnums = Elevators:WaitForChild("Enums") local ElevatorEnums = require(Elevators:WaitForChild("Enums"))
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage") local Storage = game:GetService("ReplicatedStorage")
local Tags = Storage:WaitForChild("Tags") local Tags = require(Storage:WaitForChild("Tags"))
type TagsConstructor = Tags.TagsConstructor type TagsConstructor = Tags.TagsConstructor
type TagProdcut = Tags.TagProdcut type TagProduct = Tags.TagProduct
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
Lanterns: (self: ClassConstructor, ElevatorModel: ) -> Lanterns Lanterns: (self: ClassConstructor, ElevatorModel: ElevatorEnums.ElevatorValues) -> Lanterns,
Buttons: (self: ClassConstructor, ElevatorModel: ElevatorEnums.ElevatorValues) -> GetButtons,
Interactables: (self: ClassConstructor) -> ()
} & Impl_Static_Props } & Impl_Static_Props
type Impl_Static_Props = { type Decoders = {
Volume: number CarTag: (FloorTag: string) -> ()
} }
type Constructor_Fun = (Tags: TagsConstructor) -> ClassConstructor
type Impl_Static_Props = {
Decoders: Decoders
}
type Constructor_Fun = (TagsConstructor: TagsConstructor) -> ClassConstructor
type Constructor_Return_Props = { type Constructor_Return_Props = {
Tags: TagsConstructor, ExportedTags: Tags.ExportedTags,
} }
type Lantern = { type Lantern = {
@@ -57,26 +64,28 @@ export type ButtonProperties = {
local TagService = {} :: Impl_Constructor local TagService = {} :: Impl_Constructor
TagService.__index = TagService TagService.__index = TagService
function TagService.constructor(Tags) function TagService.constructor(TagsConstructor)
return setmetatable({ return setmetatable({
Tags = Tags ExportedTags = TagsConstructor.__export
}, TagService) }, TagService)
end end
TagService.Decoders = {} TagService.Decoders = {
CarTag = function(FloorTag)
function TagService.Decoders:CarTag(FloorTag)
local Match = FloorTag:match('%d+$') local Match = FloorTag:match('%d+$')
return Match and tonumber(Match) return Match and tonumber(Match)
end end
}
function TagService:Lanterns(ElevatorModel) function TagService:Lanterns(ElevatorModel)
local Lanterns = {} :: Lanterns local Lanterns = {} :: Lanterns
for TagName: string, Inst: TagProduct in self.Tags do for TagName: string, Inst: TagProduct in self.ExportedTags do
local Split = TagName:split('_') local Split = TagName:split('_')
if Split[1] == ElevatorModel and Split[2] == "DirectionIndicator" then if Split[1] == ElevatorModel and Split[2] == "DirectionIndicator" then
local Floor = tonumber(Split[3]) local Floor = tonumber(Split[3])
if Floor then if Floor then
if not Lanterns[Floor] then if not Lanterns[Floor] then
Lanterns[Floor] = { Lanterns[Floor] = {
@@ -113,9 +122,10 @@ end
function TagService:Buttons(ElevatorModel) function TagService:Buttons(ElevatorModel)
local Buttons: GetButtons = {} local Buttons: GetButtons = {}
for TagName: string, Inst: TagProduct in self.Tags do for TagName: string, Inst: TagProduct in self.ExportedTags do
local Split = TagName:split('_') local Split = TagName:split('_')
if Split[1] == self.Model and (Split[2] == "ElevatorButton" or Split[2] == "RelayButton") then
if Split[1] == ElevatorModel and (Split[2] == "ElevatorButton" or Split[2] == "RelayButton") then
if typeof(Inst) == "Instance" then if typeof(Inst) == "Instance" then
Buttons[TagName] = Inst Buttons[TagName] = Inst
else else