mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
r
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -2,28 +2,35 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
--Slap this here
|
||||
--The Otis relay based call logic
|
||||
--https://youtu.be/BCN9mQOT3RQ
|
||||
|
||||
local StorageService = game:GetService("ReplicatedStorage")
|
||||
local Enums = require(StorageService:WaitForChild("Enums"))
|
||||
|
||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||
type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
--Class functions
|
||||
Sort: (self: ClassConstructor, ElevatorGoingUp: boolean) -> (),
|
||||
AddFloor: (self: ClassConstructor, ElevatorGoingUp: boolean, GoingUpAttribute: BoolValue, RequestedLevel: number) -> (),
|
||||
Sort: (self: ClassConstructor, Direction: Enums.ElevatorCallDirectionValues) -> (),
|
||||
AddFloor: (self: ClassConstructor, Direction: Enums.ElevatorCallDirectionValues, RequestedLevel: number) -> (),
|
||||
}
|
||||
|
||||
type Constructor_Fun = (ElevatorBoxModel: AlignPosition) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
ElevatorBoxModel: AlignPosition,
|
||||
__FloorQueue: FloorQueue,
|
||||
|
||||
Events: {
|
||||
Sorted: RBXScriptSignal,
|
||||
Added: RBXScriptSignal<number>,
|
||||
export type RelayAlgorithmEvents = {
|
||||
Sorted: RBXScriptSignal<Enums.ElevatorCallDirectionValues, FloorDirectionQueue>,
|
||||
Added: RBXScriptSignal<Enums.ElevatorCallDirectionValues, number>,
|
||||
__eventInstances__: {
|
||||
Sorted: BindableEvent,
|
||||
Added: BindableEvent
|
||||
}
|
||||
},
|
||||
}
|
||||
type Constructor_Fun = (ElevatorBoxModel: AlignPosition) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
ElevatorBoxModel: AlignPosition,
|
||||
FloorQueue: FloorQueue,
|
||||
Events: RelayAlgorithmEvents,
|
||||
}
|
||||
|
||||
type DoorAttributes = {
|
||||
@@ -32,7 +39,11 @@ type DoorAttributes = {
|
||||
}
|
||||
}
|
||||
|
||||
export type FloorQueue = {number?}
|
||||
export type FloorDirectionQueue = {number?}
|
||||
export type FloorQueue = {
|
||||
Up: FloorDirectionQueue,
|
||||
Down: FloorDirectionQueue
|
||||
}
|
||||
|
||||
export type RelayAlgorithmConstructor = ClassConstructor
|
||||
|
||||
@@ -45,7 +56,10 @@ function RelayAlgorithm.constructor(ElevatorBoxModel)
|
||||
|
||||
return setmetatable({
|
||||
ElevatorBoxModel = ElevatorBoxModel,
|
||||
__FloorQueue = {},
|
||||
FloorQueue = {
|
||||
Up = {},
|
||||
Down = {},
|
||||
},
|
||||
Events = {
|
||||
Sorted = Sorted.Event,
|
||||
Added = Added.Event,
|
||||
@@ -57,23 +71,26 @@ function RelayAlgorithm.constructor(ElevatorBoxModel)
|
||||
}, RelayAlgorithm)
|
||||
end
|
||||
|
||||
--The Otis relay based call logic
|
||||
--https://youtu.be/BCN9mQOT3RQ
|
||||
|
||||
function RelayAlgorithm:Sort(ElevatorGoingUp)
|
||||
table.sort(self.__FloorQueue, function(a, b): boolean
|
||||
if ElevatorGoingUp then
|
||||
return a<b
|
||||
end
|
||||
return a>b
|
||||
function RelayAlgorithm:Sort(Direction)
|
||||
if Direction == Enums.ElevatorCallDirection.Up then
|
||||
table.sort(self.FloorQueue.Up, function(FirstFloorIndex, LastFloorIndex): boolean
|
||||
return FirstFloorIndex<LastFloorIndex
|
||||
end)
|
||||
self.Events.__eventInstances__.Sorted:Fire()
|
||||
self.Events.__eventInstances__.Sorted:Fire(Enums.ElevatorCallDirection.Up, self.FloorQueue.Up)
|
||||
elseif Direction == Enums.ElevatorCallDirection.Down then
|
||||
table.sort(self.FloorQueue.Down, function(FirstFloorIndex, LastFloorIndex): boolean
|
||||
return FirstFloorIndex>LastFloorIndex
|
||||
end)
|
||||
self.Events.__eventInstances__.Sorted:Fire(Enums.ElevatorCallDirection.Down, self.FloorQueue.Down)
|
||||
else
|
||||
warn(`[{script.Name}.lua]: :Sort method failed. Called an unknown enum direction, direction={Direction}`, debug.traceback())
|
||||
end
|
||||
end
|
||||
|
||||
function RelayAlgorithm:AddFloor(ElevatorGoingUp, GoingUpAttribute, RequestedLevel)
|
||||
table.insert(self.__FloorQueue, ElevatorGoingUp == GoingUpAttribute.Value and 1 or #self.__FloorQueue+1, RequestedLevel)
|
||||
self.Events.__eventInstances__.Added:Fire(RequestedLevel)
|
||||
self:Sort(ElevatorGoingUp)
|
||||
function RelayAlgorithm:AddFloor(Direction, RequestedLevel)
|
||||
table.insert(Direction == Enums.ElevatorCallDirection.Up and self.FloorQueue.Up or self.FloorQueue.Down, RequestedLevel)
|
||||
self.Events.__eventInstances__.Added:Fire(Direction, RequestedLevel)
|
||||
self:Sort(Direction :: Enums.ElevatorCallDirectionValues)
|
||||
end
|
||||
|
||||
return RelayAlgorithm
|
||||
|
||||
@@ -7,7 +7,10 @@ local MainDir = Elevators.Parent
|
||||
local LoadDir = MainDir:WaitForChild("Load")
|
||||
|
||||
local RunService = game:GetService("RunService")
|
||||
local StorageService = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Enums = require(StorageService:WaitForChild("Enums"))
|
||||
local Out = require(StorageService:WaitForChild("Output"))
|
||||
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator"))
|
||||
local Tags = require(LoadDir:WaitForChild("Tags"))
|
||||
local RelayAlgorithm = require(script:WaitForChild("RelayAlgorithm"))
|
||||
@@ -20,8 +23,9 @@ type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
--Class functions
|
||||
RequestLevel: (self: ClassConstructor, RequestedLevel: number) -> boolean,
|
||||
__TravelToFloor: (self: ClassConstructor, LevelInt: number, LevelVec3: number, ElevatorGoingUp: boolean) -> (),
|
||||
GetLevel: (self: ClassConstructor, Level: number, Direction: Enums.ElevatorCallDirectionValues) -> Vector3?,
|
||||
RequestLevel: (self: ClassConstructor, RequestedLevel: number, Direction: Enums.ElevatorCallDirectionValues) -> boolean,
|
||||
__TravelToFloor: (self: ClassConstructor, LevelInt: number, VEC3_Y_WRAP: Vector3, Direction: Enums.ElevatorCallDirectionValues) -> (),
|
||||
}
|
||||
|
||||
type FloorLevelingPositions = {number}
|
||||
@@ -32,6 +36,7 @@ type Constructor_Return_Props = {
|
||||
FloorLevelingPositions: FloorLevelingPositions,
|
||||
|
||||
Elevator: {
|
||||
TravelingDirection: Enums.ElevatorCallDirectionValues,
|
||||
BoxModel: UnionOperation,
|
||||
AlignPosition: AlignPosition,
|
||||
Configuration: ElevatorTypes.ElevatorConfigurationTable
|
||||
@@ -41,7 +46,7 @@ type Constructor_Return_Props = {
|
||||
CurrentFloor: IntValue,
|
||||
NextFloor: IntValue,
|
||||
Goal: IntValue,
|
||||
GoingUp: BoolValue,
|
||||
TravelingUpwards: BoolValue,
|
||||
Stopped: BoolValue
|
||||
},
|
||||
Events: {
|
||||
@@ -100,7 +105,7 @@ local function Mover(ElevatorBoxModel: UnionOperation, Responsiveness: number, M
|
||||
end
|
||||
|
||||
function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, FloorLevelingPositions)
|
||||
assert(#FloorLevelingPositions>1, `[{ElevatorConfigurationTable.Name}] requires more floors to operate. Floors={FloorLevelingPositions}, #Floors={#FloorLevelingPositions}.`)
|
||||
assert(#FloorLevelingPositions>1, `"{ElevatorConfigurationTable.Name}" requires more floors to operate. Floors={FloorLevelingPositions}, #Floors={#FloorLevelingPositions}.`)
|
||||
|
||||
local _BoxAttachment,
|
||||
BoxAlignPosition,
|
||||
@@ -119,21 +124,20 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo
|
||||
CurrentFloor = Instance.new("IntValue") :: IntValue,
|
||||
NextFloor = Instance.new("IntValue") :: IntValue,
|
||||
Goal = Instance.new("IntValue") :: IntValue,
|
||||
GoingUp = Instance.new("BoolValue") :: BoolValue,
|
||||
TravelingUpwards = Instance.new("BoolValue") :: BoolValue,
|
||||
Stopped = Instance.new("BoolValue") :: BoolValue
|
||||
}
|
||||
Attributes.CurrentFloor.Value = 1
|
||||
Attributes.PreviousFloor.Value = Attributes.CurrentFloor.Value
|
||||
Attributes.NextFloor.Value = Attributes.CurrentFloor.Value+1
|
||||
Attributes.GoingUp.Value = false
|
||||
Attributes.TravelingUpwards.Value = true
|
||||
Attributes.Goal.Value = 1
|
||||
|
||||
print(`🛗 [{ElevatorConfigurationTable.Name}]: Initialized and ready`)
|
||||
|
||||
return setmetatable({
|
||||
local ElevatorClass = setmetatable({
|
||||
RelayAlgorithm = RelayAlgorithmConstructor,
|
||||
FloorLevelingPositions = FloorLevelingPositions,
|
||||
Elevator = {
|
||||
TravelingDirection = Enums.ElevatorCallDirection.Up,
|
||||
BoxModel = ElevatorBoxModel,
|
||||
AlignPosition = BoxAlignPosition,
|
||||
Configuration = ElevatorConfigurationTable,
|
||||
@@ -155,29 +159,54 @@ function Elevator.constructor(ElevatorBoxModel, ElevatorConfigurationTable, Floo
|
||||
Attributes = Attributes,
|
||||
__Connections = {}
|
||||
}, Elevator)
|
||||
|
||||
RelayAlgorithmConstructor.Events.Sorted:Connect(function(AddedFloorDirection: Enums.ElevatorCallDirectionValues, FloorDirectionQueue: RelayAlgorithm.FloorDirectionQueue)
|
||||
if AddedFloorDirection == ElevatorClass.Elevator.TravelingDirection then
|
||||
local NextFloorAsTraveling = FloorDirectionQueue[1]
|
||||
if NextFloorAsTraveling then
|
||||
local Level = FloorLevelingPositions[NextFloorAsTraveling]
|
||||
ElevatorClass:__TravelToFloor(Level, Vector3.new(0, Level, 0), AddedFloorDirection)
|
||||
end
|
||||
Out.printStudio(`[{ElevatorConfigurationTable.Name}]: Floors sorted in proceeding direction. direction={AddedFloorDirection}, FloorDirectionQueue={FloorDirectionQueue}`)
|
||||
end
|
||||
end)
|
||||
|
||||
print(`🛗 [{ElevatorConfigurationTable.Name}]: Initialized and ready`)
|
||||
return ElevatorClass
|
||||
end
|
||||
|
||||
local function CheckFloorQueue(self: ClassConstructor)
|
||||
if self.RelayAlgorithm.__FloorQueue[1] ~= self.Attributes.CurrentFloor.Value then
|
||||
warn("The floor queue first index did not match the elevator's current floor, CurrentFloor=", self.Attributes.CurrentFloor.Value, "FloorQueue[1]=", self.RelayAlgorithm.__FloorQueue[1])
|
||||
end
|
||||
table.remove(self.RelayAlgorithm.__FloorQueue, 1)
|
||||
local function CheckFloorQueue(self: ClassConstructor, Direction: Enums.ElevatorCallDirectionValues)
|
||||
local DirectionFloorQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down
|
||||
|
||||
local NextFloorInQueue = self.RelayAlgorithm.__FloorQueue[1]
|
||||
print(NextFloorInQueue)
|
||||
if DirectionFloorQueue[1] ~= self.Attributes.CurrentFloor.Value then
|
||||
warn(`[{self.Elevator.Configuration.Name}]: The floor queue first index did not match the elevator's current floor, CurrentFloor=`, self.Attributes.CurrentFloor.Value, "FloorQueue[1]=", DirectionFloorQueue[1])
|
||||
end
|
||||
table.remove(DirectionFloorQueue, 1)
|
||||
Out.printStudio(`[{self.Elevator.Configuration.Name}]: Checking more floors in direction queue. DirectionFloorQueue=`, DirectionFloorQueue)
|
||||
|
||||
local NextFloorInQueue = DirectionFloorQueue[1]
|
||||
if NextFloorInQueue then
|
||||
local ElevatorGoingUp = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, NextFloorInQueue)
|
||||
local LevelVec3 = self.FloorLevelingPositions[NextFloorInQueue]
|
||||
|
||||
self:__TravelToFloor(NextFloorInQueue, LevelVec3, ElevatorGoingUp)
|
||||
else
|
||||
--No more floors in this direction?
|
||||
--Check the opposite
|
||||
if Direction == Enums.ElevatorCallDirection.Up then
|
||||
if #self.RelayAlgorithm.FloorQueue.Down ~= 0 then
|
||||
|
||||
end
|
||||
else
|
||||
if #self.RelayAlgorithm.FloorQueue.Up ~= 0 then
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function CabTraveling(self: ClassConstructor, deltaTime: number, LevelVec3: number, ElevatorGoingUp: boolean)
|
||||
local function CabTraveling(self: ClassConstructor, deltaTime: number, VEC3_Y_WRAP: Vector3, Direction: Enums.ElevatorCallDirectionValues)
|
||||
local ElevatorPosition = self.Elevator.BoxModel.Position
|
||||
local AtFloorY = self.FloorLevelingPositions[ElevatorGoingUp and self.Attributes.CurrentFloor.Value+1 or self.Attributes.CurrentFloor.Value-1]
|
||||
local AtFloorY = self.FloorLevelingPositions[Direction == Enums.ElevatorCallDirection.Up and self.Attributes.CurrentFloor.Value+1 or self.Attributes.CurrentFloor.Value-1]
|
||||
|
||||
if ElevatorGoingUp then
|
||||
if Direction == Enums.ElevatorCallDirection.Up then
|
||||
--Detecting between the floors
|
||||
if ElevatorPosition.Y>=AtFloorY-self.Elevator.Configuration.FloorLevelingDistance then
|
||||
self.Attributes.PreviousFloor.Value = self.Attributes.CurrentFloor.Value
|
||||
@@ -188,17 +217,17 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LevelVec3
|
||||
end
|
||||
|
||||
--Elevator is riding upwards towards the destination
|
||||
if ElevatorPosition.Y>=LevelVec3-self.Elevator.Configuration.FloorLevelingDistance then
|
||||
if ElevatorPosition.Y>=VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLevelingDistance then
|
||||
self.Events.__eventInstances__.Leveling:Fire()
|
||||
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.LevelingVelocity
|
||||
|
||||
if ElevatorPosition.Y>=LevelVec3-self.Elevator.Configuration.FloorLeveling3PhaseDistance then
|
||||
if ElevatorPosition.Y>=VEC3_Y_WRAP.Y-self.Elevator.Configuration.FloorLeveling3PhaseDistance then
|
||||
self.Events.__eventInstances__.Leveling3Phase:Fire()
|
||||
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity
|
||||
|
||||
if ElevatorPosition.Y>=LevelVec3-self.Elevator.Configuration.ParkedDistance then
|
||||
if ElevatorPosition.Y>=VEC3_Y_WRAP.Y-self.Elevator.Configuration.ParkedDistance then
|
||||
self.Events.__eventInstances__.Parked:Fire()
|
||||
CheckFloorQueue(self);
|
||||
CheckFloorQueue(self, Direction);
|
||||
|
||||
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
||||
end
|
||||
@@ -214,17 +243,17 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LevelVec3
|
||||
end
|
||||
|
||||
--Elevator is riding upwards towards the destination
|
||||
if ElevatorPosition.Y<=LevelVec3+self.Elevator.Configuration.FloorLevelingDistance then
|
||||
if ElevatorPosition.Y<=VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLevelingDistance then
|
||||
self.Events.__eventInstances__.Leveling:Fire()
|
||||
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.LevelingVelocity
|
||||
|
||||
if ElevatorPosition.Y<=LevelVec3+self.Elevator.Configuration.FloorLeveling3PhaseDistance then
|
||||
if ElevatorPosition.Y<=VEC3_Y_WRAP.Y+self.Elevator.Configuration.FloorLeveling3PhaseDistance then
|
||||
self.Events.__eventInstances__.Leveling3Phase:Fire()
|
||||
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.Phase3LevelingVelocity
|
||||
|
||||
if ElevatorPosition.Y<=LevelVec3+self.Elevator.Configuration.ParkedDistance then
|
||||
if ElevatorPosition.Y<=VEC3_Y_WRAP.Y+self.Elevator.Configuration.ParkedDistance then
|
||||
self.Events.__eventInstances__.Parked:Fire()
|
||||
CheckFloorQueue(self);
|
||||
CheckFloorQueue(self, Direction);
|
||||
|
||||
(self.__Connections.Moving :: RBXScriptConnection):Disconnect()
|
||||
end
|
||||
@@ -235,34 +264,48 @@ local function CabTraveling(self: ClassConstructor, deltaTime: number, LevelVec3
|
||||
self.Events.__eventInstances__.CabTraveling:Fire(deltaTime, ElevatorPosition)
|
||||
end
|
||||
|
||||
function Elevator:__TravelToFloor(LevelInt, LevelVec3, ElevatorGoingUp)
|
||||
function Elevator:GetLevel(LevelInt, Direction)
|
||||
local Level = self.FloorLevelingPositions[LevelInt]
|
||||
if Level then
|
||||
--local VEC3_Y_WRAP_LOSSY = Vector3.yAxis*Level //lossy
|
||||
return Vector3.new(0, Level, 0)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function Elevator:__TravelToFloor(LevelInt, VEC3_Y_WRAP, Direction)
|
||||
if self.__Connections.Moving and self.__Connections.Moving.Connected then
|
||||
self.__Connections.Moving:Disconnect()
|
||||
end
|
||||
|
||||
self.Attributes.Goal.Value = LevelInt
|
||||
self.Attributes.GoingUp.Value = ElevatorGoingUp
|
||||
self.Attributes.TravelingUpwards.Value = Direction == Enums.ElevatorCallDirection.Up
|
||||
|
||||
self.__Connections.Moving = RunService.Heartbeat:Connect(function(deltaTime)
|
||||
CabTraveling(self, deltaTime, LevelVec3, ElevatorGoingUp)
|
||||
self.__Connections.Moving = RunService.Heartbeat:Connect(function(deltaTime: number)
|
||||
CabTraveling(self, deltaTime, VEC3_Y_WRAP, Direction :: Enums.ElevatorCallDirectionValues)
|
||||
end)
|
||||
|
||||
--Set the elevator's AlignPosition to the floor Y vector
|
||||
self.Elevator.AlignPosition.Position = Vector3.new(self.Elevator.AlignPosition.Position.X, LevelVec3, self.Elevator.AlignPosition.Position.Z)
|
||||
self.Elevator.AlignPosition.Position = Vector3.new(self.Elevator.AlignPosition.Position.X, VEC3_Y_WRAP.Y, self.Elevator.AlignPosition.Position.Z)
|
||||
--Set the elevator's max velocity to its fastest speed when moving starts
|
||||
self.Elevator.AlignPosition.MaxVelocity = self.Elevator.Configuration.MaxVelocity
|
||||
end
|
||||
|
||||
function Elevator:RequestLevel(RequestedLevel)
|
||||
local LevelVec3 = self.FloorLevelingPositions[RequestedLevel]
|
||||
function Elevator:RequestLevel(RequestedLevel, Direction)
|
||||
local Level = self:GetLevel(RequestedLevel, Direction :: Enums.ElevatorCallDirectionValues)
|
||||
|
||||
if LevelVec3 then
|
||||
if Level then
|
||||
if RequestedLevel ~= self.Attributes.CurrentFloor.Value then
|
||||
local ElevatorGoingUp = ElevatorGoingUpDirection(self.Attributes.CurrentFloor.Value, RequestedLevel)
|
||||
self.RelayAlgorithm:AddFloor(ElevatorGoingUp, self.Attributes.GoingUp, RequestedLevel)
|
||||
if (RequestedLevel == 1 and Direction == Enums.ElevatorCallDirection.Down) or (RequestedLevel == #self.FloorLevelingPositions and Direction == Enums.ElevatorCallDirection.Up) then
|
||||
warn(`[{self.Elevator.Configuration.Name}]: Impossible direction requested, Direction={Direction}, RequestedLevel={Level}`)
|
||||
return false
|
||||
else
|
||||
local DirectionQueue = Direction == Enums.ElevatorCallDirection.Up and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down
|
||||
self.RelayAlgorithm:AddFloor(Direction :: Enums.ElevatorCallDirectionValues, RequestedLevel)
|
||||
|
||||
if #self.RelayAlgorithm.__FloorQueue == 1 then
|
||||
self:__TravelToFloor(RequestedLevel, LevelVec3, ElevatorGoingUp)
|
||||
if #DirectionQueue == 1 then
|
||||
self:__TravelToFloor(RequestedLevel, Level, Direction :: Enums.ElevatorCallDirectionValues)
|
||||
end
|
||||
end
|
||||
else
|
||||
warn(`[{self.Elevator.Configuration.Name}]: The elevator is already at the requested floor. RequestLevel={RequestedLevel}, CurrentLevel={self.Attributes.CurrentFloor.Value}`)
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
local ParentDir = script.Parent
|
||||
local MainDir = ParentDir.Parent
|
||||
|
||||
local StorageService = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Enums = require(StorageService:WaitForChild("Enums"))
|
||||
local InitElevator = require(ParentDir:WaitForChild("InitElevator"))
|
||||
local TagsModule = require(MainDir:WaitForChild("Load"):WaitForChild("Tags"))
|
||||
|
||||
@@ -48,7 +51,7 @@ return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsMod
|
||||
end)
|
||||
|
||||
task.wait(1)
|
||||
Elevator:RequestLevel(3)
|
||||
Elevator:RequestLevel(5)
|
||||
Elevator:RequestLevel(2)
|
||||
Elevator:RequestLevel(3, Enums.ElevatorCallDirection.Up)
|
||||
Elevator:RequestLevel(5, Enums.ElevatorCallDirection.Up)
|
||||
Elevator:RequestLevel(2, Enums.ElevatorCallDirection.Down)
|
||||
end
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
local SoundEnums = {}
|
||||
|
||||
--MACROSSSSSSSSSSS
|
||||
export type Otis1960Sounds = typeof(SoundEnums.Otis1960)
|
||||
|
||||
export type Otis1960LanternChimeDirection = "rbxassetid://16990287228"
|
||||
export type Otis1960LanternChimeLanding = "rbxassetid://16990290265"
|
||||
export type Otis1960DoorClosingClick = "rbxassetid://16357740945"
|
||||
@@ -14,18 +14,8 @@ export type Otis1960RelayLowActivated = "rbxassetid://17701796245"
|
||||
export type Otis1960RelayDeActivated = "rbxassetid://17702004158"
|
||||
export type Otis1960BigRelayActivated = "rbxassetid://17701707630"
|
||||
export type Otis1960BigRelayDeActivated = "rbxassetid://17701712012"
|
||||
|
||||
export type Otis1960SoundValues = Otis1960LanternChimeDirection |
|
||||
Otis1960LanternChimeLanding |
|
||||
Otis1960DoorClosingClick |
|
||||
Otis1960RelayHighActivated |
|
||||
Otis1960RelayLowActivated |
|
||||
Otis1960RelayDeActivated |
|
||||
Otis1960BigRelayActivated |
|
||||
Otis1960BigRelayDeActivated
|
||||
|
||||
export type Otis1960SoundValues = Otis1960LanternChimeDirection | Otis1960LanternChimeLanding | Otis1960DoorClosingClick | Otis1960RelayHighActivated | Otis1960RelayLowActivated | Otis1960RelayDeActivated | Otis1960BigRelayActivated | Otis1960BigRelayDeActivated
|
||||
export type ElevatorSoundValues = Otis1960SoundValues
|
||||
|
||||
SoundEnums.Otis1960 = {
|
||||
LanternChimeDirection = "rbxassetid://16990287228" :: Otis1960LanternChimeDirection,
|
||||
LanternChimeLanding = "rbxassetid://16990290265" :: Otis1960LanternChimeLanding,
|
||||
|
||||
@@ -4,33 +4,11 @@
|
||||
|
||||
local Enums = {}
|
||||
|
||||
--MACROSSSSSSSSSSS
|
||||
export type EnumValue = EnumButton | EnumButtonTree | EnumElevator | EnumInteractables | EnumSpecialButton
|
||||
|
||||
export type EnumButton = typeof(Enums.Button)
|
||||
export type EnumButtonTree = typeof(Enums.ButtonTree)
|
||||
export type EnumElevator = typeof(Enums.Elevator)
|
||||
export type EnumInteractables = typeof(Enums.InteractType)
|
||||
export type EnumSpecialButton = typeof(Enums.SpecialButton)
|
||||
|
||||
export type ButtonValues = typeof(Enums.Button.Car) |
|
||||
typeof(Enums.Button.Landing) |
|
||||
typeof(Enums.Button.Special) |
|
||||
typeof(Enums.Button.Relay)
|
||||
|
||||
export type ButtonTreeValues = typeof(Enums.ButtonTree.Car) |
|
||||
typeof(Enums.ButtonTree.Landing) |
|
||||
typeof(Enums.ButtonTree.Special) |
|
||||
typeof(Enums.ButtonTree.Relays) |
|
||||
typeof(Enums.ButtonTree.Unknown)
|
||||
|
||||
export type SpecialButtonValues = typeof(Enums.SpecialButton.Stop)
|
||||
|
||||
export type InteractablesValues = typeof(Enums.InteractType.LightSwitch) |
|
||||
typeof(Enums.InteractType.Light) |
|
||||
typeof(Enums.InteractType.LightSource)
|
||||
|
||||
export type ElevatorValues = typeof(Enums.Elevator.Otis1960) |
|
||||
typeof(Enums.Elevator.Haughton)
|
||||
|
||||
export type ButtonValues = typeof(Enums.Button.Car) | typeof(Enums.Button.Landing) | typeof(Enums.Button.Special) | typeof(Enums.Button.Relay)
|
||||
Enums.Button = {
|
||||
Car = "CarButton" :: "CarButton",
|
||||
Landing = "LandingButton" :: "LandingButton",
|
||||
@@ -38,6 +16,8 @@ Enums.Button = {
|
||||
Relay = "RelayButton" :: "RelayButton"
|
||||
}
|
||||
|
||||
export type EnumButtonTree = typeof(Enums.ButtonTree)
|
||||
export type ButtonTreeValues = typeof(Enums.ButtonTree.Car) | typeof(Enums.ButtonTree.Landing) | typeof(Enums.ButtonTree.Special) | typeof(Enums.ButtonTree.Relays) | typeof(Enums.ButtonTree.Unknown)
|
||||
Enums.ButtonTree = {
|
||||
Car = "Car" :: "Car",
|
||||
Landing = "Landing" :: "Landing",
|
||||
@@ -46,19 +26,32 @@ Enums.ButtonTree = {
|
||||
Unknown = "Unknown" :: "Unknown"
|
||||
}
|
||||
|
||||
export type EnumSpecialButton = typeof(Enums.SpecialButton)
|
||||
export type SpecialButtonValues = typeof(Enums.SpecialButton.Stop)
|
||||
Enums.SpecialButton = {
|
||||
Stop = "Stop" :: "Stop"
|
||||
}
|
||||
|
||||
export type EnumElevator = typeof(Enums.Elevator)
|
||||
export type ElevatorValues = typeof(Enums.Elevator.Otis1960) | typeof(Enums.Elevator.Haughton)
|
||||
Enums.Elevator = {
|
||||
Otis1960 = "Otis1960" :: "Otis1960",
|
||||
Haughton = "Haughton" :: "Haughton"
|
||||
}
|
||||
|
||||
export type EnumInteractables = typeof(Enums.InteractType)
|
||||
export type InteractablesValues = typeof(Enums.InteractType.LightSwitch) | typeof(Enums.InteractType.Light) | typeof(Enums.InteractType.LightSource)
|
||||
Enums.InteractType = {
|
||||
LightSwitch = "LightSwitch" :: "LightSwitch",
|
||||
Light = "Light" :: "Light",
|
||||
LightSource = "LightSource" :: "LightSource"
|
||||
}
|
||||
|
||||
export type EnumElevatorCallDirections = typeof(Enums.ElevatorCallDirection)
|
||||
export type ElevatorCallDirectionValues = typeof(Enums.ElevatorCallDirection.Up) | typeof(Enums.ElevatorCallDirection.Down)
|
||||
Enums.ElevatorCallDirection = {
|
||||
Up = "Up" :: "Up",
|
||||
Down = "Down" :: "Down"
|
||||
}
|
||||
|
||||
return Enums
|
||||
50
src/shared/Output.luau
Normal file
50
src/shared/Output.luau
Normal file
@@ -0,0 +1,50 @@
|
||||
--!optimize 2
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local RunService = game:GetService("RunService")
|
||||
|
||||
local function printStudio<T...>(...: T...)
|
||||
if RunService:IsStudio() then
|
||||
print(...)
|
||||
end
|
||||
end
|
||||
|
||||
local function printServer<T...>(...: T...)
|
||||
if RunService:IsServer() then
|
||||
print(...)
|
||||
end
|
||||
end
|
||||
|
||||
local function printClient<T...>(...: T...)
|
||||
if RunService:IsClient() then
|
||||
print(...)
|
||||
end
|
||||
end
|
||||
|
||||
local function warnStudio<T...>(...: T...)
|
||||
if RunService:IsStudio() then
|
||||
warn(...)
|
||||
end
|
||||
end
|
||||
|
||||
local function warnServer<T...>(...: T...)
|
||||
if RunService:IsServer() then
|
||||
warn(...)
|
||||
end
|
||||
end
|
||||
|
||||
local function warnClient<T...>(...: T...)
|
||||
if RunService:IsClient() then
|
||||
warn(...)
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
printStudio = printStudio,
|
||||
printServer = printServer,
|
||||
printClient = printClient,
|
||||
warnStudio = warnStudio,
|
||||
warnServer = warnServer,
|
||||
warnClient = warnClient
|
||||
}
|
||||
Reference in New Issue
Block a user