mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-13 22:31:55 +00:00
Working car button system, need to figure out some phantom data on the relay algorithm events for hall station buttons to recognize and pick up the heading direction
This commit is contained in:
@@ -1,14 +1,15 @@
|
|||||||
# Lights
|
## Lights
|
||||||
#### Properties
|
##### Properties / Attributes
|
||||||
- Activated #Color3
|
- Activated #Color3
|
||||||
- The color that is shown on the <a>Light Props</a> once
|
- ActivatedMaterial #string
|
||||||
- ActivatedMaterial #string / #MaterialName
|
|
||||||
- Deactivated #Color3
|
- Deactivated #Color3
|
||||||
- DeactivatedMaterial #string / #MaterialName
|
- DeactivatedMaterial #string
|
||||||
- Enabled #boolean
|
- Enabled #boolean
|
||||||
#### Tag
|
##### Tag
|
||||||
* `Interact_LightSwitch_*AreaName*`
|
* ### Interact_LightSwitch_Area
|
||||||
* `Interact` - *Interact Initializer* [`Not Changable`]
|
* `Interact` - *Interact Initialize* [`Not Changable`]
|
||||||
* `LightSwitch` - *Interaction Type* [`Not Changable`]
|
* `LightSwitch` - *Interaction Type* [`Not Changable`]
|
||||||
* `*AreaName*` - *Area name, must be unique and cannot use the same names* [`Changable`]
|
* `AreaName` - *Area name, must be unique and cannot use the same names* [`Changable`]
|
||||||
|
## Elevator
|
||||||
|
* ##### Cab
|
||||||
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -13,7 +13,7 @@ local Map = Main:WaitForChild("Map")
|
|||||||
local PromptModule = require(Map:WaitForChild("Prompts"))
|
local PromptModule = require(Map:WaitForChild("Prompts"))
|
||||||
local Tags = require(Map:WaitForChild("Load"):WaitForChild("Tags"))
|
local Tags = require(Map:WaitForChild("Load"):WaitForChild("Tags"))
|
||||||
|
|
||||||
type FloorButtonActivatedCallback = (ButtonFloor: number | string) -> ()
|
type FloorButtonActivatedCallback = (ButtonFloor: number) -> ()
|
||||||
type StopButtonActivatedCallback = (Toggled: boolean) -> ()
|
type StopButtonActivatedCallback = (Toggled: boolean) -> ()
|
||||||
|
|
||||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ type Impl_Constructor = {
|
|||||||
__index: Impl_Constructor,
|
__index: Impl_Constructor,
|
||||||
constructor: Constructor_Fun,
|
constructor: Constructor_Fun,
|
||||||
--Class functions
|
--Class functions
|
||||||
InitForElevator: (self: ClassConstructor, MaxActivationDistance: number?, AddedOffset: Vector3?) -> ()
|
InitForElevator: (self: ClassConstructor, MaxActivationDistance: number?, AddedOffset: Vector3?) -> (),
|
||||||
|
Get: (self: ClassConstructor, ButtonType: Enums.ButtonTreeValues, ButtonID: number) -> Tags.ButtonProperties?
|
||||||
}
|
}
|
||||||
|
|
||||||
type Constructor_Fun = (
|
type Constructor_Fun = (
|
||||||
@@ -33,21 +34,24 @@ type Constructor_Return_Props = {
|
|||||||
ElevatorModel: Enums.ElevatorValues,
|
ElevatorModel: Enums.ElevatorValues,
|
||||||
ButtonTags: Tags.ElevatorButtons,
|
ButtonTags: Tags.ElevatorButtons,
|
||||||
CurrentFloor: IntValue,
|
CurrentFloor: IntValue,
|
||||||
Events: Events
|
Events: Events,
|
||||||
|
__PromptButtons__: Tags.ButtonsTree?
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Events = {
|
export type Events = {
|
||||||
FloorButtonActivated: RBXScriptSignal<boolean, number | string, Tags.ButtonPropertiesSafe>,
|
FloorButtonActivated: RBXScriptSignal<boolean, number, Tags.ButtonProperties>,
|
||||||
__eventInstances__: {
|
__eventInstances__: {
|
||||||
FloorButtonActivated: BindableEvent
|
FloorButtonActivated: BindableEvent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type constructor = ClassConstructor
|
||||||
|
|
||||||
local Buttons = {} :: Impl_Constructor
|
local Buttons = {} :: Impl_Constructor
|
||||||
Buttons.__index = Buttons
|
Buttons.__index = Buttons
|
||||||
|
|
||||||
function Buttons.constructor(ElevatorModel, ButtonTags, CurrentFloor)
|
function Buttons.constructor(ElevatorModel, ButtonTags, CurrentFloor)
|
||||||
local ButtonActivated = Instance.new("BindableEvent")
|
local ButtonActivated = Instance.new("BindableEvent") :: BindableEvent
|
||||||
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
ElevatorModel = ElevatorModel,
|
ElevatorModel = ElevatorModel,
|
||||||
@@ -69,24 +73,36 @@ function Buttons:InitForElevator(MaxActivationDistance, AddedOffset)
|
|||||||
|
|
||||||
local ButtonManagerConstructor = ButtonManager.constructor(self.CurrentFloor)
|
local ButtonManagerConstructor = ButtonManager.constructor(self.CurrentFloor)
|
||||||
local ButtonTagsConstructor = ButtonTags.constructor(self.ButtonTags, self.ElevatorModel)
|
local ButtonTagsConstructor = ButtonTags.constructor(self.ButtonTags, self.ElevatorModel)
|
||||||
local Prompt = ButtonTagsConstructor:CreatePromptButtons()
|
|
||||||
|
|
||||||
local CarButtonPrompts = Prompt[self.ElevatorModel].Car
|
self.__PromptButtons__ = ButtonTagsConstructor:CreatePromptButtons()
|
||||||
|
|
||||||
|
local CarButtonPrompts = (self.__PromptButtons__ :: Tags.ButtonsTree)[self.ElevatorModel].Car
|
||||||
|
|
||||||
for PromptType, PromptProperties in CarButtonPrompts do
|
for PromptType, PromptProperties in CarButtonPrompts do
|
||||||
if PromptProperties.Attachment and PromptProperties.Inst and PromptProperties.Prompt then
|
PromptProperties.Prompt.MaxActivationDistance = MaxActivationDistance :: number
|
||||||
PromptProperties.Prompt.MaxActivationDistance = MaxActivationDistance :: number
|
PromptProperties.Attachment.Position+=AddedOffset :: Vector3
|
||||||
PromptProperties.Attachment.Position+=AddedOffset :: Vector3
|
|
||||||
|
|
||||||
ButtonManagerConstructor:CarButton(PromptType, PromptProperties, function(ButtonFloor: number | string)
|
ButtonManagerConstructor:CarButton(PromptType, PromptProperties, function(ButtonFloor: number)
|
||||||
self.Events.__eventInstances__.FloorButtonActivated:Fire(true, ButtonFloor, PromptProperties :: Tags.ButtonPropertiesSafe)
|
self.Events.__eventInstances__.FloorButtonActivated:Fire(true, ButtonFloor, PromptProperties)
|
||||||
end, function(ButtonFloor: number | string)
|
end, function(ButtonFloor: number)
|
||||||
self.Events.__eventInstances__.FloorButtonActivated:Fire(false, ButtonFloor, PromptProperties :: Tags.ButtonPropertiesSafe)
|
self.Events.__eventInstances__.FloorButtonActivated:Fire(false, ButtonFloor, PromptProperties)
|
||||||
end)
|
end)
|
||||||
else
|
|
||||||
warn()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Buttons:Get(ButtonType, ButtonName)
|
||||||
|
assert(self.__PromptButtons__, `Initialize the elevator buttons first before using :Get, self.__PromptButtons__={self.__PromptButtons__}`)
|
||||||
|
|
||||||
|
local Button = self.__PromptButtons__[self.ElevatorModel][ButtonType] :: Tags.ButtonDictionary?
|
||||||
|
if Button then
|
||||||
|
--mega cringe
|
||||||
|
for ButtonFullName: string, ButtonProps: Tags.ButtonProperties in Button do
|
||||||
|
if ButtonProps.ID == ButtonName then
|
||||||
|
return ButtonProps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
return Buttons
|
return Buttons
|
||||||
48
src/server/main/Elevators/Map/Haughton/Doors.luau
Normal file
48
src/server/main/Elevators/Map/Haughton/Doors.luau
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
--!optimize 2
|
||||||
|
--!native
|
||||||
|
--!strict
|
||||||
|
|
||||||
|
local ParentDir = script.Parent
|
||||||
|
local ElevatorsDir = ParentDir.Parent.Parent
|
||||||
|
local MainDir = ElevatorsDir.Parent
|
||||||
|
|
||||||
|
local DoorEnums = require(MainDir:WaitForChild("Types"):WaitForChild("Enums"):WaitForChild("Doors"))
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
}
|
||||||
|
|
||||||
|
type LandingDoorsTree = {
|
||||||
|
[number]: {BasePart}
|
||||||
|
}
|
||||||
|
type CabDoorsTree = {
|
||||||
|
[number]: {BasePart}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Constructor_Fun = (
|
||||||
|
|
||||||
|
) -> ClassConstructor
|
||||||
|
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
local Doors = {}
|
||||||
|
Doors.__index = Doors
|
||||||
|
|
||||||
|
function Doors.constructor(CabDoorsType, LandingDoorsType, LandingDoorsTree, CabDoorsTree)
|
||||||
|
return setmetatable({}, Doors)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Doors:Open()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function Doors:Close()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return Doors
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
--!optimize 2
|
|
||||||
--!native
|
|
||||||
--!strict
|
|
||||||
|
|
||||||
local ParentDir = script.Parent
|
|
||||||
local ElevatorsDir = ParentDir.Parent.Parent
|
|
||||||
local MainDir = ElevatorsDir.Parent
|
|
||||||
|
|
||||||
local StorageService = game:GetService("ReplicatedStorage")
|
|
||||||
|
|
||||||
local Enums = require(StorageService:WaitForChild("Enums"))
|
|
||||||
local InitElevator = require(ElevatorsDir:WaitForChild("System"))
|
|
||||||
local Buttons = require(ParentDir:WaitForChild("Buttons"))
|
|
||||||
local MovingObjects = require(ParentDir:WaitForChild("MovingObjects"))
|
|
||||||
local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags"))
|
|
||||||
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator"))
|
|
||||||
|
|
||||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
|
||||||
|
|
||||||
type Impl_Constructor = {
|
|
||||||
__index: Impl_Constructor,
|
|
||||||
constructor: Constructor_Fun,
|
|
||||||
--Class functions
|
|
||||||
Elevator: (self: ClassConstructor) -> (),
|
|
||||||
Buttons: (self: ClassConstructor) -> ()
|
|
||||||
}
|
|
||||||
|
|
||||||
type Constructor_Fun = (
|
|
||||||
InitElevatorConstructor: InitElevator.constructor,
|
|
||||||
ElevatorConfig: ElevatorTypes.ElevatorConfigurationTable,
|
|
||||||
ElevatorEvents: InitElevator.Events,
|
|
||||||
ElevatorAttributes: InitElevator.Attributes,
|
|
||||||
ButtonEvents: Buttons.Events,
|
|
||||||
ElevatorBoxModel: BasePart,
|
|
||||||
Leveling: {number},
|
|
||||||
MovingObjectsConstructor: MovingObjects.constructor
|
|
||||||
) -> ClassConstructor
|
|
||||||
|
|
||||||
type Constructor_Return_Props = {
|
|
||||||
InitElevatorConstructor: InitElevator.constructor,
|
|
||||||
ElevatorConfig: ElevatorTypes.ElevatorConfigurationTable,
|
|
||||||
ElevatorEvents: InitElevator.Events,
|
|
||||||
ElevatorAttributes: InitElevator.Attributes,
|
|
||||||
ButtonEvents: Buttons.Events,
|
|
||||||
ElevatorBoxModel: BasePart,
|
|
||||||
Leveling: {number},
|
|
||||||
MovingObjectsConstructor: MovingObjects.constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
local Events = {} :: Impl_Constructor
|
|
||||||
Events.__index = Events
|
|
||||||
|
|
||||||
function Events.constructor(InitElevatorConstructor, ElevatorConfig, ElevatorEvents, ElevatorAttributes, ButtonEvents, ElevatorBoxModel, Leveling, MovingObjectsConstructor)
|
|
||||||
return setmetatable({
|
|
||||||
InitElevatorConstructor = InitElevatorConstructor,
|
|
||||||
ElevatorConfig = ElevatorConfig,
|
|
||||||
ElevatorEvents = ElevatorEvents,
|
|
||||||
ElevatorAttributes = ElevatorAttributes,
|
|
||||||
ButtonEvents = ButtonEvents,
|
|
||||||
ElevatorBoxModel = ElevatorBoxModel,
|
|
||||||
Leveling = Leveling,
|
|
||||||
MovingObjectsConstructor = MovingObjectsConstructor
|
|
||||||
}, Events)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Events:Elevator()
|
|
||||||
self.ElevatorEvents.Traveling:Connect(function(_DeltaTime: number, CabPosition: Vector3)
|
|
||||||
local CabVelocity = self.ElevatorBoxModel:GetVelocityAtPosition(CabPosition)
|
|
||||||
local TravelingUpwards = self.ElevatorAttributes.TravelingUpwards.Value
|
|
||||||
|
|
||||||
self.MovingObjectsConstructor:RotatePulleyWheel(TravelingUpwards, CabVelocity.Y)
|
|
||||||
self.MovingObjectsConstructor:RotateRotodials(CabVelocity.Y)
|
|
||||||
end)
|
|
||||||
self.ElevatorEvents.Progression:Connect(function(previousFloor: number, CurrentFloor: number, NextFloor: number)
|
|
||||||
|
|
||||||
end)
|
|
||||||
self.ElevatorEvents.Leveling:Connect(function()
|
|
||||||
self.MovingObjectsConstructor:RotateRelayCogs2Async()
|
|
||||||
end)
|
|
||||||
self.ElevatorEvents.Leveling3Phase:Connect(function()
|
|
||||||
|
|
||||||
end)
|
|
||||||
self.ElevatorEvents.ManualTravelRequested:Connect(function()
|
|
||||||
self.MovingObjectsConstructor:ControllerStartAsync()
|
|
||||||
task.wait(1)
|
|
||||||
self.MovingObjectsConstructor:RotateRelayCogs1Async().Completed:Wait()
|
|
||||||
self.InitElevatorConstructor:StartTraveling()
|
|
||||||
end)
|
|
||||||
self.ElevatorEvents.TravelStart:Connect(function()
|
|
||||||
|
|
||||||
end)
|
|
||||||
self.ElevatorEvents.Parked:Connect(function()
|
|
||||||
self.MovingObjectsConstructor:RotateRelayCogs3()
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function ElevatorGoingUpDirection(CurrentFloor: number, RequestedFloor: number): boolean
|
|
||||||
return CurrentFloor<RequestedFloor
|
|
||||||
end
|
|
||||||
|
|
||||||
function Events:Buttons()
|
|
||||||
self.ButtonEvents.FloorButtonActivated:Connect(function(Success: boolean, Floor: number | string, Properties: TagsModule.ButtonPropertiesSafe)
|
|
||||||
Properties.Prompt.Enabled = false
|
|
||||||
(Properties.Inst :: BasePart).Color = self.ElevatorConfig.Colors.ButtonActivated.Color;
|
|
||||||
(Properties.Inst :: BasePart).Material = self.ElevatorConfig.Colors.ButtonActivated.Material
|
|
||||||
|
|
||||||
if Success then
|
|
||||||
local CorrectFloor: number = 0
|
|
||||||
if type(Floor) == "string" then
|
|
||||||
if Floor == "B" then
|
|
||||||
CorrectFloor = 1
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- CorrectFloor = Floor~=#self.Leveling and Floor+1 or Floor
|
|
||||||
CorrectFloor = Floor
|
|
||||||
end
|
|
||||||
if CorrectFloor ~= 0 then
|
|
||||||
local Direction = ElevatorGoingUpDirection(self.ElevatorAttributes.CurrentFloor.Value, CorrectFloor) and Enums.ElevatorCallDirection.Up or Enums.ElevatorCallDirection.Down
|
|
||||||
task.spawn(function()
|
|
||||||
self.InitElevatorConstructor:RequestLevelAsync(CorrectFloor, Direction :: Enums.ElevatorCallDirectionValues)
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
warn(`[{self.ElevatorConfig.Name}]: The floor index was 0. Call={Floor}`)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
return Events
|
|
||||||
93
src/server/main/Elevators/Map/Haughton/Events/Buttons.luau
Normal file
93
src/server/main/Elevators/Map/Haughton/Events/Buttons.luau
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
--!optimize 2
|
||||||
|
--!native
|
||||||
|
--!strict
|
||||||
|
|
||||||
|
local ParentDir = script.Parent
|
||||||
|
local ElevatorDir = ParentDir.Parent
|
||||||
|
local ElevatorsDir = ElevatorDir.Parent.Parent
|
||||||
|
local MainDir = ElevatorsDir.Parent
|
||||||
|
|
||||||
|
local StorageService = game:GetService("ReplicatedStorage")
|
||||||
|
|
||||||
|
local Enums = require(StorageService:WaitForChild("Enums"))
|
||||||
|
local InitElevator = require(ElevatorsDir:WaitForChild("System"))
|
||||||
|
local Buttons = require(ElevatorDir:WaitForChild("Buttons"))
|
||||||
|
local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags"))
|
||||||
|
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator"))
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
Events: (self: ClassConstructor) -> ()
|
||||||
|
}
|
||||||
|
|
||||||
|
type Constructor_Fun = (ElevatorConfig: ElevatorTypes.ElevatorConfigurationTable, ElevatorConstructor: InitElevator.constructor, ButtonsConstructor: Buttons.constructor) -> ClassConstructor
|
||||||
|
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
ElevatorConfig: ElevatorTypes.ElevatorConfigurationTable,
|
||||||
|
ElevatorConstructor: InitElevator.constructor,
|
||||||
|
ButtonsConstructor: Buttons.constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
local ButtonEvents = {} :: Impl_Constructor
|
||||||
|
ButtonEvents.__index = ButtonEvents
|
||||||
|
|
||||||
|
function ButtonEvents.constructor(ElevatorConfig, ElevatorConstructor, ButtonsConstructor)
|
||||||
|
return setmetatable({
|
||||||
|
ElevatorConfig = ElevatorConfig,
|
||||||
|
ElevatorConstructor = ElevatorConstructor,
|
||||||
|
ButtonsConstructor = ButtonsConstructor
|
||||||
|
}, ButtonEvents)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ElevatorGoingUpDirection(CurrentFloor: number, RequestedFloor: number): boolean
|
||||||
|
return CurrentFloor<RequestedFloor
|
||||||
|
end
|
||||||
|
|
||||||
|
local function DeactivateButton(self: ClassConstructor, Properties: TagsModule.ButtonProperties)
|
||||||
|
(Properties.Inst :: BasePart).Color = self.ElevatorConfig.Colors.ButtonDeactivated.Color;
|
||||||
|
(Properties.Inst :: BasePart).Material = self.ElevatorConfig.Colors.ButtonDeactivated.Material
|
||||||
|
Properties.Prompt.Enabled = true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ActivateButton(self: ClassConstructor, Properties: TagsModule.ButtonProperties)
|
||||||
|
Properties.Prompt.Enabled = false
|
||||||
|
(Properties.Inst :: BasePart).Color = self.ElevatorConfig.Colors.ButtonActivated.Color;
|
||||||
|
(Properties.Inst :: BasePart).Material = self.ElevatorConfig.Colors.ButtonActivated.Material
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ButtonAttributes(self: ClassConstructor)
|
||||||
|
self.ElevatorConstructor.Attributes.CurrentFloor:GetPropertyChangedSignal("Value"):Connect(function()
|
||||||
|
if self.ElevatorConstructor.Attributes.CurrentFloor.Value == self.ElevatorConstructor.Attributes.Goal.Value then
|
||||||
|
local FloorButton = self.ButtonsConstructor:Get(Enums.ButtonTree.Car, self.ElevatorConstructor.Attributes.CurrentFloor.Value)
|
||||||
|
if FloorButton then
|
||||||
|
DeactivateButton(self, FloorButton)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ButtonEvents:Events()
|
||||||
|
self.ElevatorConstructor.RelayAlgorithm.Events.Added:Connect(function(_Direction: Enums.ElevatorCallDirectionValues, AddedFloor: number)
|
||||||
|
local FloorButton = self.ButtonsConstructor:Get(Enums.ButtonTree.Car, AddedFloor)
|
||||||
|
if FloorButton then
|
||||||
|
ActivateButton(self, FloorButton)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
self.ButtonsConstructor.Events.FloorButtonActivated:Connect(function(Success: boolean, Floor: number, Properties: TagsModule.ButtonProperties)
|
||||||
|
if Success then
|
||||||
|
local Direction = ElevatorGoingUpDirection(self.ElevatorConstructor.Attributes.CurrentFloor.Value, Floor) and Enums.ElevatorCallDirection.Up or Enums.ElevatorCallDirection.Down
|
||||||
|
self.ElevatorConstructor:RequestLevelAsync(Floor, Direction :: Enums.ElevatorCallDirectionValues)
|
||||||
|
else
|
||||||
|
ActivateButton(self, Properties)
|
||||||
|
task.wait(.45)
|
||||||
|
DeactivateButton(self, Properties)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
ButtonAttributes(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
return ButtonEvents
|
||||||
106
src/server/main/Elevators/Map/Haughton/Events/init.luau
Normal file
106
src/server/main/Elevators/Map/Haughton/Events/init.luau
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
--!optimize 2
|
||||||
|
--!native
|
||||||
|
--!strict
|
||||||
|
|
||||||
|
local ParentDir = script.Parent
|
||||||
|
local ElevatorsDir = ParentDir.Parent.Parent
|
||||||
|
local MainDir = ElevatorsDir.Parent
|
||||||
|
|
||||||
|
local ButtonEvents = require(script:WaitForChild("Buttons"))
|
||||||
|
local InitElevator = require(ElevatorsDir:WaitForChild("System"))
|
||||||
|
local Buttons = require(ParentDir:WaitForChild("Buttons"))
|
||||||
|
local MovingObjects = require(ParentDir:WaitForChild("MovingObjects"))
|
||||||
|
local TractionRopes = require(ParentDir:WaitForChild("TractionRopes"))
|
||||||
|
local ElevatorTypes = require(MainDir:WaitForChild("Types"):WaitForChild("Elevator"))
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
InitButtons: (self: ClassConstructor) -> ()
|
||||||
|
}
|
||||||
|
|
||||||
|
type Constructor_Fun = (
|
||||||
|
ElevatorConstructor: InitElevator.constructor,
|
||||||
|
ElevatorConfig: ElevatorTypes.ElevatorConfigurationTable,
|
||||||
|
ButtonsConstructor: Buttons.constructor,
|
||||||
|
ElevatorBoxModel: BasePart,
|
||||||
|
Leveling: {number},
|
||||||
|
MovingObjectsConstructor: MovingObjects.constructor,
|
||||||
|
TractionRopesConstructor: TractionRopes.constructor
|
||||||
|
) -> ClassConstructor
|
||||||
|
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
ElevatorConstructor: InitElevator.constructor,
|
||||||
|
ElevatorConfig: ElevatorTypes.ElevatorConfigurationTable,
|
||||||
|
ButtonsConstructor: Buttons.constructor,
|
||||||
|
ElevatorBoxModel: BasePart,
|
||||||
|
Leveling: {number},
|
||||||
|
MovingObjectsConstructor: MovingObjects.constructor,
|
||||||
|
TractionRopesConstructor: TractionRopes.constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
local Events = {} :: Impl_Constructor
|
||||||
|
Events.__index = Events
|
||||||
|
|
||||||
|
function Events.constructor(
|
||||||
|
ElevatorConstructor,
|
||||||
|
ElevatorConfig,
|
||||||
|
ButtonsConstructor,
|
||||||
|
ElevatorBoxModel,
|
||||||
|
Leveling,
|
||||||
|
MovingObjectsConstructor,
|
||||||
|
TractionRopesConstructor
|
||||||
|
)
|
||||||
|
return setmetatable({
|
||||||
|
ElevatorConstructor = ElevatorConstructor,
|
||||||
|
ElevatorConfig = ElevatorConfig,
|
||||||
|
ButtonsConstructor = ButtonsConstructor,
|
||||||
|
ElevatorBoxModel = ElevatorBoxModel,
|
||||||
|
Leveling = Leveling,
|
||||||
|
MovingObjectsConstructor = MovingObjectsConstructor,
|
||||||
|
TractionRopesConstructor = TractionRopesConstructor
|
||||||
|
}, Events)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ElevatorEvents(self: ClassConstructor)
|
||||||
|
self.ElevatorConstructor.Events.Traveling:Connect(function(_DeltaTime: number, CabPosition: Vector3)
|
||||||
|
local CabVelocity = self.ElevatorBoxModel:GetVelocityAtPosition(CabPosition)
|
||||||
|
local TravelingUpwards = self.ElevatorConstructor.Attributes.TravelingUpwards.Value
|
||||||
|
|
||||||
|
self.TractionRopesConstructor:Update()
|
||||||
|
self.MovingObjectsConstructor:RotatePulleyWheel(TravelingUpwards, CabVelocity.Y)
|
||||||
|
self.MovingObjectsConstructor:RotateRotodials(CabVelocity.Y)
|
||||||
|
end)
|
||||||
|
-- self.ElevatorConstructor.Events.Progression:Connect(function(previousFloor: number, CurrentFloor: number, NextFloor: number)
|
||||||
|
|
||||||
|
-- end)
|
||||||
|
self.ElevatorConstructor.Events.Leveling:Connect(function()
|
||||||
|
self.MovingObjectsConstructor:RotateRelayCogs2Async()
|
||||||
|
end)
|
||||||
|
-- self.ElevatorConstructor.Events.Leveling3Phase:Connect(function()
|
||||||
|
|
||||||
|
-- end)
|
||||||
|
self.ElevatorConstructor.Events.ManualTravelRequested:Connect(function()
|
||||||
|
self.MovingObjectsConstructor:ControllerStartAsync()
|
||||||
|
task.wait(1)
|
||||||
|
self.MovingObjectsConstructor:RotateRelayCogs1Async().Completed:Wait()
|
||||||
|
self.ElevatorConstructor:StartTraveling()
|
||||||
|
end)
|
||||||
|
-- self.ElevatorConstructor.Events.TravelStart:Connect(function()
|
||||||
|
|
||||||
|
-- end)
|
||||||
|
self.ElevatorConstructor.Events.Parked:Connect(function()
|
||||||
|
self.MovingObjectsConstructor:RotateRelayCogs3()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Events:InitButtons()
|
||||||
|
ElevatorEvents(self)
|
||||||
|
|
||||||
|
local ButtonEventsConstructor = ButtonEvents.constructor(self.ElevatorConfig, self.ElevatorConstructor, self.ButtonsConstructor)
|
||||||
|
ButtonEventsConstructor:Events()
|
||||||
|
end
|
||||||
|
|
||||||
|
return Events
|
||||||
@@ -60,9 +60,16 @@ type Constructor_Return_Props = {
|
|||||||
Rotodials: {Instance}
|
Rotodials: {Instance}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LowPassSoundeffects = {
|
||||||
|
SoundGroup: SoundGroup,
|
||||||
|
EqualizerSoundEffect: EqualizerSoundEffect
|
||||||
|
}
|
||||||
|
|
||||||
export type constructor = ClassConstructor
|
export type constructor = ClassConstructor
|
||||||
|
|
||||||
local TS = game:GetService("TweenService")
|
local TS = game:GetService("TweenService")
|
||||||
|
local SS = game:GetService("SoundService")
|
||||||
|
local RandomNew = Random.new()
|
||||||
|
|
||||||
local MovingObjects = {} :: Impl_Constructor
|
local MovingObjects = {} :: Impl_Constructor
|
||||||
MovingObjects.__index = MovingObjects
|
MovingObjects.__index = MovingObjects
|
||||||
@@ -70,7 +77,32 @@ MovingObjects.__index = MovingObjects
|
|||||||
MovingObjects.RotateRotodialsSensitivity = 40
|
MovingObjects.RotateRotodialsSensitivity = 40
|
||||||
MovingObjects.PulleyWheelRotationSensitivity = 2
|
MovingObjects.PulleyWheelRotationSensitivity = 2
|
||||||
|
|
||||||
|
local function LowPassSoundEffects(): LowPassSoundeffects
|
||||||
|
local SoundGroup = Instance.new("SoundGroup") :: SoundGroup
|
||||||
|
SoundGroup.Volume = 1
|
||||||
|
local EqualizerSoundEffect = Instance.new("EqualizerSoundEffect") :: EqualizerSoundEffect
|
||||||
|
EqualizerSoundEffect.HighGain = -15
|
||||||
|
EqualizerSoundEffect.LowGain = 0
|
||||||
|
EqualizerSoundEffect.MidGain = -35
|
||||||
|
|
||||||
|
EqualizerSoundEffect.Parent = SoundGroup
|
||||||
|
SoundGroup.Parent = SS
|
||||||
|
|
||||||
|
return {
|
||||||
|
SoundGroup = SoundGroup,
|
||||||
|
EqualizerSoundEffect = EqualizerSoundEffect
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function SmoothAudioRollin(Audio: Sound, Time: number, Goal: number)
|
||||||
|
TS:Create(Audio, TweenInfo.new(Time, Enum.EasingStyle.Linear), {
|
||||||
|
Volume = Goal
|
||||||
|
}):Play()
|
||||||
|
end
|
||||||
|
|
||||||
function MovingObjects.constructor(TagsConstructor)
|
function MovingObjects.constructor(TagsConstructor)
|
||||||
|
local AudioEffect = LowPassSoundEffects()
|
||||||
|
|
||||||
local PulleyWheel = TagsConstructor:Request("Haughton_PulleyWheel") :: BasePart
|
local PulleyWheel = TagsConstructor:Request("Haughton_PulleyWheel") :: BasePart
|
||||||
|
|
||||||
local Cog2_Row1 = TagsConstructor:Request("Haughton_Cog2_Row1") :: BasePart
|
local Cog2_Row1 = TagsConstructor:Request("Haughton_Cog2_Row1") :: BasePart
|
||||||
@@ -87,7 +119,16 @@ function MovingObjects.constructor(TagsConstructor)
|
|||||||
local Controller_Clicks = TagsConstructor:Request("Haughton_Controller_Clicks") :: Sound
|
local Controller_Clicks = TagsConstructor:Request("Haughton_Controller_Clicks") :: Sound
|
||||||
local Pulley_Moving = TagsConstructor:Request("Haughton_Pulley_Moving") :: Sound
|
local Pulley_Moving = TagsConstructor:Request("Haughton_Pulley_Moving") :: Sound
|
||||||
local Pulley_Start = TagsConstructor:Request("Haughton_Pulley_Start") :: Sound
|
local Pulley_Start = TagsConstructor:Request("Haughton_Pulley_Start") :: Sound
|
||||||
Controller_Hum.Looped = true
|
|
||||||
|
-- Haughton_Relay_Close.SoundGroup = AudioEffect.SoundGroup
|
||||||
|
-- Haughton_Relay_FullOpen.SoundGroup = AudioEffect.SoundGroup
|
||||||
|
-- Haughton_Relay_Open.SoundGroup = AudioEffect.SoundGroup
|
||||||
|
-- Controller_Start.SoundGroup = AudioEffect.SoundGroup
|
||||||
|
-- Controller_Hum.SoundGroup = AudioEffect.SoundGroup
|
||||||
|
-- Controller_End.SoundGroup = AudioEffect.SoundGroup
|
||||||
|
-- Controller_Clicks.SoundGroup = AudioEffect.SoundGroup
|
||||||
|
-- Pulley_Moving.SoundGroup = AudioEffect.SoundGroup
|
||||||
|
-- Pulley_Start.SoundGroup = AudioEffect.SoundGroup
|
||||||
|
|
||||||
local MagnetCog_Row1 = TagsConstructor:Request("Haughton_MagnetCog_Row1") :: BasePart
|
local MagnetCog_Row1 = TagsConstructor:Request("Haughton_MagnetCog_Row1") :: BasePart
|
||||||
local MagnetCog_Row2 = TagsConstructor:Request("Haughton_MagnetCog_Row2") :: BasePart
|
local MagnetCog_Row2 = TagsConstructor:Request("Haughton_MagnetCog_Row2") :: BasePart
|
||||||
@@ -176,10 +217,12 @@ local function ElectricalFlash(Flash: PointLight)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MovingObjects:ControllerStartAsync()
|
function MovingObjects:ControllerStartAsync()
|
||||||
if math.random(1,30) == 1 then
|
if RandomNew:NextInteger(1,30) == 1 then
|
||||||
self.Controller_Start.SoundId = "rbxassetid://108739293674278"
|
self.Controller_Start.SoundId = "rbxassetid://108739293674278"
|
||||||
|
self.Controller_Start.Volume = 1
|
||||||
else
|
else
|
||||||
self.Controller_Start.SoundId = "rbxassetid://75136143926200"
|
self.Controller_Start.SoundId = "rbxassetid://75136143926200"
|
||||||
|
self.Controller_Start.Volume = 1.8
|
||||||
end
|
end
|
||||||
self.Controller_Start:Play()
|
self.Controller_Start:Play()
|
||||||
self.Controller_Start.Ended:Wait()
|
self.Controller_Start.Ended:Wait()
|
||||||
@@ -192,9 +235,13 @@ function MovingObjects:RotateRelayCogs1Async()
|
|||||||
task.wait(.30)
|
task.wait(.30)
|
||||||
RotateRelayCogs(true, false, self.MagnetCog_Row2, self.Cog2_Row2, self.Row2_CounterWeight, self.Row2_Relays)
|
RotateRelayCogs(true, false, self.MagnetCog_Row2, self.Cog2_Row2, self.Row2_CounterWeight, self.Row2_Relays)
|
||||||
task.wait(.30)
|
task.wait(.30)
|
||||||
|
|
||||||
self.Pulley_Start:Play()
|
self.Pulley_Start:Play()
|
||||||
|
SmoothAudioRollin(self.Pulley_Start, 2, 1.8)
|
||||||
|
|
||||||
task.spawn(function()
|
task.spawn(function()
|
||||||
self.Pulley_Start.Ended:Wait()
|
self.Pulley_Start.Ended:Wait()
|
||||||
|
self.Pulley_Start.Volume = 0
|
||||||
self.Pulley_Moving:Play()
|
self.Pulley_Moving:Play()
|
||||||
end)
|
end)
|
||||||
return RotateRelayCogs(true, true, self.MagnetCog_Row4, self.Cog2_Row4, self.Row4_CounterWeight, self.Row4_Relays)
|
return RotateRelayCogs(true, true, self.MagnetCog_Row4, self.Cog2_Row4, self.Row4_CounterWeight, self.Row4_Relays)
|
||||||
@@ -210,7 +257,7 @@ function MovingObjects:RotateRelayCogs2Async()
|
|||||||
RotateRelayCogs(false, true,self.MagnetCog_Row4, self.Cog2_Row4, self.Row4_CounterWeight, self.Row4_Relays)
|
RotateRelayCogs(false, true,self.MagnetCog_Row4, self.Cog2_Row4, self.Row4_CounterWeight, self.Row4_Relays)
|
||||||
ElectricalFlash(self.Row4_Flash)
|
ElectricalFlash(self.Row4_Flash)
|
||||||
self.Pulley_Moving:Stop()
|
self.Pulley_Moving:Stop()
|
||||||
task.wait(2)
|
task.wait(RandomNew:NextNumber(2,4))
|
||||||
self.Controller_Clicks:Play()
|
self.Controller_Clicks:Play()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -226,8 +273,9 @@ function MovingObjects:RotateRelayCogs3()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MovingObjects:RotateRotodials(Elevator_Y_Velocity)
|
function MovingObjects:RotateRotodials(Elevator_Y_Velocity)
|
||||||
|
local rad = math.rad(Elevator_Y_Velocity/MovingObjects.RotateRotodialsSensitivity)
|
||||||
for n: number = 1, #self.Rotodials do
|
for n: number = 1, #self.Rotodials do
|
||||||
(self.Rotodials[n] :: BasePart).CFrame*=CFrame.Angles(math.rad(Elevator_Y_Velocity/MovingObjects.RotateRotodialsSensitivity),0,0)
|
(self.Rotodials[n] :: BasePart).CFrame*=CFrame.Angles(rad,0,0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
56
src/server/main/Elevators/Map/Haughton/TractionRopes.luau
Normal file
56
src/server/main/Elevators/Map/Haughton/TractionRopes.luau
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
--!optimize 2
|
||||||
|
--!native
|
||||||
|
--!strict
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
Update: (self: ClassConstructor) -> ()
|
||||||
|
}
|
||||||
|
|
||||||
|
type Constructor_Fun = (CabRopesObject: BasePart, PulleyRopesObject: BasePart) -> ClassConstructor
|
||||||
|
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
CabRopesObject: BasePart,
|
||||||
|
PulleyRopesObject: BasePart,
|
||||||
|
PulleyCables: {RopeConstraint}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type constructor = ClassConstructor
|
||||||
|
|
||||||
|
local TractionRopes = {} :: Impl_Constructor
|
||||||
|
TractionRopes.__index = TractionRopes
|
||||||
|
|
||||||
|
function TractionRopes.constructor(CabRopesObject, PulleyRopesObject)
|
||||||
|
local PulleyCables = {}
|
||||||
|
local PulleyCablesChildren = PulleyRopesObject:GetChildren()
|
||||||
|
|
||||||
|
for n: number = 1, #PulleyCablesChildren do
|
||||||
|
local Object = PulleyCablesChildren[n] :: Instance
|
||||||
|
if Object:IsA("BasePart") then
|
||||||
|
local Rope = Object:FindFirstChildOfClass("RopeConstraint")
|
||||||
|
if Rope then
|
||||||
|
table.insert(PulleyCables, Rope)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert(#PulleyCables>0, "0 RopeConstraint's were found for an elevator with traction ropes!")
|
||||||
|
|
||||||
|
return setmetatable({
|
||||||
|
CabRopesObject = CabRopesObject,
|
||||||
|
PulleyRopesObject = PulleyRopesObject,
|
||||||
|
PulleyCables = PulleyCables
|
||||||
|
}, TractionRopes)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TractionRopes:Update()
|
||||||
|
local StudLength = (self.PulleyRopesObject.Position-self.CabRopesObject.Position).Magnitude+1
|
||||||
|
for n: number = 1, #self.PulleyCables do
|
||||||
|
self.PulleyCables[n].Length = StudLength
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return TractionRopes
|
||||||
@@ -12,21 +12,29 @@ local Config = require(script:WaitForChild("Config"))
|
|||||||
local Buttons = require(script:WaitForChild("Buttons"))
|
local Buttons = require(script:WaitForChild("Buttons"))
|
||||||
local Leveling = require(script:WaitForChild("Leveling"))
|
local Leveling = require(script:WaitForChild("Leveling"))
|
||||||
local MovingObjects = require(script:WaitForChild("MovingObjects"))
|
local MovingObjects = require(script:WaitForChild("MovingObjects"))
|
||||||
|
local TractionRopes = require(script:WaitForChild("TractionRopes"))
|
||||||
local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags"))
|
local TagsModule = require(MainDir:WaitForChild("Map"):WaitForChild("Load"):WaitForChild("Tags"))
|
||||||
|
|
||||||
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
|
return function(TagsConstructor: TagsModule.TagsConstructor, ButtonTags: TagsModule.ElevatorButtons, LanternTags: TagsModule.Lanterns, LandingDoorTags: TagsModule.LandingTags)
|
||||||
local ElevatorModel = TagsConstructor:Request("Elevator_Haughton") :: Model
|
local ElevatorModel = TagsConstructor:Request("Elevator_Haughton") :: Model
|
||||||
|
local CabRopesObject = TagsConstructor:Request("Haughton_Rope_Cab") :: BasePart
|
||||||
|
local PulleyRopesObject = TagsConstructor:Request("Haughton_Rope_Pulley") :: BasePart
|
||||||
local ElevatorBoxModel = ElevatorModel:WaitForChild("Mover") :: BasePart
|
local ElevatorBoxModel = ElevatorModel:WaitForChild("Mover") :: BasePart
|
||||||
|
|
||||||
local Elevator = InitElevator.constructor(ElevatorBoxModel, Config, Leveling)
|
local Elevator = InitElevator.constructor(ElevatorBoxModel, Config, Leveling)
|
||||||
local MovingObjectsConstructor = MovingObjects.constructor(TagsConstructor)
|
local MovingObjectsConstructor = MovingObjects.constructor(TagsConstructor)
|
||||||
local ButtonsConstructor = Buttons.constructor(Config.Name, ButtonTags, Elevator.Attributes.CurrentFloor)
|
local ButtonsConstructor = Buttons.constructor(Config.Name, ButtonTags, Elevator.Attributes.CurrentFloor)
|
||||||
local EventsConstructor = Events.constructor(Elevator, Config, Elevator.Events, Elevator.Attributes, ButtonsConstructor.Events, ElevatorBoxModel, Leveling, MovingObjectsConstructor)
|
local TractionRopesConstructor = TractionRopes.constructor(CabRopesObject, PulleyRopesObject)
|
||||||
|
local EventsConstructor = Events.constructor(
|
||||||
|
Elevator,
|
||||||
|
Config,
|
||||||
|
ButtonsConstructor,
|
||||||
|
ElevatorBoxModel,
|
||||||
|
Leveling,
|
||||||
|
MovingObjectsConstructor,
|
||||||
|
TractionRopesConstructor
|
||||||
|
)
|
||||||
|
|
||||||
EventsConstructor:Elevator()
|
EventsConstructor:InitButtons()
|
||||||
EventsConstructor:Buttons()
|
|
||||||
ButtonsConstructor:InitForElevator(2, Vector3.new(-.05,0,0))
|
ButtonsConstructor:InitForElevator(2, Vector3.new(-.05,0,0))
|
||||||
|
|
||||||
-- task.wait(3)
|
|
||||||
-- Elevator:RequestLevelAsync(7, "Down")
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ local function GoingUpDirectionToDirectionEnum(CurrentFloor: number, RequestedFl
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function CheckFloorQueue(self: ClassConstructor)
|
local function CheckFloorQueue(self: ClassConstructor)
|
||||||
self.Elevator.AlignPosition.MaxVelocity = 0
|
SmoothVelocity(self, 0, 1)
|
||||||
|
|
||||||
local DirectionToDirectionQueue = self.Attributes.TravelingUpwards.Value and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down
|
local DirectionToDirectionQueue = self.Attributes.TravelingUpwards.Value and self.RelayAlgorithm.FloorQueue.Up or self.RelayAlgorithm.FloorQueue.Down
|
||||||
local DirectionToOppositeDirectionQueue = self.Attributes.TravelingUpwards.Value and self.RelayAlgorithm.FloorQueue.Down or self.RelayAlgorithm.FloorQueue.Up
|
local DirectionToOppositeDirectionQueue = self.Attributes.TravelingUpwards.Value and self.RelayAlgorithm.FloorQueue.Down or self.RelayAlgorithm.FloorQueue.Up
|
||||||
@@ -413,13 +413,14 @@ function Elevator:__TravelToFloorAsync(Level_Int, LEVEL_VEC3_Y_WRAP)
|
|||||||
--Set the elevator's AlignPosition to the floor Y vector
|
--Set the elevator's AlignPosition to the floor Y vector
|
||||||
self.Elevator.AlignPosition.Position = Vector3.new(self.Elevator.AlignPosition.Position.X, LEVEL_VEC3_Y_WRAP.Y, self.Elevator.AlignPosition.Position.Z)
|
self.Elevator.AlignPosition.Position = Vector3.new(self.Elevator.AlignPosition.Position.X, LEVEL_VEC3_Y_WRAP.Y, self.Elevator.AlignPosition.Position.Z)
|
||||||
--Set the elevator's velocity
|
--Set the elevator's velocity
|
||||||
SmoothVelocity(self, self.Elevator.Configuration.MaxVelocity, 3)
|
SmoothVelocity(self, self.Elevator.Configuration.MaxVelocity, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Elevator:RequestLevelAsync(RequestedLevel, Direction)
|
function Elevator:RequestLevelAsync(RequestedLevel, Direction)
|
||||||
local Level = self:GetLevel(RequestedLevel)
|
local Level = self:GetLevel(RequestedLevel)
|
||||||
|
|
||||||
if Level then
|
if Level then
|
||||||
|
--Some patch solution for cab calls
|
||||||
if (RequestedLevel == 1 and Direction == Enums.ElevatorCallDirection.Down) then
|
if (RequestedLevel == 1 and Direction == Enums.ElevatorCallDirection.Down) then
|
||||||
self.ewarnStudio(`Impossible direction requested, Direction={Direction}, RequestedLevel={RequestedLevel}. correcting...`)
|
self.ewarnStudio(`Impossible direction requested, Direction={Direction}, RequestedLevel={RequestedLevel}. correcting...`)
|
||||||
Direction = Enums.ElevatorCallDirection.Up
|
Direction = Enums.ElevatorCallDirection.Up
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
--!optimize 2
|
|
||||||
--!native
|
|
||||||
--!strict
|
|
||||||
|
|
||||||
type RopeTags = {Instance}
|
|
||||||
type Leveling = {number}
|
|
||||||
|
|
||||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
|
||||||
type Impl_Constructor = {
|
|
||||||
__index: Impl_Constructor,
|
|
||||||
constructor: Constructor_Fun,
|
|
||||||
--Class functions
|
|
||||||
Move: (self: ClassConstructor, Offset: number, ElevatorPosition: Vector3) -> (),
|
|
||||||
Stopped: (self: ClassConstructor) -> (),
|
|
||||||
}
|
|
||||||
|
|
||||||
type Constructor_Fun = (RopeTags: RopeTags, ElevatorBox: BasePart, Leveling: Leveling) -> ClassConstructor
|
|
||||||
type Constructor_Return_Props = {
|
|
||||||
Ropes: RopeTags,
|
|
||||||
Leveling: Leveling,
|
|
||||||
BiggestRopeLength: number,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type TractionRopesConstructor = ClassConstructor
|
|
||||||
|
|
||||||
local TractionRopes = {} :: Impl_Constructor
|
|
||||||
TractionRopes.__index = TractionRopes
|
|
||||||
|
|
||||||
function TractionRopes.constructor(RopeTags, ElevatorBox, Leveling)
|
|
||||||
local ArbitraryRopeContact = RopeTags[1].Parent :: BasePart
|
|
||||||
local HighestLevel = Leveling[#Leveling]
|
|
||||||
local BiggestRopeLength = HighestLevel-(ArbitraryRopeContact.Position.Y-HighestLevel)
|
|
||||||
|
|
||||||
return setmetatable({
|
|
||||||
Ropes = RopeTags,
|
|
||||||
Leveling = Leveling,
|
|
||||||
BiggestRopeLength = BiggestRopeLength
|
|
||||||
}, TractionRopes)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TractionRopes:Move(Offset, ElevatorPosition)
|
|
||||||
local l = self.BiggestRopeLength-ElevatorPosition.Y+Offset
|
|
||||||
|
|
||||||
for i: number = 1, #self.Ropes do
|
|
||||||
(self.Ropes[i] :: RopeConstraint).Length = l
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function TractionRopes:Stopped()
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
return TractionRopes
|
|
||||||
@@ -20,20 +20,20 @@ type Impl_Constructor = {
|
|||||||
__index: Impl_Constructor,
|
__index: Impl_Constructor,
|
||||||
constructor: Constructor_Fun,
|
constructor: Constructor_Fun,
|
||||||
--Class functions
|
--Class functions
|
||||||
DecodeCarTag: (self: ClassConstructor, FloorTag: string) -> number?,
|
DecodeCarTag: (self: ClassConstructor, FloorTag: string) -> number?,
|
||||||
CreatePromptButtons: (self: ClassConstructor) -> Tags.ButtonsTree,
|
CreatePromptButtons: (self: ClassConstructor) -> Tags.ButtonsTree,
|
||||||
} & Impl_Static_Props
|
} & Impl_Static_Props
|
||||||
|
|
||||||
type Impl_Static_Props = {
|
type Impl_Static_Props = {
|
||||||
DefaultMaxActivationDistance: number,
|
DefaultMaxActivationDistance: number,
|
||||||
DefaultHoldDuration: number
|
DefaultHoldDuration: number
|
||||||
}
|
}
|
||||||
|
|
||||||
type Constructor_Fun = (ModelButtons: Tags.ElevatorButtons, ElevatorModel: Enums.ElevatorValues) -> ClassConstructor
|
type Constructor_Fun = (ModelButtons: Tags.ElevatorButtons, ElevatorModel: Enums.ElevatorValues) -> ClassConstructor
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
ModelButtons: Tags.ElevatorButtons,
|
ModelButtons: Tags.ElevatorButtons,
|
||||||
ElevatorModel: Enums.ElevatorValues,
|
ElevatorModel: Enums.ElevatorValues,
|
||||||
Buttons: Tags.ButtonsTree
|
Buttons: Tags.ButtonsTree
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ButtonsTagsConstructor = ClassConstructor
|
export type ButtonsTagsConstructor = ClassConstructor
|
||||||
@@ -42,7 +42,7 @@ local ButtonsModule = {} :: Impl_Constructor
|
|||||||
ButtonsModule.__index = ButtonsModule
|
ButtonsModule.__index = ButtonsModule
|
||||||
|
|
||||||
ButtonsModule.DefaultMaxActivationDistance = 3
|
ButtonsModule.DefaultMaxActivationDistance = 3
|
||||||
ButtonsModule.DefaultHoldDuration = .30
|
ButtonsModule.DefaultHoldDuration = 0
|
||||||
|
|
||||||
function ButtonsModule.constructor(ModelButtons, ElevatorModel)
|
function ButtonsModule.constructor(ModelButtons, ElevatorModel)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
@@ -79,7 +79,7 @@ function ButtonsModule:CreatePromptButtons()
|
|||||||
|
|
||||||
local ButtonType: Enums.ButtonValues? = if tonumber(Split[3]) then
|
local ButtonType: Enums.ButtonValues? = if tonumber(Split[3]) then
|
||||||
Enums.Button.Car
|
Enums.Button.Car
|
||||||
elseif Split[3] == "Floor" and Split[4]:match('%d') then
|
elseif Split[3] == "Floor" and Split[4]:match('%d') then --how do i stop opinionated info
|
||||||
Enums.Button.Landing
|
Enums.Button.Landing
|
||||||
elseif Split[2] == "ElevatorButton" then
|
elseif Split[2] == "ElevatorButton" then
|
||||||
Enums.Button.Special
|
Enums.Button.Special
|
||||||
@@ -90,22 +90,29 @@ function ButtonsModule:CreatePromptButtons()
|
|||||||
|
|
||||||
if ButtonType == Enums.Button.Car then
|
if ButtonType == Enums.Button.Car then
|
||||||
--ElevatorButton_1
|
--ElevatorButton_1
|
||||||
|
local ID = tonumber(Split[3])
|
||||||
|
if ID then
|
||||||
|
local Name = (Inst:GetAttribute("Name") :: string?) or tostring(Split[3])
|
||||||
|
Inst:SetAttribute("Name", nil)
|
||||||
|
|
||||||
Prompt.ActionText = tostring(Split[3])
|
Prompt.ActionText = Name
|
||||||
Prompt.ObjectText = "Floor"
|
Prompt.ObjectText = "Floor"
|
||||||
|
self.Buttons[self.ElevatorModel].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
|
ID = ID,
|
||||||
}
|
Name = Name
|
||||||
|
}
|
||||||
|
else
|
||||||
|
warn(`Button ID failed! {Split[1]}: button: "{Split[3]}" did not represent a number, ID={ID}`)
|
||||||
|
end
|
||||||
elseif ButtonType == Enums.Button.Landing then
|
elseif ButtonType == Enums.Button.Landing then
|
||||||
--ElevatorButton_Floor_1_Up
|
--ElevatorButton_Floor_1_Up
|
||||||
|
|
||||||
local Name = tostring(Split[5])
|
local Name = tostring(Split[5])
|
||||||
Prompt.ActionText = `Send Elevator {Name}`
|
Prompt.ActionText = `Send Elevator {Name}`
|
||||||
Prompt.ObjectText = `Floor {tostring(Split[4])}`
|
Prompt.ObjectText = `Floor {tostring(Split[4])}`
|
||||||
|
|
||||||
self.Buttons[self.ElevatorModel].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,
|
||||||
@@ -118,7 +125,6 @@ function ButtonsModule:CreatePromptButtons()
|
|||||||
local Name = tostring(Split[3])
|
local Name = tostring(Split[3])
|
||||||
Prompt.ActionText = Name
|
Prompt.ActionText = Name
|
||||||
Prompt.ObjectText = "Elevator"
|
Prompt.ObjectText = "Elevator"
|
||||||
|
|
||||||
self.Buttons[self.ElevatorModel].Special[`{Split[2]}_{Split[3]}`] = {
|
self.Buttons[self.ElevatorModel].Special[`{Split[2]}_{Split[3]}`] = {
|
||||||
Inst = Inst,
|
Inst = Inst,
|
||||||
Prompt = Prompt,
|
Prompt = Prompt,
|
||||||
@@ -131,7 +137,6 @@ function ButtonsModule:CreatePromptButtons()
|
|||||||
Prompt.Exclusivity = Enum.ProximityPromptExclusivity.OneGlobally --why does this not work...
|
Prompt.Exclusivity = Enum.ProximityPromptExclusivity.OneGlobally --why does this not work...
|
||||||
Prompt.ActionText = "Activate"
|
Prompt.ActionText = "Activate"
|
||||||
Prompt.ObjectText = "Relay"
|
Prompt.ObjectText = "Relay"
|
||||||
|
|
||||||
self.Buttons[self.ElevatorModel].Relays[`{Split[2]}_{Split[3]}`] = {
|
self.Buttons[self.ElevatorModel].Relays[`{Split[2]}_{Split[3]}`] = {
|
||||||
Inst = Inst,
|
Inst = Inst,
|
||||||
Prompt = Prompt,
|
Prompt = Prompt,
|
||||||
|
|||||||
@@ -87,11 +87,11 @@ function Lights:Functionality(DefinedProperties)
|
|||||||
ClickSound.SoundId = LightProperties.LightSwitchActivateSoundId
|
ClickSound.SoundId = LightProperties.LightSwitchActivateSoundId
|
||||||
ClickSound.Parent = self.Switch
|
ClickSound.Parent = self.Switch
|
||||||
|
|
||||||
LightAddresses.ColorActivated = self.Switch:GetAttribute("Activated")
|
LightAddresses.ColorActivated = self.Switch:GetAttribute("Activated") :: Color3?
|
||||||
LightAddresses.ColorDeactivated = self.Switch:GetAttribute("Deactivated")
|
LightAddresses.ColorDeactivated = self.Switch:GetAttribute("Deactivated") :: Color3?
|
||||||
LightAddresses.ActivatedMaterial = self.Switch:GetAttribute("ActivatedMaterial")
|
LightAddresses.ActivatedMaterial = self.Switch:GetAttribute("ActivatedMaterial") :: string?
|
||||||
LightAddresses.DeactivatedMaterial = self.Switch:GetAttribute("DeactivatedMaterial")
|
LightAddresses.DeactivatedMaterial = self.Switch:GetAttribute("DeactivatedMaterial") :: string?
|
||||||
LightAddresses.Enabled = self.Switch:GetAttribute("Enabled")
|
LightAddresses.Enabled = self.Switch:GetAttribute("Enabled") :: boolean?
|
||||||
LightAddresses.Attachment = Attachment
|
LightAddresses.Attachment = Attachment
|
||||||
LightAddresses.Prompt = Prompt
|
LightAddresses.Prompt = Prompt
|
||||||
LightAddresses.ClickSound = ClickSound
|
LightAddresses.ClickSound = ClickSound
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ type Impl_Constructor = {
|
|||||||
|
|
||||||
type Impl_Static_Props = {
|
type Impl_Static_Props = {
|
||||||
Decoders: {
|
Decoders: {
|
||||||
CarTag: (FloorTag: string) -> (number | string)?,
|
CarTag: (FloorTag: string) -> number?,
|
||||||
HallTag: (FloorTag: string) -> number?
|
HallTag: (FloorTag: string) -> number?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ export type ButtonDictionary = {
|
|||||||
[string]: ButtonProperties
|
[string]: ButtonProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RelayProperties = ButtonProperties & {
|
export type RelayProperties = Properties & {
|
||||||
Unique: boolean,
|
Unique: boolean,
|
||||||
ActiveState: boolean,
|
ActiveState: boolean,
|
||||||
PhysicalSound: {
|
PhysicalSound: {
|
||||||
@@ -114,24 +114,25 @@ export type RelayDictionary = {
|
|||||||
export type ButtonsTree = {
|
export type ButtonsTree = {
|
||||||
[Enums.ElevatorValues]: {
|
[Enums.ElevatorValues]: {
|
||||||
Car: ButtonDictionary,
|
Car: ButtonDictionary,
|
||||||
Landing: ButtonDictionary,
|
Landing: Properties,
|
||||||
Special: ButtonDictionary,
|
Special: Properties,
|
||||||
Relays: RelayDictionary
|
Relays: RelayDictionary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ButtonProperties = {
|
export type ButtonProperties = {
|
||||||
Inst: Instance?,
|
|
||||||
Prompt: ProximityPrompt?,
|
|
||||||
Attachment: Attachment?,
|
|
||||||
Name: string?
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ButtonPropertiesSafe = {
|
|
||||||
Inst: Instance,
|
Inst: Instance,
|
||||||
Prompt: ProximityPrompt,
|
Prompt: ProximityPrompt,
|
||||||
Attachment: Attachment,
|
Attachment: Attachment,
|
||||||
Name: string?
|
ID: number,
|
||||||
|
Name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Properties = {
|
||||||
|
Inst: Instance,
|
||||||
|
Prompt: ProximityPrompt,
|
||||||
|
Attachment: Attachment,
|
||||||
|
Name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ExportedTags = {
|
export type ExportedTags = {
|
||||||
@@ -154,9 +155,8 @@ Tags.__index = Tags
|
|||||||
|
|
||||||
Tags.Decoders = {
|
Tags.Decoders = {
|
||||||
CarTag = function(FloorTag)
|
CarTag = function(FloorTag)
|
||||||
local Match = FloorTag:match('%w+$')
|
local Match = FloorTag:match('%d+$')
|
||||||
|
return Match and tonumber(Match)
|
||||||
return Match and (tonumber(Match) or tostring(Match))
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
HallTag = function(FloorTag)
|
HallTag = function(FloorTag)
|
||||||
@@ -201,8 +201,6 @@ function Tags:Nuke()
|
|||||||
warn("☢️ nuked all in-game tags. Left-over tags="..table.concat(CS:GetAllTags(), ", "))
|
warn("☢️ nuked all in-game tags. Left-over tags="..table.concat(CS:GetAllTags(), ", "))
|
||||||
end
|
end
|
||||||
|
|
||||||
--Parsers:
|
|
||||||
|
|
||||||
function Tags:__ElevatorLanterns()
|
function Tags:__ElevatorLanterns()
|
||||||
local Lanterns: LanternsTree = {}
|
local Lanterns: LanternsTree = {}
|
||||||
|
|
||||||
|
|||||||
17
src/server/main/Types/Enums/Doors.luau
Normal file
17
src/server/main/Types/Enums/Doors.luau
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
--!optimize 2
|
||||||
|
--!native
|
||||||
|
--!strict
|
||||||
|
|
||||||
|
local DoorEnums = {}
|
||||||
|
|
||||||
|
export type DoorEnumValues = typeof(DoorEnums.Door)
|
||||||
|
export type SingleSpeed = "SingleSpeed"
|
||||||
|
export type DoubleSpeed = "DoubleSpeed"
|
||||||
|
export type TripleSpeed = "TripleSpeed"
|
||||||
|
DoorEnums.Door = {
|
||||||
|
SingleSpeed = "SingleSpeed" :: SingleSpeed,
|
||||||
|
DoubleSpeed = "DoubleSpeed" :: DoubleSpeed,
|
||||||
|
TripleSpeed = "TripleSpeed" :: TripleSpeed
|
||||||
|
}
|
||||||
|
|
||||||
|
return DoorEnums
|
||||||
@@ -51,7 +51,8 @@ export type EnumElevatorCallDirections = typeof(Enums.ElevatorCallDirection)
|
|||||||
export type ElevatorCallDirectionValues = typeof(Enums.ElevatorCallDirection.Up) | typeof(Enums.ElevatorCallDirection.Down)
|
export type ElevatorCallDirectionValues = typeof(Enums.ElevatorCallDirection.Up) | typeof(Enums.ElevatorCallDirection.Down)
|
||||||
Enums.ElevatorCallDirection = {
|
Enums.ElevatorCallDirection = {
|
||||||
Up = "Up" :: "Up",
|
Up = "Up" :: "Up",
|
||||||
Down = "Down" :: "Down"
|
Down = "Down" :: "Down",
|
||||||
|
Cab = "Cab" :: "Cab"
|
||||||
}
|
}
|
||||||
|
|
||||||
return Enums
|
return Enums
|
||||||
|
|||||||
Reference in New Issue
Block a user