mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
Physical relays
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -123,7 +123,6 @@ function ButtonFunctions:LandingButton(ButtonID, ButtonTree, Callback, Fallback)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function ButtonFunctions:SpecialButton(ButtonID, ButtonName, ButtonTree, Callback)
|
function ButtonFunctions:SpecialButton(ButtonID, ButtonName, ButtonTree, Callback)
|
||||||
--precomputing speed
|
--precomputing speed
|
||||||
if ButtonID == Enums.SpecialButton.Stop then
|
if ButtonID == Enums.SpecialButton.Stop then
|
||||||
@@ -142,7 +141,7 @@ function ButtonFunctions:SpecialButton(ButtonID, ButtonName, ButtonTree, Callbac
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ButtonFunctions:__DeactivateButton(Button, Glass)
|
function ButtonFunctions:__DeactivateButton(Button, Glass)
|
||||||
local Part = Glass and Glass or Button
|
local Part = Glass or Button
|
||||||
|
|
||||||
Part.Material = Enum.Material.Glass
|
Part.Material = Enum.Material.Glass
|
||||||
Part.Color = self.ElevatorButtonColors.ButtonDeactivated
|
Part.Color = self.ElevatorButtonColors.ButtonDeactivated
|
||||||
@@ -150,7 +149,7 @@ function ButtonFunctions:__DeactivateButton(Button, Glass)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ButtonFunctions:__ActivateButton(Button, Glass)
|
function ButtonFunctions:__ActivateButton(Button, Glass)
|
||||||
local Part = Glass and Glass or Button
|
local Part = Glass or Button
|
||||||
|
|
||||||
Part.Material = Enum.Material.Neon
|
Part.Material = Enum.Material.Neon
|
||||||
Part.Color = self.ElevatorButtonColors.ButtonActivated
|
Part.Color = self.ElevatorButtonColors.ButtonActivated
|
||||||
@@ -159,7 +158,7 @@ end
|
|||||||
|
|
||||||
function ButtonFunctions:AestheticActivateButton(Button)
|
function ButtonFunctions:AestheticActivateButton(Button)
|
||||||
local Glass = Button:FindFirstChild("Glass") :: BasePart?
|
local Glass = Button:FindFirstChild("Glass") :: BasePart?
|
||||||
local LookVec = (Glass and Glass or Button).CFrame.LookVector/50
|
local LookVec = (Glass or Button).CFrame.LookVector/50
|
||||||
if Glass then
|
if Glass then
|
||||||
Glass.Position+=LookVec
|
Glass.Position+=LookVec
|
||||||
self:__ActivateButton(Button, Glass)
|
self:__ActivateButton(Button, Glass)
|
||||||
|
|||||||
107
src/server/main/Elevators/Otis1960/PhysicalRelay.lua
Normal file
107
src/server/main/Elevators/Otis1960/PhysicalRelay.lua
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
--!optimize 2
|
||||||
|
--!native
|
||||||
|
--!strict
|
||||||
|
|
||||||
|
local Elevators = script.Parent
|
||||||
|
local MainDir = Elevators.Parent.Parent
|
||||||
|
local LoadDir = MainDir:WaitForChild("Load")
|
||||||
|
|
||||||
|
local Storage = game:GetService("ReplicatedStorage")
|
||||||
|
|
||||||
|
local Tween = require(Storage:WaitForChild("Tween"))
|
||||||
|
local Enums = require(Storage:WaitForChild("Enums"))
|
||||||
|
local Tags = require(LoadDir:WaitForChild("Tags"))
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
SetState: (self: ClassConstructor, RelayName: string, State: boolean) -> ()
|
||||||
|
} & Impl_Static_Props
|
||||||
|
|
||||||
|
type Impl_Static_Props = {
|
||||||
|
ActivatedAngle: number,
|
||||||
|
DeActivatedAngle: number,
|
||||||
|
AnimationTime: number
|
||||||
|
}
|
||||||
|
|
||||||
|
type Constructor_Fun = (ElevatorModel: Enums.ElevatorValues, RelayTagList: Tags.ButtonDictionary) -> ClassConstructor
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
ElevatorModel: Enums.ElevatorValues,
|
||||||
|
RelayTagList: Tags.ButtonDictionary & {
|
||||||
|
AudioActivated: Sound,
|
||||||
|
AudoDeactivated: Sound
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PhysicalRelayConstructor = ClassConstructor
|
||||||
|
|
||||||
|
local PhysicalRelay = {} :: Impl_Constructor
|
||||||
|
PhysicalRelay.__index = PhysicalRelay
|
||||||
|
|
||||||
|
PhysicalRelay.ActivatedAngle = 13
|
||||||
|
PhysicalRelay.DeActivatedAngle = -13
|
||||||
|
PhysicalRelay.AnimationTime = .05
|
||||||
|
|
||||||
|
function PhysicalRelay.constructor(ElevatorModel, RelayTagList)
|
||||||
|
--Idk how to construct an ideal way to identify these,
|
||||||
|
--Hard coding it is
|
||||||
|
for RelayName, RelayProperties in RelayTagList do
|
||||||
|
if RelayProperties.Inst then
|
||||||
|
local RelayAudioActivated = Instance.new("Sound")
|
||||||
|
local RelayAudioDeActivated = Instance.new("Sound")
|
||||||
|
RelayAudioActivated.Volume = 1
|
||||||
|
RelayAudioDeActivated.Volume = 1
|
||||||
|
|
||||||
|
if ElevatorModel == Enums.Elevator.Otis1960 then
|
||||||
|
if RelayProperties.Name == "240 V" or
|
||||||
|
RelayProperties.Name == "440 V" or
|
||||||
|
RelayProperties.Name == "UP" or
|
||||||
|
RelayProperties.Name == "DOWN"
|
||||||
|
then
|
||||||
|
RelayAudioActivated.SoundId = ""
|
||||||
|
RelayAudioDeActivated.SoundId = ""
|
||||||
|
else
|
||||||
|
RelayAudioActivated.SoundId = ""
|
||||||
|
RelayAudioDeActivated.SoundId = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
RelayAudioActivated.Parent = RelayProperties.Inst
|
||||||
|
end
|
||||||
|
else
|
||||||
|
warn()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable({
|
||||||
|
ElevatorModel = ElevatorModel,
|
||||||
|
RelayTagList = RelayTagList
|
||||||
|
}, PhysicalRelay)
|
||||||
|
end
|
||||||
|
|
||||||
|
local Animation = Tween.constructor(TweenInfo.new(PhysicalRelay.AnimationTime, Enum.EasingStyle.Linear))
|
||||||
|
|
||||||
|
local function OtimRelayAnimation(Relay: BasePart, State: boolean)
|
||||||
|
local T = Animation:Start(Relay, {
|
||||||
|
CFrame = Relay.CFrame*CFrame.Angles(math.rad(State and PhysicalRelay.ActivatedAngle or PhysicalRelay.DeActivatedAngle), 0, 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
T.Completed:Once(function()
|
||||||
|
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function PhysicalRelay:SetState(RelayName, State)
|
||||||
|
local Relay = self.RelayTagList[`RelayButton_{RelayName}`]
|
||||||
|
|
||||||
|
if Relay then
|
||||||
|
if self.ElevatorModel == Enums.Elevator.Otis1960 then
|
||||||
|
OtimRelayAnimation(Relay.Inst :: BasePart, State)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
warn(`Physical Relay "{RelayName}" does not exist! it will physically not work`)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return PhysicalRelay
|
||||||
@@ -2,8 +2,11 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
local RelayAlgorithmModule = require(script.Parent:WaitForChild("RelayAlgorithm"))
|
local ElevatorDir = script.Parent
|
||||||
local DoorsModule = require(script.Parent:WaitForChild("Doors"))
|
|
||||||
|
local RelayAlgorithmModule = require(ElevatorDir:WaitForChild("RelayAlgorithm"))
|
||||||
|
local DoorsModule = require(ElevatorDir:WaitForChild("Doors"))
|
||||||
|
local PhysicalRelay = require(ElevatorDir:WaitForChild("PhysicalRelay"))
|
||||||
|
|
||||||
type Leveling = {
|
type Leveling = {
|
||||||
Leveling: {number},
|
Leveling: {number},
|
||||||
@@ -25,9 +28,18 @@ type Impl_Constructor = {
|
|||||||
__GoalYLevel: (self: ClassConstructor) -> (),
|
__GoalYLevel: (self: ClassConstructor) -> (),
|
||||||
}
|
}
|
||||||
|
|
||||||
type Constructor_Fun = (RelayAlgorthm: RelayAlgorithmModule.RelayAlgorithmConstructor, ElevatorAttributes: ElevatorAttributes, DoorAttributes: DoorAttributes, Leveling: Leveling, BoxAlignPosition: BoxAlignPosition, ElevatorBox: ElevatorBox) -> ClassConstructor
|
type Constructor_Fun = (
|
||||||
|
PhysicalRelay: PhysicalRelay.PhysicalRelayConstructor,
|
||||||
|
RelayAlgorthm: RelayAlgorithmModule.RelayAlgorithmConstructor,
|
||||||
|
ElevatorAttributes: ElevatorAttributes,
|
||||||
|
DoorAttributes: DoorAttributes,
|
||||||
|
Leveling: Leveling,
|
||||||
|
BoxAlignPosition: BoxAlignPosition,
|
||||||
|
ElevatorBox: ElevatorBox
|
||||||
|
) -> ClassConstructor
|
||||||
|
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
|
PhysicalRelay: PhysicalRelay.PhysicalRelayConstructor,
|
||||||
RelayAlgorthm: RelayAlgorithmModule.RelayAlgorithmConstructor,
|
RelayAlgorthm: RelayAlgorithmModule.RelayAlgorithmConstructor,
|
||||||
ElevatorAttributes: ElevatorAttributes,
|
ElevatorAttributes: ElevatorAttributes,
|
||||||
DoorAttributes: DoorAttributes,
|
DoorAttributes: DoorAttributes,
|
||||||
@@ -36,7 +48,7 @@ type Constructor_Return_Props = {
|
|||||||
ElevatorBox: ElevatorBox,
|
ElevatorBox: ElevatorBox,
|
||||||
|
|
||||||
__Connections: {
|
__Connections: {
|
||||||
Ready: RBXScriptConnection?,
|
ReadyForMoving: RBXScriptConnection?,
|
||||||
Open: RBXScriptConnection?,
|
Open: RBXScriptConnection?,
|
||||||
GoalYLevel: RBXScriptConnection?,
|
GoalYLevel: RBXScriptConnection?,
|
||||||
Goal: RBXScriptConnection?
|
Goal: RBXScriptConnection?
|
||||||
@@ -45,7 +57,7 @@ type Constructor_Return_Props = {
|
|||||||
|
|
||||||
type ElevatorAttributes = {
|
type ElevatorAttributes = {
|
||||||
Relay: {
|
Relay: {
|
||||||
Ready: BoolValue,
|
ReadyForMoving: BoolValue,
|
||||||
GoalYLevel: NumberValue,
|
GoalYLevel: NumberValue,
|
||||||
Goal: IntValue
|
Goal: IntValue
|
||||||
},
|
},
|
||||||
@@ -60,8 +72,9 @@ export type RelayConstructor = ClassConstructor
|
|||||||
local Relay = {} :: Impl_Constructor
|
local Relay = {} :: Impl_Constructor
|
||||||
Relay.__index = Relay
|
Relay.__index = Relay
|
||||||
|
|
||||||
function Relay.constructor(RelayAlgorthm, ElevatorAttributes, DoorAttributes, LevelingModule, BoxAlignPosition, ElevatorBox)
|
function Relay.constructor(PhysicalRelay, RelayAlgorthm, ElevatorAttributes, DoorAttributes, LevelingModule, BoxAlignPosition, ElevatorBox)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
|
PhysicalRelay = PhysicalRelay,
|
||||||
RelayAlgorthm = RelayAlgorthm,
|
RelayAlgorthm = RelayAlgorthm,
|
||||||
ElevatorAttributes = ElevatorAttributes,
|
ElevatorAttributes = ElevatorAttributes,
|
||||||
DoorAttributes = DoorAttributes,
|
DoorAttributes = DoorAttributes,
|
||||||
@@ -74,17 +87,17 @@ function Relay.constructor(RelayAlgorthm, ElevatorAttributes, DoorAttributes, Le
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Relay:__Ready()
|
function Relay:__Ready()
|
||||||
if not self.ElevatorAttributes.Relay.Ready.Value then
|
if not self.ElevatorAttributes.Relay.ReadyForMoving.Value then
|
||||||
self:__GoalYLevel()
|
self:__GoalYLevel()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Relay:__Open()
|
function Relay:__Open()
|
||||||
self.ElevatorAttributes.Relay.Ready.Value = self.DoorAttributes.Relay.Open.Value
|
self.ElevatorAttributes.Relay.ReadyForMoving.Value = not self.DoorAttributes.Relay.Open.Value
|
||||||
end
|
end
|
||||||
|
|
||||||
function Relay:__GoalYLevel()
|
function Relay:__GoalYLevel()
|
||||||
if not self.ElevatorAttributes.Relay.Ready.Value then
|
if self.ElevatorAttributes.Relay.ReadyForMoving.Value then
|
||||||
self.BoxAlignPosition.Position = Vector3.new(
|
self.BoxAlignPosition.Position = Vector3.new(
|
||||||
self.ElevatorBox.Position.X,
|
self.ElevatorBox.Position.X,
|
||||||
self.ElevatorAttributes.Relay.GoalYLevel.Value,
|
self.ElevatorAttributes.Relay.GoalYLevel.Value,
|
||||||
@@ -100,29 +113,36 @@ function Relay:__Goal()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Relay:BulkConnect()
|
function Relay:BulkConnect()
|
||||||
self.__Connections.Ready = self.ElevatorAttributes.Relay.Ready:GetPropertyChangedSignal("Value"):Connect(function()
|
local ReadyForMovingRelay = self.ElevatorAttributes.Relay.ReadyForMoving
|
||||||
print("Relay=Ready","State=", self.ElevatorAttributes.Relay.Ready.Value)
|
local OpenRelay = self.DoorAttributes.Relay.Open
|
||||||
|
|
||||||
|
self.__Connections.ReadyForMoving = ReadyForMovingRelay:GetPropertyChangedSignal("Value"):Connect(function()
|
||||||
|
self.PhysicalRelay:SetState("RD", ReadyForMovingRelay.Value)
|
||||||
|
|
||||||
if not self.ElevatorAttributes.Stopped.Value then
|
if not self.ElevatorAttributes.Stopped.Value then
|
||||||
self:__Ready()
|
self:__Ready()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
self.__Connections.Open = self.DoorAttributes.Relay.Open:GetPropertyChangedSignal("Value"):Connect(function()
|
self.__Connections.Open = OpenRelay:GetPropertyChangedSignal("Value"):Connect(function()
|
||||||
print("Relay=Open","State=", self.DoorAttributes.Relay.Open.Value)
|
self.PhysicalRelay:SetState("DO", OpenRelay.Value)
|
||||||
|
|
||||||
if not self.ElevatorAttributes.Stopped.Value then
|
if not self.ElevatorAttributes.Stopped.Value then
|
||||||
self:__Open()
|
self:__Open()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
self.__Connections.GoalYLevel = self.ElevatorAttributes.Relay.GoalYLevel:GetPropertyChangedSignal("Value"):Connect(function()
|
self.__Connections.GoalYLevel = self.ElevatorAttributes.Relay.GoalYLevel:GetPropertyChangedSignal("Value"):Connect(function()
|
||||||
print("Relay=GoalYLevel","State=", self.ElevatorAttributes.Relay.GoalYLevel.Value)
|
|
||||||
|
|
||||||
if not self.ElevatorAttributes.Stopped.Value then
|
if not self.ElevatorAttributes.Stopped.Value then
|
||||||
self:__GoalYLevel()
|
self:__GoalYLevel()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
self.__Connections.Goal = self.ElevatorAttributes.Relay.Goal:GetPropertyChangedSignal("Value"):Connect(function()
|
self.__Connections.Goal = self.ElevatorAttributes.Relay.Goal:GetPropertyChangedSignal("Value"):Connect(function()
|
||||||
print("Relay=Goal","State=", self.ElevatorAttributes.Relay.Goal.Value)
|
|
||||||
|
|
||||||
if not self.ElevatorAttributes.Stopped.Value then
|
if not self.ElevatorAttributes.Stopped.Value then
|
||||||
self:__Goal()
|
self:__Goal()
|
||||||
end
|
end
|
||||||
@@ -130,8 +150,8 @@ function Relay:BulkConnect()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Relay:BulkDisconnect()
|
function Relay:BulkDisconnect()
|
||||||
if self.__Connections.Ready and self.__Connections.Ready.Connected then
|
if self.__Connections.ReadyForMoving and self.__Connections.ReadyForMoving.Connected then
|
||||||
self.__Connections.Ready:Disconnect()
|
self.__Connections.ReadyForMoving:Disconnect()
|
||||||
end
|
end
|
||||||
if self.__Connections.Open and self.__Connections.Open.Connected then
|
if self.__Connections.Open and self.__Connections.Open.Connected then
|
||||||
self.__Connections.Open:Disconnect()
|
self.__Connections.Open:Disconnect()
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ type ElevatorAttributes = {
|
|||||||
CurrentFloor: IntValue,
|
CurrentFloor: IntValue,
|
||||||
GoingUp: BoolValue,
|
GoingUp: BoolValue,
|
||||||
Moving: BoolValue,
|
Moving: BoolValue,
|
||||||
|
|
||||||
|
Relay: {
|
||||||
|
Goal: IntValue,
|
||||||
|
GoalYLevel: NumberValue,
|
||||||
|
ReadyForMoving: BoolValue,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DoorAttributes = {
|
type DoorAttributes = {
|
||||||
@@ -89,7 +95,7 @@ end
|
|||||||
function RelayAlgorithm:AddFloor(ElevatorGoingUp, RequestedLevel)
|
function RelayAlgorithm:AddFloor(ElevatorGoingUp, RequestedLevel)
|
||||||
self:RawInsert(ElevatorGoingUp, RequestedLevel)
|
self:RawInsert(ElevatorGoingUp, RequestedLevel)
|
||||||
|
|
||||||
return not self.ElevatorAttributes.Moving.Value and self.DoorAttributes.Relay.Open.Value
|
return not self.ElevatorAttributes.Relay.ReadyForMoving.Value
|
||||||
end
|
end
|
||||||
|
|
||||||
return RelayAlgorithm
|
return RelayAlgorithm
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
--Set relay tags through studio command line
|
--Set relay tags through studio command line
|
||||||
--[[
|
--[[
|
||||||
local s = game.Selection:Get()[1]
|
local s = game.Selection:Get()[1]
|
||||||
|
|
||||||
for i,v in s:GetChildren() do
|
for i,v in s:GetChildren() do
|
||||||
if v:IsA("Model") then
|
if v:IsA("Model") then
|
||||||
local main = v:FindFirstChild("main")
|
local main = v:FindFirstChild("main")
|
||||||
@@ -37,6 +38,7 @@ local Doors = require(script:WaitForChild("Doors"))
|
|||||||
local MovingObjects = require(script:WaitForChild("MovingObjects"))
|
local MovingObjects = require(script:WaitForChild("MovingObjects"))
|
||||||
local RelayAlgorithm = require(script:WaitForChild("RelayAlgorithm"))
|
local RelayAlgorithm = require(script:WaitForChild("RelayAlgorithm"))
|
||||||
local Relay = require(script:WaitForChild("Relay"))
|
local Relay = require(script:WaitForChild("Relay"))
|
||||||
|
local PhysicalRelays = require(script:WaitForChild("PhysicalRelay"))
|
||||||
|
|
||||||
local HallDisplays = require(Elevators:WaitForChild("HallDisplays"))
|
local HallDisplays = require(Elevators:WaitForChild("HallDisplays"))
|
||||||
local ElevatorMover = require(Elevators:WaitForChild("Mover"))
|
local ElevatorMover = require(Elevators:WaitForChild("Mover"))
|
||||||
@@ -54,12 +56,8 @@ type Impl_Constructor = {
|
|||||||
__index: Impl_Constructor,
|
__index: Impl_Constructor,
|
||||||
constructor: Constructor_Fun,
|
constructor: Constructor_Fun,
|
||||||
--Class functions
|
--Class functions
|
||||||
Leveled: (self: ClassConstructor, RequestedLevel: number) -> (),
|
RequestLevelAsync: (self: ClassConstructor, RequestedLevel: number) -> boolean,
|
||||||
Leveling: (self: ClassConstructor, RequestedLevel: number) -> (),
|
__MoveToAsync: (self: ClassConstructor, GoingUp: boolean, RequestedLevel: number) -> (),
|
||||||
FloorPassingUp: (self: ClassConstructor, ElevatorPositionY: number, RequestedLevel: number) -> (),
|
|
||||||
FloorPassingDown: (self: ClassConstructor, ElevatorPositionY: number, RequestedLevel: number) -> (),
|
|
||||||
RequestLevel: (self: ClassConstructor, RequestedLevel: number) -> boolean,
|
|
||||||
__MoveTo: (self: ClassConstructor, GoingUp: boolean, RequestedLevel: number) -> (),
|
|
||||||
__MovingHeartbeat: (self: ClassConstructor, GoingUp: boolean, RequestedLevel: number) -> (),
|
__MovingHeartbeat: (self: ClassConstructor, GoingUp: boolean, RequestedLevel: number) -> (),
|
||||||
} & Impl_Static_Props
|
} & Impl_Static_Props
|
||||||
|
|
||||||
@@ -91,7 +89,7 @@ type Impl_Static_Props = {
|
|||||||
Relay: {
|
Relay: {
|
||||||
Goal: IntValue,
|
Goal: IntValue,
|
||||||
GoalYLevel: NumberValue,
|
GoalYLevel: NumberValue,
|
||||||
Ready: BoolValue,
|
ReadyForMoving: BoolValue,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Events: {
|
Events: {
|
||||||
@@ -99,7 +97,13 @@ type Impl_Static_Props = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Constructor_Fun = (TagsConstructor: TagsConstructor, ButtonsTags: Tags.ElevatorButtons, LanternsTags: Tags.Lanterns, LandingDoors: Tags.LandingTags) -> ClassConstructor
|
type Constructor_Fun = (
|
||||||
|
TagsConstructor: TagsConstructor,
|
||||||
|
ButtonsTags: Tags.ElevatorButtons,
|
||||||
|
LanternsTags: Tags.Lanterns,
|
||||||
|
LandingDoors: Tags.LandingTags
|
||||||
|
) -> ClassConstructor
|
||||||
|
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
Tags: Tags,
|
Tags: Tags,
|
||||||
MOConstructor: MovingObjects.MovingObjectsConstructor,
|
MOConstructor: MovingObjects.MovingObjectsConstructor,
|
||||||
@@ -125,6 +129,7 @@ type Constructor_Return_Props = {
|
|||||||
ButtonsConstructor: Buttons.ButtonsConstructor,
|
ButtonsConstructor: Buttons.ButtonsConstructor,
|
||||||
RelayAlgorithmConstructor: RelayAlgorithm.RelayAlgorithmConstructor,
|
RelayAlgorithmConstructor: RelayAlgorithm.RelayAlgorithmConstructor,
|
||||||
RelayConstructor: Relay.RelayConstructor,
|
RelayConstructor: Relay.RelayConstructor,
|
||||||
|
PhysicalRelays: PhysicalRelays.PhysicalRelayConstructor,
|
||||||
|
|
||||||
__Connections: {
|
__Connections: {
|
||||||
Moving: RBXScriptConnection?,
|
Moving: RBXScriptConnection?,
|
||||||
@@ -162,7 +167,7 @@ Elevator.Attributes = {
|
|||||||
Stopped = Instance.new("BoolValue") :: BoolValue,
|
Stopped = Instance.new("BoolValue") :: BoolValue,
|
||||||
|
|
||||||
Relay = {
|
Relay = {
|
||||||
Ready = Instance.new("BoolValue") :: BoolValue,
|
ReadyForMoving = Instance.new("BoolValue") :: BoolValue,
|
||||||
Goal = Instance.new("IntValue") :: IntValue,
|
Goal = Instance.new("IntValue") :: IntValue,
|
||||||
GoalYLevel = Instance.new("NumberValue") :: NumberValue,
|
GoalYLevel = Instance.new("NumberValue") :: NumberValue,
|
||||||
},
|
},
|
||||||
@@ -178,19 +183,20 @@ Elevator.Attributes.GoingUp.Value = false
|
|||||||
|
|
||||||
Elevator.Attributes.Relay.Goal.Value = 1
|
Elevator.Attributes.Relay.Goal.Value = 1
|
||||||
Elevator.Attributes.Relay.GoalYLevel.Value = LevelingModule.Leveling[Elevator.Attributes.CurrentFloor.Value]
|
Elevator.Attributes.Relay.GoalYLevel.Value = LevelingModule.Leveling[Elevator.Attributes.CurrentFloor.Value]
|
||||||
Elevator.Attributes.Relay.Ready.Value = false
|
Elevator.Attributes.Relay.ReadyForMoving.Value = false
|
||||||
|
|
||||||
local Attributes = Elevator.Attributes
|
local Attributes = Elevator.Attributes
|
||||||
|
|
||||||
--Math function for determining if the elevator goal is to move upwards or not
|
--Math function for determining if the elevator goal is to move upwards or not
|
||||||
local function ElevatorGoingUpDirection(CurrentFloor: number, RequestedFloor: number): boolean
|
local function ElevatorGoingUpDirection(CurrentFloor: number, RequestedFloor: number): boolean
|
||||||
--(CurrentFloor-RequestedFloor)>0
|
-- -(CurrentFloor-RequestedFloor)>0
|
||||||
return -CurrentFloor+RequestedFloor>0
|
-- -CurrentFloor+RequestedFloor>0
|
||||||
|
return CurrentFloor<RequestedFloor
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _ActivatedFloorButton(self: ClassConstructor, ButtonFloor: number, ButtonTree: Tags.ButtonPropertiesSafe)
|
local function _ActivatedFloorButton(self: ClassConstructor, ButtonFloor: number, ButtonTree: Tags.ButtonPropertiesSafe)
|
||||||
ButtonTree.Prompt.Enabled = false
|
ButtonTree.Prompt.Enabled = false
|
||||||
local Some = self:RequestLevel(ButtonFloor)
|
local Some = self:RequestLevelAsync(ButtonFloor)
|
||||||
|
|
||||||
if Some then
|
if Some then
|
||||||
local FloorTracker: RBXScriptConnection
|
local FloorTracker: RBXScriptConnection
|
||||||
@@ -212,9 +218,9 @@ end
|
|||||||
--If the elevator is fully stopped at the floor and the hall button or the same cab button for the same floor is pressed,
|
--If the elevator is fully stopped at the floor and the hall button or the same cab button for the same floor is pressed,
|
||||||
--then open the doors
|
--then open the doors
|
||||||
local function OpenElevatorDoorsSafe(self: ClassConstructor)
|
local function OpenElevatorDoorsSafe(self: ClassConstructor)
|
||||||
print("Relay.Open=",Doors.Attributes.Relay.Open.Value,"Relay.Ready=",Attributes.Relay.Ready.Value)
|
print("Relay.Open=",Doors.Attributes.Relay.Open.Value,"Relay.ReadyForMoving=",Attributes.Relay.ReadyForMoving.Value)
|
||||||
|
|
||||||
if not Doors.Attributes.Relay.Open.Value and not Attributes.Relay.Ready.Value then
|
if not Attributes.Relay.ReadyForMoving.Value then
|
||||||
task.spawn(function()
|
task.spawn(function()
|
||||||
self.ElevatorDoorsConstructor:ToggleElevatorDoorsAsync(true, Attributes.CurrentFloor.Value)
|
self.ElevatorDoorsConstructor:ToggleElevatorDoorsAsync(true, Attributes.CurrentFloor.Value)
|
||||||
end)
|
end)
|
||||||
@@ -257,7 +263,7 @@ local function HookButtons(self: ClassConstructor, ButtonNameType: Enums.ButtonT
|
|||||||
(ButtonTree.Inst :: BasePart).Position-=Vector3.new(0,0,.05)
|
(ButtonTree.Inst :: BasePart).Position-=Vector3.new(0,0,.05)
|
||||||
|
|
||||||
self.LanternsConstructor:Reset()
|
self.LanternsConstructor:Reset()
|
||||||
self:__MoveTo(ElevatorGoingUpDirection(Attributes.CurrentFloor.Value, Attributes.Relay.Goal.Value))
|
self:__MoveToAsync(ElevatorGoingUpDirection(Attributes.CurrentFloor.Value, Attributes.Relay.Goal.Value))
|
||||||
self.BoxAlignPosition.MaxVelocity = Elevator.MaxVelocity
|
self.BoxAlignPosition.MaxVelocity = Elevator.MaxVelocity
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -273,7 +279,7 @@ local function HookButtons(self: ClassConstructor, ButtonNameType: Enums.ButtonT
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function IterateButtons(self: ClassConstructor, ButtonsTagsConstructor: ButtonTags.ButtonsTagsConstructor)
|
local function IterateButtons(self: ClassConstructor, ButtonsTagsConstructor: ButtonTags.ButtonsTagsConstructor)
|
||||||
for ButtonNameType, ButtonList in ButtonsTagsConstructor.Buttons do
|
for ButtonNameType, ButtonList in ButtonsTagsConstructor.Buttons[Elevator.Name] do
|
||||||
for ButtonID, ButtonTree in ButtonList do
|
for ButtonID, ButtonTree in ButtonList do
|
||||||
if ButtonTree.Prompt and ButtonTree.Inst and ButtonTree.Attachment then
|
if ButtonTree.Prompt and ButtonTree.Inst and ButtonTree.Attachment then
|
||||||
HookButtons(self, ButtonNameType :: Enums.ButtonTreeValues, ButtonID, ButtonTree :: Tags.ButtonPropertiesSafe)
|
HookButtons(self, ButtonNameType :: Enums.ButtonTreeValues, ButtonID, ButtonTree :: Tags.ButtonPropertiesSafe)
|
||||||
@@ -329,7 +335,7 @@ function Elevator.constructor(TagsConstructor, ButtonsTags, LanternsTags, Landin
|
|||||||
--Init the lanterns
|
--Init the lanterns
|
||||||
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, LanternsTags, Elevator.Sounds, Elevator.Colors)
|
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, LanternsTags, Elevator.Sounds, Elevator.Colors)
|
||||||
|
|
||||||
local ButtonsTagsConstructor = ButtonTags.constructor(TagsConstructor, ButtonsTags)
|
local ButtonsTagsConstructor = ButtonTags.constructor(TagsConstructor, ButtonsTags, Elevator.Name)
|
||||||
local Otis1960_Buttons = ButtonsTagsConstructor:CreatePromptButtons()
|
local Otis1960_Buttons = ButtonsTagsConstructor:CreatePromptButtons()
|
||||||
|
|
||||||
self.ButtonsConstructor = Buttons.constructor(Elevator.Attributes, Elevator.Events, Elevator.Colors)
|
self.ButtonsConstructor = Buttons.constructor(Elevator.Attributes, Elevator.Events, Elevator.Colors)
|
||||||
@@ -345,8 +351,11 @@ function Elevator.constructor(TagsConstructor, ButtonsTags, LanternsTags, Landin
|
|||||||
Elevator.MaxVelocity
|
Elevator.MaxVelocity
|
||||||
)
|
)
|
||||||
|
|
||||||
|
--Relays
|
||||||
|
self.PhysicalRelays = PhysicalRelays.constructor(Elevator.Name, ButtonsTagsConstructor.Buttons[Elevator.Name].Relays)
|
||||||
self.RelayAlgorithmConstructor = RelayAlgorithm.constructor(self.BoxAlignPosition, Attributes, Doors.Attributes)
|
self.RelayAlgorithmConstructor = RelayAlgorithm.constructor(self.BoxAlignPosition, Attributes, Doors.Attributes)
|
||||||
self.RelayConstructor = Relay.constructor(
|
self.RelayConstructor = Relay.constructor(
|
||||||
|
self.PhysicalRelays,
|
||||||
self.RelayAlgorithmConstructor,
|
self.RelayAlgorithmConstructor,
|
||||||
Attributes,
|
Attributes,
|
||||||
Doors.Attributes,
|
Doors.Attributes,
|
||||||
@@ -372,7 +381,7 @@ function Elevator.constructor(TagsConstructor, ButtonsTags, LanternsTags, Landin
|
|||||||
return ClassConstructor
|
return ClassConstructor
|
||||||
end
|
end
|
||||||
|
|
||||||
function Elevator:Leveled(RequestedLevel)
|
local function Leveled(self: ClassConstructor, RequestedLevel: number)
|
||||||
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
||||||
Attributes.Moving.Value = false
|
Attributes.Moving.Value = false
|
||||||
Attributes.CurrentFloor.Value = RequestedLevel
|
Attributes.CurrentFloor.Value = RequestedLevel
|
||||||
@@ -385,19 +394,19 @@ function Elevator:Leveled(RequestedLevel)
|
|||||||
|
|
||||||
if self.RelayAlgorithmConstructor:Check(ElevatorGoingUp) then
|
if self.RelayAlgorithmConstructor:Check(ElevatorGoingUp) then
|
||||||
--More floors in the queue
|
--More floors in the queue
|
||||||
self:__MoveTo(ElevatorGoingUp, RequestedLevel)
|
self:__MoveToAsync(ElevatorGoingUp, RequestedLevel)
|
||||||
else
|
else
|
||||||
--The elevator is at a full park now
|
--The elevator is at a full park now
|
||||||
Attributes.Relay.Ready.Value = false
|
Attributes.Relay.ReadyForMoving.Value = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Elevator:Leveling(RequestedLevel)
|
local function Leveling(self: ClassConstructor, RequestedLevel: number)
|
||||||
self.BoxAlignPosition.MaxVelocity = 1
|
self.BoxAlignPosition.MaxVelocity = 1
|
||||||
self.LanternsConstructor:Toggle(true, RequestedLevel)
|
self.LanternsConstructor:Toggle(true, RequestedLevel)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Elevator:FloorPassingUp(ElevatorPositionY, RequestedLevel)
|
local function FloorPassingUp(self: ClassConstructor, ElevatorPositionY: number, RequestedLevel: number)
|
||||||
local NextLevelBetweenFloors: number? = LevelingModule.LevelingBetween[Attributes.CurrentFloor.Value+1]
|
local NextLevelBetweenFloors: number? = LevelingModule.LevelingBetween[Attributes.CurrentFloor.Value+1]
|
||||||
|
|
||||||
if NextLevelBetweenFloors and ElevatorPositionY>=NextLevelBetweenFloors then
|
if NextLevelBetweenFloors and ElevatorPositionY>=NextLevelBetweenFloors then
|
||||||
@@ -408,7 +417,7 @@ function Elevator:FloorPassingUp(ElevatorPositionY, RequestedLevel)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Elevator:FloorPassingDown(ElevatorPositionY, RequestedLevel)
|
local function FloorPassingDown(self: ClassConstructor, ElevatorPositionY: number, RequestedLevel: number)
|
||||||
local NextLevelBetweenFloors: number? = LevelingModule.LevelingBetween[Attributes.CurrentFloor.Value-1]
|
local NextLevelBetweenFloors: number? = LevelingModule.LevelingBetween[Attributes.CurrentFloor.Value-1]
|
||||||
|
|
||||||
if NextLevelBetweenFloors and ElevatorPositionY<=NextLevelBetweenFloors then
|
if NextLevelBetweenFloors and ElevatorPositionY<=NextLevelBetweenFloors then
|
||||||
@@ -420,10 +429,6 @@ function Elevator:FloorPassingDown(ElevatorPositionY, RequestedLevel)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Elevator:__MovingHeartbeat(GoingUp, RequestedLevel)
|
function Elevator:__MovingHeartbeat(GoingUp, RequestedLevel)
|
||||||
Attributes.GoingUp.Value = GoingUp
|
|
||||||
Attributes.Relay.Goal.Value = RequestedLevel
|
|
||||||
Attributes.Moving.Value = true
|
|
||||||
|
|
||||||
if self.__Connections.Moving and self.__Connections.Moving.Connected then
|
if self.__Connections.Moving and self.__Connections.Moving.Connected then
|
||||||
self.__Connections.Moving:Disconnect()
|
self.__Connections.Moving:Disconnect()
|
||||||
end
|
end
|
||||||
@@ -431,6 +436,10 @@ function Elevator:__MovingHeartbeat(GoingUp, RequestedLevel)
|
|||||||
local Delta = 0
|
local Delta = 0
|
||||||
local DoorsOpeningDebounce = false
|
local DoorsOpeningDebounce = false
|
||||||
|
|
||||||
|
Attributes.GoingUp.Value = GoingUp
|
||||||
|
Attributes.Relay.Goal.Value = RequestedLevel
|
||||||
|
Attributes.Moving.Value = true
|
||||||
|
|
||||||
self.MOConstructor:UpdateCFrame()
|
self.MOConstructor:UpdateCFrame()
|
||||||
|
|
||||||
self.__Connections.Moving = RS.Heartbeat:Connect(function(_dt)
|
self.__Connections.Moving = RS.Heartbeat:Connect(function(_dt)
|
||||||
@@ -446,10 +455,10 @@ function Elevator:__MovingHeartbeat(GoingUp, RequestedLevel)
|
|||||||
|
|
||||||
--Kill the connection
|
--Kill the connection
|
||||||
if Attributes.GoingUp.Value then
|
if Attributes.GoingUp.Value then
|
||||||
self:FloorPassingUp(ElevatorPositionY, Attributes.Relay.Goal.Value)
|
FloorPassingUp(self, ElevatorPositionY, Attributes.Relay.Goal.Value)
|
||||||
|
|
||||||
if ElevatorPositionY>=BoxAlignY-Elevator.FloorLevelingDistance then
|
if ElevatorPositionY>=BoxAlignY-Elevator.FloorLevelingDistance then
|
||||||
self:Leveling(Attributes.Relay.Goal.Value)
|
Leveling(self, Attributes.Relay.Goal.Value)
|
||||||
|
|
||||||
if not DoorsOpeningDebounce and ElevatorPositionY>=BoxAlignY-Elevator.DoorOpeningDistance then
|
if not DoorsOpeningDebounce and ElevatorPositionY>=BoxAlignY-Elevator.DoorOpeningDistance then
|
||||||
DoorsOpeningDebounce = true
|
DoorsOpeningDebounce = true
|
||||||
@@ -458,13 +467,13 @@ function Elevator:__MovingHeartbeat(GoingUp, RequestedLevel)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ElevatorPositionY>=BoxAlignY-Elevator.LeveledDistance then
|
if ElevatorPositionY>=BoxAlignY-Elevator.LeveledDistance then
|
||||||
self:Leveled(Attributes.Relay.Goal.Value)
|
Leveled(self, Attributes.Relay.Goal.Value)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:FloorPassingDown(ElevatorPositionY, Attributes.Relay.Goal.Value)
|
FloorPassingDown(self, ElevatorPositionY, Attributes.Relay.Goal.Value)
|
||||||
|
|
||||||
if ElevatorPositionY<=BoxAlignY+Elevator.FloorLevelingDistance then
|
if ElevatorPositionY<=BoxAlignY+Elevator.FloorLevelingDistance then
|
||||||
self:Leveling(Attributes.Relay.Goal.Value)
|
Leveling(self, Attributes.Relay.Goal.Value)
|
||||||
|
|
||||||
if not DoorsOpeningDebounce and ElevatorPositionY>=BoxAlignY-Elevator.DoorOpeningDistance then
|
if not DoorsOpeningDebounce and ElevatorPositionY>=BoxAlignY-Elevator.DoorOpeningDistance then
|
||||||
DoorsOpeningDebounce = true
|
DoorsOpeningDebounce = true
|
||||||
@@ -473,13 +482,13 @@ function Elevator:__MovingHeartbeat(GoingUp, RequestedLevel)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ElevatorPositionY<=BoxAlignY+Elevator.LeveledDistance then
|
if ElevatorPositionY<=BoxAlignY+Elevator.LeveledDistance then
|
||||||
self:Leveled(Attributes.Relay.Goal.Value)
|
Leveled(self, Attributes.Relay.Goal.Value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Elevator:__MoveTo(GoingUp, RequestedLevel)
|
function Elevator:__MoveToAsync(GoingUp, RequestedLevel)
|
||||||
if Doors.Attributes.Relay.Open.Value then
|
if Doors.Attributes.Relay.Open.Value then
|
||||||
self.ElevatorDoorsConstructor:ToggleElevatorDoorsAsync(false, Attributes.CurrentFloor.Value)
|
self.ElevatorDoorsConstructor:ToggleElevatorDoorsAsync(false, Attributes.CurrentFloor.Value)
|
||||||
end
|
end
|
||||||
@@ -492,7 +501,7 @@ function Elevator:__MoveTo(GoingUp, RequestedLevel)
|
|||||||
self:__MovingHeartbeat(GoingUp, RequestedLevel)
|
self:__MovingHeartbeat(GoingUp, RequestedLevel)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Elevator:RequestLevel(RequestedLevel)
|
function Elevator:RequestLevelAsync(RequestedLevel)
|
||||||
local FloorExist: number? = LevelingModule.Leveling[RequestedLevel]
|
local FloorExist: number? = LevelingModule.Leveling[RequestedLevel]
|
||||||
|
|
||||||
if FloorExist and RequestedLevel ~= Attributes.CurrentFloor.Value then
|
if FloorExist and RequestedLevel ~= Attributes.CurrentFloor.Value then
|
||||||
@@ -500,7 +509,7 @@ function Elevator:RequestLevel(RequestedLevel)
|
|||||||
local Proceeding = self.RelayAlgorithmConstructor:AddFloor(ElevatorGoingUp, RequestedLevel)
|
local Proceeding = self.RelayAlgorithmConstructor:AddFloor(ElevatorGoingUp, RequestedLevel)
|
||||||
|
|
||||||
if Proceeding then
|
if Proceeding then
|
||||||
self:__MoveTo(ElevatorGoingUp, RequestedLevel)
|
self:__MoveToAsync(ElevatorGoingUp, RequestedLevel)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ export type Otis1960Sounds = typeof(SoundEnums.Otis1960)
|
|||||||
export type Otis1960LanternChimeDirection = "rbxassetid://16990287228"
|
export type Otis1960LanternChimeDirection = "rbxassetid://16990287228"
|
||||||
export type Otis1960LanternChimeLanding = "rbxassetid://16990290265"
|
export type Otis1960LanternChimeLanding = "rbxassetid://16990290265"
|
||||||
export type Otis1960DoorClosingClick = "rbxassetid://16357740945"
|
export type Otis1960DoorClosingClick = "rbxassetid://16357740945"
|
||||||
|
export type Otis1960RelayActivated = ""
|
||||||
|
export type Otis1960RelayDeActivated = ""
|
||||||
|
export type Otis1960BigRelayActivated = ""
|
||||||
|
export type Otis1960BigRelayDeActivated = ""
|
||||||
|
|
||||||
export type Otis1960SoundValues = Otis1960LanternChimeDirection |
|
export type Otis1960SoundValues = Otis1960LanternChimeDirection |
|
||||||
Otis1960LanternChimeLanding |
|
Otis1960LanternChimeLanding |
|
||||||
@@ -17,7 +21,11 @@ export type Otis1960SoundValues = Otis1960LanternChimeDirection |
|
|||||||
SoundEnums.Otis1960 = {
|
SoundEnums.Otis1960 = {
|
||||||
LanternChimeDirection = "rbxassetid://16990287228" :: Otis1960LanternChimeDirection,
|
LanternChimeDirection = "rbxassetid://16990287228" :: Otis1960LanternChimeDirection,
|
||||||
LanternChimeLanding = "rbxassetid://16990290265" :: Otis1960LanternChimeLanding,
|
LanternChimeLanding = "rbxassetid://16990290265" :: Otis1960LanternChimeLanding,
|
||||||
DoorClosingClick = "rbxassetid://16357740945" :: Otis1960DoorClosingClick
|
DoorClosingClick = "rbxassetid://16357740945" :: Otis1960DoorClosingClick,
|
||||||
|
RelayActivated = "" :: Otis1960RelayActivated,
|
||||||
|
RelayDeActivated = "" :: Otis1960RelayDeActivated,
|
||||||
|
BigRelayActivated = "" :: Otis1960BigRelayActivated,
|
||||||
|
BigRealyDeActivated = "" :: Otis1960BigRelayDeActivated,
|
||||||
}
|
}
|
||||||
|
|
||||||
return SoundEnums
|
return SoundEnums
|
||||||
@@ -29,10 +29,11 @@ type Impl_Static_Props = {
|
|||||||
DefaultHoldDuration: number
|
DefaultHoldDuration: number
|
||||||
}
|
}
|
||||||
|
|
||||||
type Constructor_Fun = (TagsConstructor: TagsConstructor, ModelButtons: Tags.ElevatorButtons) -> ClassConstructor
|
type Constructor_Fun = (TagsConstructor: TagsConstructor, ModelButtons: Tags.ElevatorButtons, ElevatorModel: Enums.ElevatorValues) -> ClassConstructor
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
Tags: TagsConstructor,
|
Tags: TagsConstructor,
|
||||||
ModelButtons: Tags.ElevatorButtons,
|
ModelButtons: Tags.ElevatorButtons,
|
||||||
|
ElevatorModel: Enums.ElevatorValues,
|
||||||
Buttons: Tags.ButtonsTree
|
Buttons: Tags.ButtonsTree
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,16 +45,20 @@ ButtonsModule.__index = ButtonsModule
|
|||||||
ButtonsModule.DefaultMaxActivationDistance = 3
|
ButtonsModule.DefaultMaxActivationDistance = 3
|
||||||
ButtonsModule.DefaultHoldDuration = .30
|
ButtonsModule.DefaultHoldDuration = .30
|
||||||
|
|
||||||
function ButtonsModule.constructor(TagsConstructor, ModelButtons)
|
function ButtonsModule.constructor(TagsConstructor, ModelButtons, ElevatorModel)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
Tags = TagsConstructor,
|
Tags = TagsConstructor,
|
||||||
ModelButtons = ModelButtons,
|
ModelButtons = ModelButtons,
|
||||||
|
ElevatorModel = ElevatorModel,
|
||||||
|
|
||||||
Buttons = {
|
Buttons = {
|
||||||
|
[ElevatorModel] = {
|
||||||
Landing = {},
|
Landing = {},
|
||||||
Car = {},
|
Car = {},
|
||||||
Special = {},
|
Special = {},
|
||||||
Relays = {}
|
Relays = {}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, ButtonsModule)
|
}, ButtonsModule)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -91,7 +96,7 @@ function ButtonsModule:CreatePromptButtons()
|
|||||||
Prompt.ActionText = tostring(Split[3])
|
Prompt.ActionText = tostring(Split[3])
|
||||||
Prompt.ObjectText = "Floor"
|
Prompt.ObjectText = "Floor"
|
||||||
|
|
||||||
self.Buttons.Car[`{Split[2]}_{Split[3]}`] = {
|
self.Buttons[self.ElevatorModel].Car[`{Split[2]}_{Split[3]}`] = {
|
||||||
Inst = Inst,
|
Inst = Inst,
|
||||||
Prompt = Prompt,
|
Prompt = Prompt,
|
||||||
Attachment = Attachment
|
Attachment = Attachment
|
||||||
@@ -103,7 +108,7 @@ function ButtonsModule:CreatePromptButtons()
|
|||||||
Prompt.ActionText = `Send Elevator {Name}`
|
Prompt.ActionText = `Send Elevator {Name}`
|
||||||
Prompt.ObjectText = `Floor {tostring(Split[4])}`
|
Prompt.ObjectText = `Floor {tostring(Split[4])}`
|
||||||
|
|
||||||
self.Buttons.Landing[`{Split[2]}_{Split[3]}_{Split[4]}_{Split[5]}`] = {
|
self.Buttons[self.ElevatorModel].Landing[`{Split[2]}_{Split[3]}_{Split[4]}_{Split[5]}`] = {
|
||||||
Inst = Inst,
|
Inst = Inst,
|
||||||
Prompt = Prompt,
|
Prompt = Prompt,
|
||||||
Attachment = Attachment,
|
Attachment = Attachment,
|
||||||
@@ -116,7 +121,7 @@ function ButtonsModule:CreatePromptButtons()
|
|||||||
Prompt.ActionText = Name
|
Prompt.ActionText = Name
|
||||||
Prompt.ObjectText = "Elevator"
|
Prompt.ObjectText = "Elevator"
|
||||||
|
|
||||||
self.Buttons.Special[`{Split[2]}_{Split[3]}`] = {
|
self.Buttons[self.ElevatorModel].Special[`{Split[2]}_{Split[3]}`] = {
|
||||||
Inst = Inst,
|
Inst = Inst,
|
||||||
Prompt = Prompt,
|
Prompt = Prompt,
|
||||||
Attachment = Attachment,
|
Attachment = Attachment,
|
||||||
@@ -129,7 +134,7 @@ function ButtonsModule:CreatePromptButtons()
|
|||||||
Prompt.ActionText = "Activate"
|
Prompt.ActionText = "Activate"
|
||||||
Prompt.ObjectText = "Relay"
|
Prompt.ObjectText = "Relay"
|
||||||
|
|
||||||
self.Buttons.Relays[`{Split[2]}_{Split[3]}`] = {
|
self.Buttons[self.ElevatorModel].Relays[`{Split[2]}_{Split[3]}`] = {
|
||||||
Inst = Inst,
|
Inst = Inst,
|
||||||
Prompt = Prompt,
|
Prompt = Prompt,
|
||||||
Attachment = Attachment,
|
Attachment = Attachment,
|
||||||
|
|||||||
@@ -94,11 +94,17 @@ export type InteractablesTree = {
|
|||||||
LightSwitches: LightSwitchTree
|
LightSwitches: LightSwitchTree
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ButtonDictionary = {
|
||||||
|
[string]: ButtonProperties
|
||||||
|
}
|
||||||
|
|
||||||
export type ButtonsTree = {
|
export type ButtonsTree = {
|
||||||
Car: ButtonProperties,
|
[Enums.ElevatorValues]: {
|
||||||
Landing: ButtonProperties,
|
Car: ButtonDictionary,
|
||||||
Special: ButtonProperties,
|
Landing: ButtonDictionary,
|
||||||
Relays: ButtonProperties
|
Special: ButtonDictionary,
|
||||||
|
Relays: ButtonDictionary
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ButtonProperties = {
|
export type ButtonProperties = {
|
||||||
|
|||||||
@@ -125,7 +125,8 @@ function Lights:Init()
|
|||||||
LightProperties.Lights and
|
LightProperties.Lights and
|
||||||
LightProperties.LightSources and
|
LightProperties.LightSources and
|
||||||
LightProperties.ActivatedMaterial and
|
LightProperties.ActivatedMaterial and
|
||||||
LightProperties.DeactivatedMaterial then
|
LightProperties.DeactivatedMaterial
|
||||||
|
then
|
||||||
if LightProperties.Enabled then
|
if LightProperties.Enabled then
|
||||||
EnabledState = true
|
EnabledState = true
|
||||||
LightProperties.Prompt.ActionText = "Toggle Off"
|
LightProperties.Prompt.ActionText = "Toggle Off"
|
||||||
|
|||||||
Reference in New Issue
Block a user