hall displays

This commit is contained in:
2024-05-08 21:46:43 -04:00
parent f905a4251d
commit 0e119db084
2 changed files with 29 additions and 11 deletions

View File

@@ -2,37 +2,54 @@
--!native
--!strict
type HallDisplays = {Instance}
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
BindHallDisplays: (self: ClassConstructor) -> ()
BindHallDisplays: (self: ClassConstructor) -> (),
UnBindHallDisplays: (self: ClassConstructor) -> (),
SetHallDisplays: (self: ClassConstructor, floor: string) -> ()
}
type Constructor_Fun = (CurrentFloorAttribute: IntValue) -> ClassConstructor
type Constructor_Fun = (CurrentFloorAttribute: IntValue, HallDisplayTags: HallDisplays) -> ClassConstructor
type Constructor_Return_Props = {
CurrentFloorAttribute: IntValue,
HallDisplayTags: HallDisplays,
__CurrentFloorConnection: RBXScriptConnection?
}
export type HallDisplaysConstructor = ClassConstructor
local HallDisplays = {} :: Impl_Constructor
HallDisplays.__index = HallDisplays
function HallDisplays.constructor(CurrentFloorAttribute)
function HallDisplays.constructor(CurrentFloorAttribute, HallDisplayTags)
return setmetatable({
CurrentFloorAttribute = CurrentFloorAttribute
CurrentFloorAttribute = CurrentFloorAttribute,
HallDisplayTags = HallDisplayTags
}, HallDisplays)
end
function HallDisplays:BindHallDisplays()
if self.__CurrentFloorConnection and self.__CurrentFloorConnection.Connected then
self.__CurrentFloorConnection:Disconnect()
function HallDisplays:SetHallDisplays(floor)
for i = 1, #self.HallDisplayTags do
(self.HallDisplayTags[i] :: TextLabel).Text = floor
end
end
function HallDisplays:BindHallDisplays()
self:UnBindHallDisplays()
self.__CurrentFloorConnection = self.CurrentFloorAttribute:GetPropertyChangedSignal("Value"):Connect(function()
self:SetHallDisplays(tostring(self.CurrentFloorAttribute.Value))
end)
end
function HallDisplays:UnBindHallDisplays()
if self.__CurrentFloorConnection and self.__CurrentFloorConnection.Connected then
self.__CurrentFloorConnection:Disconnect()
end
end
return HallDisplays

View File

@@ -11,9 +11,10 @@ local RS: RunService = game:GetService("RunService")
local Enums = require(Storage:WaitForChild("Enums"))
local Leveling = require(script:WaitForChild("Leveling"))
local Doors = require(script:WaitForChild("Doors"))
local MovingObjects = require(script:WaitForChild("MovingObjects"))
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 ElevatorMover = require(Elevators:WaitForChild("Mover"))
local ButtonTags = require(Elevators:WaitForChild("Buttons"))