mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
hall displays
This commit is contained in:
@@ -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
|
||||||
@@ -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"))
|
||||||
|
|||||||
Reference in New Issue
Block a user