mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
d
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -17,7 +17,12 @@ type Constructor_Return_Props = {
|
|||||||
__FloorQueue: FloorQueue,
|
__FloorQueue: FloorQueue,
|
||||||
|
|
||||||
Events: {
|
Events: {
|
||||||
Sorted: BindableEvent
|
Sorted: RBXScriptSignal,
|
||||||
|
Added: RBXScriptSignal<number>,
|
||||||
|
__eventInstances__: {
|
||||||
|
Sorted: BindableEvent,
|
||||||
|
Added: BindableEvent
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,12 +40,19 @@ local RelayAlgorithm = {} :: Impl_Constructor
|
|||||||
RelayAlgorithm.__index = RelayAlgorithm
|
RelayAlgorithm.__index = RelayAlgorithm
|
||||||
|
|
||||||
function RelayAlgorithm.constructor(ElevatorBoxModel)
|
function RelayAlgorithm.constructor(ElevatorBoxModel)
|
||||||
|
local Sorted = Instance.new("BindableEvent") :: BindableEvent
|
||||||
|
local Added = Instance.new("BindableEvent") :: BindableEvent
|
||||||
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
ElevatorBoxModel = ElevatorBoxModel,
|
ElevatorBoxModel = ElevatorBoxModel,
|
||||||
__FloorQueue = {},
|
__FloorQueue = {},
|
||||||
|
|
||||||
Events = {
|
Events = {
|
||||||
Sorted = Instance.new("BindableEvent") :: BindableEvent
|
Sorted = Sorted.Event,
|
||||||
|
Added = Added.Event,
|
||||||
|
__eventInstances__ = {
|
||||||
|
Sorted = Sorted,
|
||||||
|
Added = Added
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}, RelayAlgorithm)
|
}, RelayAlgorithm)
|
||||||
end
|
end
|
||||||
@@ -55,11 +67,12 @@ function RelayAlgorithm:Sort(ElevatorGoingUp)
|
|||||||
end
|
end
|
||||||
return a>b
|
return a>b
|
||||||
end)
|
end)
|
||||||
self.Events.Sorted:Fire()
|
self.Events.__eventInstances__.Sorted:Fire()
|
||||||
end
|
end
|
||||||
|
|
||||||
function RelayAlgorithm:AddFloor(ElevatorGoingUp, GoingUpAttribute, RequestedLevel)
|
function RelayAlgorithm:AddFloor(ElevatorGoingUp, GoingUpAttribute, RequestedLevel)
|
||||||
table.insert(self.__FloorQueue, ElevatorGoingUp == GoingUpAttribute.Value and 1 or #self.__FloorQueue+1, RequestedLevel)
|
table.insert(self.__FloorQueue, ElevatorGoingUp == GoingUpAttribute.Value and 1 or #self.__FloorQueue+1, RequestedLevel)
|
||||||
|
self.Events.__eventInstances__.Added:Fire(RequestedLevel)
|
||||||
self:Sort(ElevatorGoingUp)
|
self:Sort(ElevatorGoingUp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,17 +4,12 @@
|
|||||||
|
|
||||||
local Elevators = script.Parent
|
local Elevators = script.Parent
|
||||||
local MainDir = Elevators.Parent
|
local MainDir = Elevators.Parent
|
||||||
local EnumsDir = MainDir:WaitForChild("Enums")
|
|
||||||
local LoadDir = MainDir:WaitForChild("Load")
|
local LoadDir = MainDir:WaitForChild("Load")
|
||||||
|
|
||||||
local StorageService = game:GetService("ReplicatedStorage")
|
local RunService = game:GetService("RunService")
|
||||||
local RunService = game:GetService("RunService")
|
|
||||||
|
|
||||||
local Enums = require(StorageService:WaitForChild("Enums"))
|
|
||||||
local SoundEnums = require(EnumsDir:WaitForChild("Sounds"))
|
|
||||||
|
|
||||||
local Tags = require(LoadDir:WaitForChild("Tags"))
|
|
||||||
|
|
||||||
|
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator"))
|
||||||
|
local Tags = require(LoadDir:WaitForChild("Tags"))
|
||||||
local RelayAlgorithm = require(script:WaitForChild("RelayAlgorithm"))
|
local RelayAlgorithm = require(script:WaitForChild("RelayAlgorithm"))
|
||||||
|
|
||||||
type Tags = Tags.ExportedTags
|
type Tags = Tags.ExportedTags
|
||||||
@@ -29,33 +24,8 @@ type Impl_Constructor = {
|
|||||||
__TravelToFloor: (self: ClassConstructor, LevelInt: number, LevelVec3: number, ElevatorGoingUp: boolean) -> (),
|
__TravelToFloor: (self: ClassConstructor, LevelInt: number, LevelVec3: number, ElevatorGoingUp: boolean) -> (),
|
||||||
}
|
}
|
||||||
|
|
||||||
type ElevatorConfigurationTable = {
|
|
||||||
Name: Enums.ElevatorValues,
|
|
||||||
Responsiveness: number,
|
|
||||||
MaxVelocity: number,
|
|
||||||
FloorLevelingDistance: number,
|
|
||||||
FloorLeveling3PhaseDistance: number,
|
|
||||||
ParkedDistance: number,
|
|
||||||
LevelingVelocity: number,
|
|
||||||
Phase3LevelingVelocity: number,
|
|
||||||
Sounds: {
|
|
||||||
LanternChimeDirection: SoundEnums.ElevatorSoundValues,
|
|
||||||
LanternChimeLanding: SoundEnums.ElevatorSoundValues,
|
|
||||||
},
|
|
||||||
Colors: {
|
|
||||||
ButtonActivated: Color3,
|
|
||||||
ButtonDeactivated: Color3,
|
|
||||||
LanternDisplayOn: Color3,
|
|
||||||
LanternDisplayOff: Color3,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type FloorLevelingPositions = {number}
|
type FloorLevelingPositions = {number}
|
||||||
type Constructor_Fun = (
|
type Constructor_Fun = (ElevatorBoxModel: UnionOperation, ElevatorConfigurationTable: ElevatorTypes.ElevatorConfigurationTable, FloorLevelingPositions: FloorLevelingPositions) -> ClassConstructor
|
||||||
ElevatorBoxModel: UnionOperation,
|
|
||||||
ElevatorConfigurationTable: ElevatorConfigurationTable,
|
|
||||||
FloorLevelingPositions: FloorLevelingPositions
|
|
||||||
) -> ClassConstructor
|
|
||||||
|
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
RelayAlgorithm: RelayAlgorithm.RelayAlgorithmConstructor,
|
RelayAlgorithm: RelayAlgorithm.RelayAlgorithmConstructor,
|
||||||
@@ -64,7 +34,7 @@ type Constructor_Return_Props = {
|
|||||||
Elevator: {
|
Elevator: {
|
||||||
BoxModel: UnionOperation,
|
BoxModel: UnionOperation,
|
||||||
AlignPosition: AlignPosition,
|
AlignPosition: AlignPosition,
|
||||||
Configuration: ElevatorConfigurationTable
|
Configuration: ElevatorTypes.ElevatorConfigurationTable
|
||||||
},
|
},
|
||||||
Attributes: {
|
Attributes: {
|
||||||
PreviousFloor: IntValue,
|
PreviousFloor: IntValue,
|
||||||
@@ -75,11 +45,18 @@ type Constructor_Return_Props = {
|
|||||||
Stopped: BoolValue
|
Stopped: BoolValue
|
||||||
},
|
},
|
||||||
Events: {
|
Events: {
|
||||||
CabProgression: BindableEvent,
|
CabProgression: RBXScriptSignal<number, number, number>,
|
||||||
CabTraveling: BindableEvent,
|
CabTraveling: RBXScriptSignal<number, Vector3>,
|
||||||
Parked: BindableEvent,
|
Parked: RBXScriptSignal,
|
||||||
Leveling: BindableEvent,
|
Leveling: RBXScriptSignal,
|
||||||
Leveling3Phase: BindableEvent,
|
Leveling3Phase: RBXScriptSignal,
|
||||||
|
__eventInstances__: {
|
||||||
|
CabProgression: BindableEvent,
|
||||||
|
CabTraveling: BindableEvent,
|
||||||
|
Parked: BindableEvent,
|
||||||
|
Leveling: BindableEvent,
|
||||||
|
Leveling3Phase: BindableEvent,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
__Connections: {
|
__Connections: {
|
||||||
@@ -123,19 +100,19 @@ local function Mover(ElevatorBoxModel: UnionOperation, Responsiveness: number, M
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, FloorLevelingPositions)
|
function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, FloorLevelingPositions)
|
||||||
|
assert(#FloorLevelingPositions>1, `[{ElevatorConfigurationTable.Name}] requires more floors to operate. Floors={FloorLevelingPositions}, #Floors={#FloorLevelingPositions}.`)
|
||||||
|
|
||||||
local _BoxAttachment,
|
local _BoxAttachment,
|
||||||
BoxAlignPosition,
|
BoxAlignPosition,
|
||||||
_BoxAlignOrientation = Mover(ElevatorBoxModel, ElevatorConfigurationTable.Responsiveness, ElevatorConfigurationTable.MaxVelocity)
|
_BoxAlignOrientation = Mover(ElevatorBoxModel, ElevatorConfigurationTable.Responsiveness, ElevatorConfigurationTable.MaxVelocity)
|
||||||
|
|
||||||
local RelayAlgorithmConstructor = RelayAlgorithm.constructor(BoxAlignPosition)
|
local RelayAlgorithmConstructor = RelayAlgorithm.constructor(BoxAlignPosition)
|
||||||
|
|
||||||
local Events = {
|
local CabProgression = Instance.new("BindableEvent") :: BindableEvent
|
||||||
CabProgression = Instance.new("BindableEvent") :: BindableEvent,
|
local CabTraveling = Instance.new("BindableEvent") :: BindableEvent
|
||||||
CabTraveling = Instance.new("BindableEvent") :: BindableEvent,
|
local Parked = Instance.new("BindableEvent") :: BindableEvent
|
||||||
Parked = Instance.new("BindableEvent") :: BindableEvent,
|
local Leveling = Instance.new("BindableEvent") :: BindableEvent
|
||||||
Leveling = Instance.new("BindableEvent") :: BindableEvent,
|
local Leveling3Phase = Instance.new("BindableEvent") :: BindableEvent
|
||||||
Leveling3Phase = Instance.new("BindableEvent") :: BindableEvent,
|
|
||||||
}
|
|
||||||
|
|
||||||
local Attributes = {
|
local Attributes = {
|
||||||
PreviousFloor = Instance.new("IntValue") :: IntValue,
|
PreviousFloor = Instance.new("IntValue") :: IntValue,
|
||||||
@@ -145,10 +122,11 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo
|
|||||||
GoingUp = Instance.new("BoolValue") :: BoolValue,
|
GoingUp = Instance.new("BoolValue") :: BoolValue,
|
||||||
Stopped = Instance.new("BoolValue") :: BoolValue
|
Stopped = Instance.new("BoolValue") :: BoolValue
|
||||||
}
|
}
|
||||||
Attributes.CurrentFloor.Value = 1
|
Attributes.CurrentFloor.Value = 1
|
||||||
Attributes.NextFloor.Value = Attributes.CurrentFloor.Value+1
|
Attributes.PreviousFloor.Value = Attributes.CurrentFloor.Value
|
||||||
Attributes.GoingUp.Value = false
|
Attributes.NextFloor.Value = Attributes.CurrentFloor.Value+1
|
||||||
Attributes.Goal.Value = 1
|
Attributes.GoingUp.Value = false
|
||||||
|
Attributes.Goal.Value = 1
|
||||||
|
|
||||||
print(`🛗 [{ElevatorConfigurationTable.Name}]: Initialized and ready`)
|
print(`🛗 [{ElevatorConfigurationTable.Name}]: Initialized and ready`)
|
||||||
|
|
||||||
@@ -160,8 +138,21 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo
|
|||||||
AlignPosition = BoxAlignPosition,
|
AlignPosition = BoxAlignPosition,
|
||||||
Configuration = ElevatorConfigurationTable,
|
Configuration = ElevatorConfigurationTable,
|
||||||
},
|
},
|
||||||
|
Events = {
|
||||||
|
CabProgression = CabProgression.Event,
|
||||||
|
CabTraveling = CabTraveling.Event,
|
||||||
|
Parked = Parked.Event,
|
||||||
|
Leveling = Leveling.Event,
|
||||||
|
Leveling3Phase = Leveling3Phase.Event,
|
||||||
|
__eventInstances__ = {
|
||||||
|
CabProgression = CabProgression,
|
||||||
|
CabTraveling = CabTraveling,
|
||||||
|
Parked = Parked,
|
||||||
|
Leveling = Leveling,
|
||||||
|
Leveling3Phase = Leveling3Phase,
|
||||||
|
}
|
||||||
|
},
|
||||||
Attributes = Attributes,
|
Attributes = Attributes,
|
||||||
Events = Events,
|
|
||||||
__Connections = {}
|
__Connections = {}
|
||||||
}, Elevator)
|
}, Elevator)
|
||||||
end
|
end
|
||||||
@@ -173,6 +164,7 @@ local function CheckFloorQueue(self: ClassConstructor)
|
|||||||
table.remove(self.RelayAlgorithm.__FloorQueue, 1)
|
table.remove(self.RelayAlgorithm.__FloorQueue, 1)
|
||||||
|
|
||||||
local NextFloorInQueue = self.RelayAlgorithm.__FloorQueue[1]
|
local NextFloorInQueue = self.RelayAlgorithm.__FloorQueue[1]
|
||||||
|
print(NextFloorInQueue)
|
||||||
if NextFloorInQueue then
|
if NextFloorInQueue then
|
||||||
local ElevatorGoingUp = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, NextFloorInQueue)
|
local ElevatorGoingUp = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, NextFloorInQueue)
|
||||||
local LevelVec3 = self.FloorLevelingPositions[NextFloorInQueue]
|
local LevelVec3 = self.FloorLevelingPositions[NextFloorInQueue]
|
||||||
@@ -192,20 +184,20 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LevelVec3
|
|||||||
self.Attributes.CurrentFloor.Value+=1
|
self.Attributes.CurrentFloor.Value+=1
|
||||||
self.Attributes.NextFloor.Value = math.clamp(1, self.Attributes.CurrentFloor.Value+1, #self.FloorLevelingPositions)
|
self.Attributes.NextFloor.Value = math.clamp(1, self.Attributes.CurrentFloor.Value+1, #self.FloorLevelingPositions)
|
||||||
|
|
||||||
self.Events.CabProgression:Fire(self.Attributes.PreviousFloor.Value, self.Attributes.CurrentFloor.Value, self.Attributes.NextFloor.Value)
|
self.Events.__eventInstances__.CabProgression:Fire(self.Attributes.PreviousFloor.Value, self.Attributes.CurrentFloor.Value, self.Attributes.NextFloor.Value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Elevator is riding upwards towards the destination
|
--Elevator is riding upwards towards the destination
|
||||||
if ElevatorPosition.Y>=LevelVec3-self.Elevator.Configuration.FloorLevelingDistance then
|
if ElevatorPosition.Y>=LevelVec3-self.Elevator.Configuration.FloorLevelingDistance then
|
||||||
self.Events.Leveling:Fire()
|
self.Events.__eventInstances__.Leveling:Fire()
|
||||||
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.LevelingVelocity
|
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.LevelingVelocity
|
||||||
|
|
||||||
if ElevatorPosition.Y>=LevelVec3-self.Elevator.Configuration.FloorLeveling3PhaseDistance then
|
if ElevatorPosition.Y>=LevelVec3-self.Elevator.Configuration.FloorLeveling3PhaseDistance then
|
||||||
self.Events.Leveling3Phase:Fire()
|
self.Events.__eventInstances__.Leveling3Phase:Fire()
|
||||||
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity
|
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity
|
||||||
|
|
||||||
if ElevatorPosition.Y>=LevelVec3-self.Elevator.Configuration.ParkedDistance then
|
if ElevatorPosition.Y>=LevelVec3-self.Elevator.Configuration.ParkedDistance then
|
||||||
self.Events.Parked:Fire()
|
self.Events.__eventInstances__.Parked:Fire()
|
||||||
CheckFloorQueue(self);
|
CheckFloorQueue(self);
|
||||||
|
|
||||||
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
||||||
@@ -218,20 +210,20 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LevelVec3
|
|||||||
self.Attributes.CurrentFloor.Value-=1
|
self.Attributes.CurrentFloor.Value-=1
|
||||||
self.Attributes.NextFloor.Value = math.clamp(1, self.Attributes.CurrentFloor.Value-1, #self.FloorLevelingPositions)
|
self.Attributes.NextFloor.Value = math.clamp(1, self.Attributes.CurrentFloor.Value-1, #self.FloorLevelingPositions)
|
||||||
|
|
||||||
self.Events.CabProgression:Fire(self.Attributes.PreviousFloor.Value, self.Attributes.CurrentFloor.Value, self.Attributes.NextFloor.Value)
|
self.Events.__eventInstances__.CabProgression:Fire(self.Attributes.PreviousFloor.Value, self.Attributes.CurrentFloor.Value, self.Attributes.NextFloor.Value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Elevator is riding upwards towards the destination
|
--Elevator is riding upwards towards the destination
|
||||||
if ElevatorPosition.Y<=LevelVec3+self.Elevator.Configuration.FloorLevelingDistance then
|
if ElevatorPosition.Y<=LevelVec3+self.Elevator.Configuration.FloorLevelingDistance then
|
||||||
self.Events.Leveling:Fire()
|
self.Events.__eventInstances__.Leveling:Fire()
|
||||||
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.LevelingVelocity
|
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.LevelingVelocity
|
||||||
|
|
||||||
if ElevatorPosition.Y<=LevelVec3+self.Elevator.Configuration.FloorLeveling3PhaseDistance then
|
if ElevatorPosition.Y<=LevelVec3+self.Elevator.Configuration.FloorLeveling3PhaseDistance then
|
||||||
self.Events.Leveling3Phase:Fire()
|
self.Events.__eventInstances__.Leveling3Phase:Fire()
|
||||||
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity
|
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity
|
||||||
|
|
||||||
if ElevatorPosition.Y<=LevelVec3+self.Elevator.Configuration.ParkedDistance then
|
if ElevatorPosition.Y<=LevelVec3+self.Elevator.Configuration.ParkedDistance then
|
||||||
self.Events.Parked:Fire()
|
self.Events.__eventInstances__.Parked:Fire()
|
||||||
CheckFloorQueue(self);
|
CheckFloorQueue(self);
|
||||||
|
|
||||||
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
||||||
@@ -240,7 +232,7 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LevelVec3
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.Events.CabTraveling:Fire(deltaTime, ElevatorPosition)
|
self.Events.__eventInstances__.CabTraveling:Fire(deltaTime, ElevatorPosition)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Elevator:__TravelToFloor(LevelInt, LevelVec3, ElevatorGoingUp)
|
function Elevator:__TravelToFloor(LevelInt, LevelVec3, ElevatorGoingUp)
|
||||||
@@ -265,17 +257,21 @@ function Elevator:RequestLevel(RequestedLevel)
|
|||||||
local LevelVec3 = self.FloorLevelingPositions[RequestedLevel]
|
local LevelVec3 = self.FloorLevelingPositions[RequestedLevel]
|
||||||
|
|
||||||
if LevelVec3 then
|
if LevelVec3 then
|
||||||
local ElevatorGoingUp = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, RequestedLevel)
|
if RequestedLevel ~= self.Attributes.CurrentFloor.Value then
|
||||||
self.RelayAlgorithm:AddFloor(ElevatorGoingUp, self.Attributes.GoingUp, RequestedLevel)
|
local ElevatorGoingUp = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, RequestedLevel)
|
||||||
|
self.RelayAlgorithm:AddFloor(ElevatorGoingUp, self.Attributes.GoingUp, RequestedLevel)
|
||||||
|
|
||||||
if #self.RelayAlgorithm.__FloorQueue == 1 then
|
if #self.RelayAlgorithm.__FloorQueue == 1 then
|
||||||
self:__TravelToFloor(RequestedLevel, LevelVec3, ElevatorGoingUp)
|
self:__TravelToFloor(RequestedLevel, LevelVec3, ElevatorGoingUp)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
warn(`[{self.Elevator.Configuration.Name}]: The elevator is already at the requested floor. RequestLevel={RequestedLevel}, CurrentLevel={self.Attributes.CurrentFloor.Value}`)
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
warn(`Requested floor: "{RequestedLevel}" does not exist for this elevator`)
|
warn(`[{self.Elevator.Configuration.Name}]: Requested floor: "{RequestedLevel}" does not exist for this elevator`)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,11 @@
|
|||||||
local MainDir = script.Parent.Parent.Parent
|
local MainDir = script.Parent.Parent.Parent
|
||||||
local StorageService = game:GetService("ReplicatedStorage")
|
local StorageService = game:GetService("ReplicatedStorage")
|
||||||
|
|
||||||
local Enums = require(StorageService:WaitForChild("Enums"))
|
local Enums = require(StorageService:WaitForChild("Enums"))
|
||||||
local SoundEnums = require(MainDir:WaitForChild("Enums"):WaitForChild("Sounds"))
|
local SoundEnums = require(MainDir:WaitForChild("Enums"):WaitForChild("Sounds"))
|
||||||
|
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator"))
|
||||||
|
|
||||||
local ElevatorConfiguration = {}
|
local ElevatorConfiguration = {} :: ElevatorTypes.ElevatorConfigurationTable
|
||||||
ElevatorConfiguration.Name = Enums.Elevator.Otis1960
|
ElevatorConfiguration.Name = Enums.Elevator.Otis1960
|
||||||
ElevatorConfiguration.FloorLevelingDistance = 4
|
ElevatorConfiguration.FloorLevelingDistance = 4
|
||||||
ElevatorConfiguration.FloorLeveling3PhaseDistance = 1.5
|
ElevatorConfiguration.FloorLeveling3PhaseDistance = 1.5
|
||||||
|
|||||||
@@ -4,17 +4,51 @@
|
|||||||
|
|
||||||
local ParentDir = script.Parent
|
local ParentDir = script.Parent
|
||||||
local MainDir = ParentDir.Parent
|
local MainDir = ParentDir.Parent
|
||||||
local StorageService = game:GetService("ReplicatedStorage")
|
|
||||||
|
|
||||||
local InitElevator = require(ParentDir:WaitForChild("InitElevator"))
|
local InitElevator = require(ParentDir:WaitForChild("InitElevator"))
|
||||||
|
local TagsModule = require(MainDir:WaitForChild("Load"):WaitForChild("Tags"))
|
||||||
local TagsModule = require(MainDir:WaitForChild("Load"):WaitForChild("Tags"))
|
|
||||||
local SoundEnums = require(MainDir:WaitForChild("Enums"):WaitForChild("Sounds"))
|
|
||||||
local Enums = require(StorageService:WaitForChild("Enums"))
|
|
||||||
|
|
||||||
local ElevatorConfigurationTable = require(script:WaitForChild("Config"))
|
local ElevatorConfigurationTable = require(script:WaitForChild("Config"))
|
||||||
local FloorLevelingPositions = require(script:WaitForChild("Leveling"))
|
local FloorLevelingPositions = require(script:WaitForChild("Leveling"))
|
||||||
|
|
||||||
return function(ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
|
-- self.ElevatorBox_1960 = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
|
||||||
|
-- self.ElevatorDoor1 = TagsConstructor:Request("ElevatorDoor_1960_1") :: BasePart
|
||||||
|
-- self.ElevatorDoor2 = TagsConstructor:Request("ElevatorDoor_1960_2") :: BasePart
|
||||||
|
-- self.ElevatorDoorSensor = TagsConstructor:Request("ElevatorDoor_Sensor_1960") :: Folder
|
||||||
|
-- self.Ropes = TagsConstructor:Request("1960_ElevatorPulleyRope") :: {Instance}
|
||||||
|
-- self.HallDisplays = TagsConstructor:Request("Otis1960_LandingFloorDisplay") :: {Instance}
|
||||||
|
|
||||||
|
-- self.MachineRoom.Pulley = TagsConstructor:Request("Otis1960_Pulley") :: UnionOperation
|
||||||
|
-- self.MachineRoom.Pulley2 = TagsConstructor:Request("Otis1960_Pulley2") :: UnionOperation
|
||||||
|
-- self.MachineRoom.Governor = TagsConstructor:Request("Otis1960_Governor") :: UnionOperation
|
||||||
|
-- self.MachineRoom.GovernorFlyballs = TagsConstructor:Request("Otis1960_GovernorFlyballs") :: Part
|
||||||
|
-- self.MachineRoom.PiePlatePulley = TagsConstructor:Request("Otis1960_PieplatePulley") :: UnionOperation
|
||||||
|
-- self.MachineRoom.PiePlatePlates = TagsConstructor:Request("Otis1960_PiePlatePlates") :: UnionOperation
|
||||||
|
-- self.MachineRoom.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation
|
||||||
|
|
||||||
|
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
|
||||||
|
local ElevatorBoxModel = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
|
||||||
|
|
||||||
local Elevator = InitElevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, FloorLevelingPositions)
|
local Elevator = InitElevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, FloorLevelingPositions)
|
||||||
|
|
||||||
|
Elevator.Events.CabTraveling:Connect(function(deltaTime: number, ElevatorPosition: Vector3)
|
||||||
|
|
||||||
|
end)
|
||||||
|
Elevator.Events.CabProgression:Connect(function(PreviousFloor: number, CurrentFloor: number, NextFloor: number)
|
||||||
|
print(CurrentFloor)
|
||||||
|
end)
|
||||||
|
Elevator.Events.Leveling:Connect(function()
|
||||||
|
|
||||||
|
end)
|
||||||
|
Elevator.Events.Leveling3Phase:Connect(function()
|
||||||
|
|
||||||
|
end)
|
||||||
|
Elevator.Events.Parked:Connect(function()
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
task.wait(1)
|
||||||
|
Elevator:RequestLevel(3)
|
||||||
|
Elevator:RequestLevel(5)
|
||||||
|
Elevator:RequestLevel(2)
|
||||||
end
|
end
|
||||||
|
|||||||
30
src/server/main/Types/Elevator.luau
Normal file
30
src/server/main/Types/Elevator.luau
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
local MainDir = script.Parent.Parent
|
||||||
|
local EnumsDir = MainDir:WaitForChild("Enums")
|
||||||
|
|
||||||
|
local StorageService = game:GetService("ReplicatedStorage")
|
||||||
|
|
||||||
|
local Enums = require(StorageService:WaitForChild("Enums"))
|
||||||
|
local SoundEnums = require(EnumsDir:WaitForChild("Sounds"))
|
||||||
|
|
||||||
|
export type ElevatorConfigurationTable = {
|
||||||
|
Name: Enums.ElevatorValues,
|
||||||
|
Responsiveness: number,
|
||||||
|
MaxVelocity: number,
|
||||||
|
FloorLevelingDistance: number,
|
||||||
|
FloorLeveling3PhaseDistance: number,
|
||||||
|
ParkedDistance: number,
|
||||||
|
LevelingVelocity: number,
|
||||||
|
Phase3LevelingVelocity: number,
|
||||||
|
Sounds: {
|
||||||
|
LanternChimeDirection: SoundEnums.ElevatorSoundValues,
|
||||||
|
LanternChimeLanding: SoundEnums.ElevatorSoundValues,
|
||||||
|
},
|
||||||
|
Colors: {
|
||||||
|
ButtonActivated: Color3,
|
||||||
|
ButtonDeactivated: Color3,
|
||||||
|
LanternDisplayOn: Color3,
|
||||||
|
LanternDisplayOff: Color3,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
@@ -50,4 +50,4 @@ print("[DEBUG] Lanterns=", Lanterns)
|
|||||||
local LandingDoors = TagsConstructor:__ElevatorDoors()
|
local LandingDoors = TagsConstructor:__ElevatorDoors()
|
||||||
print("[DEBUG] Elevator Landing Doors=", LandingDoors)
|
print("[DEBUG] Elevator Landing Doors=", LandingDoors)
|
||||||
|
|
||||||
Otis1960(Buttons[Enums.Elevator.Otis1960], Lanterns[Enums.Elevator.Otis1960], LandingDoors[Enums.Elevator.Otis1960])
|
Otis1960(TagsConstructor, Buttons[Enums.Elevator.Otis1960], Lanterns[Enums.Elevator.Otis1960], LandingDoors[Enums.Elevator.Otis1960])
|
||||||
|
|||||||
Reference in New Issue
Block a user