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 --!native
--!strict --!strict
type HallDisplays = {Instance}
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
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 = { type Constructor_Return_Props = {
CurrentFloorAttribute: IntValue, CurrentFloorAttribute: IntValue,
HallDisplayTags: HallDisplays,
__CurrentFloorConnection: RBXScriptConnection? __CurrentFloorConnection: RBXScriptConnection?
} }
export type HallDisplaysConstructor = ClassConstructor
local HallDisplays = {} :: Impl_Constructor local HallDisplays = {} :: Impl_Constructor
HallDisplays.__index = HallDisplays HallDisplays.__index = HallDisplays
function HallDisplays.constructor(CurrentFloorAttribute) function HallDisplays.constructor(CurrentFloorAttribute, HallDisplayTags)
return setmetatable({ return setmetatable({
CurrentFloorAttribute = CurrentFloorAttribute CurrentFloorAttribute = CurrentFloorAttribute,
HallDisplayTags = HallDisplayTags
}, HallDisplays) }, HallDisplays)
end end
function HallDisplays:BindHallDisplays() function HallDisplays:SetHallDisplays(floor)
if self.__CurrentFloorConnection and self.__CurrentFloorConnection.Connected then for i = 1, #self.HallDisplayTags do
self.__CurrentFloorConnection:Disconnect() (self.HallDisplayTags[i] :: TextLabel).Text = floor
end end
end
function HallDisplays:BindHallDisplays()
self:UnBindHallDisplays()
self.__CurrentFloorConnection = self.CurrentFloorAttribute:GetPropertyChangedSignal("Value"):Connect(function() self.__CurrentFloorConnection = self.CurrentFloorAttribute:GetPropertyChangedSignal("Value"):Connect(function()
self:SetHallDisplays(tostring(self.CurrentFloorAttribute.Value))
end) end)
end end
function HallDisplays:UnBindHallDisplays()
if self.__CurrentFloorConnection and self.__CurrentFloorConnection.Connected then
self.__CurrentFloorConnection:Disconnect()
end
end
return HallDisplays return HallDisplays

View File

@@ -11,9 +11,10 @@ local RS: RunService = game:GetService("RunService")
local Enums = require(Storage:WaitForChild("Enums")) local Enums = require(Storage:WaitForChild("Enums"))
local Leveling = require(script:WaitForChild("Leveling")) local Leveling = require(script:WaitForChild("Leveling"))
local Doors = require(script:WaitForChild("Doors")) local Doors = require(script:WaitForChild("Doors"))
local MovingObjects = require(script:WaitForChild("MovingObjects")) local MovingObjects = require(script:WaitForChild("MovingObjects"))
local HallDisplays = require(script:WaitForChild("HallDisplays"))
local ElevatorMover = require(Elevators:WaitForChild("Mover")) local ElevatorMover = require(Elevators:WaitForChild("Mover"))
local ButtonTags = require(Elevators:WaitForChild("Buttons")) local ButtonTags = require(Elevators:WaitForChild("Buttons"))