mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
motivation 0
This commit is contained in:
@@ -4,28 +4,35 @@
|
||||
|
||||
local ParentDir = script.Parent
|
||||
local Elevators = ParentDir:WaitForChild("Elevators")
|
||||
local ElevatorEnums = Elevators:WaitForChild("Enums")
|
||||
local ElevatorEnums = require(Elevators:WaitForChild("Enums"))
|
||||
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local Tags = Storage:WaitForChild("Tags")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local Tags = require(Storage:WaitForChild("Tags"))
|
||||
|
||||
type TagsConstructor = Tags.TagsConstructor
|
||||
type TagProdcut = Tags.TagProdcut
|
||||
type TagProduct = Tags.TagProduct
|
||||
|
||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||
type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
--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
|
||||
|
||||
type Impl_Static_Props = {
|
||||
Volume: number
|
||||
type Decoders = {
|
||||
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 = {
|
||||
Tags: TagsConstructor,
|
||||
ExportedTags: Tags.ExportedTags,
|
||||
}
|
||||
|
||||
type Lantern = {
|
||||
@@ -57,26 +64,28 @@ export type ButtonProperties = {
|
||||
local TagService = {} :: Impl_Constructor
|
||||
TagService.__index = TagService
|
||||
|
||||
function TagService.constructor(Tags)
|
||||
function TagService.constructor(TagsConstructor)
|
||||
return setmetatable({
|
||||
Tags = Tags
|
||||
ExportedTags = TagsConstructor.__export
|
||||
}, TagService)
|
||||
end
|
||||
|
||||
TagService.Decoders = {}
|
||||
|
||||
function TagService.Decoders:CarTag(FloorTag)
|
||||
local Match = FloorTag:match('%d+$')
|
||||
return Match and tonumber(Match)
|
||||
end
|
||||
TagService.Decoders = {
|
||||
CarTag = function(FloorTag)
|
||||
local Match = FloorTag:match('%d+$')
|
||||
return Match and tonumber(Match)
|
||||
end
|
||||
}
|
||||
|
||||
function TagService:Lanterns(ElevatorModel)
|
||||
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('_')
|
||||
|
||||
if Split[1] == ElevatorModel and Split[2] == "DirectionIndicator" then
|
||||
local Floor = tonumber(Split[3])
|
||||
|
||||
if Floor then
|
||||
if not Lanterns[Floor] then
|
||||
Lanterns[Floor] = {
|
||||
@@ -113,9 +122,10 @@ end
|
||||
function TagService:Buttons(ElevatorModel)
|
||||
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('_')
|
||||
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
|
||||
Buttons[TagName] = Inst
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user