From 4c3aaac0d130bd7263ff668b94296d628080d00f Mon Sep 17 00:00:00 2001 From: tensorunit Date: Tue, 26 Mar 2024 22:01:25 -0400 Subject: [PATCH] need a serial loop function for everything and pieplate selector module --- sourcemap.json | 2 +- src/server/main/Elevators/Mover.lua | 7 ++- src/server/main/Elevators/Otis1960/init.lua | 53 +++++++++-------- src/server/main/Elevators/TractionRopes.lua | 66 +++++++++++++++++++++ 4 files changed, 99 insertions(+), 29 deletions(-) create mode 100644 src/server/main/Elevators/TractionRopes.lua diff --git a/sourcemap.json b/sourcemap.json index a773dc1..dbe8b77 100644 --- a/sourcemap.json +++ b/sourcemap.json @@ -1 +1 @@ -{"name":"ElevatorGame","className":"DataModel","filePaths":["default.project.json"],"children":[{"name":"ReplicatedFirst","className":"ReplicatedFirst","children":[{"name":"intro","className":"LocalScript","filePaths":["src/load/intro/init.client.lua"],"children":[{"name":"IntroGui","className":"ModuleScript","filePaths":["src/load/intro/IntroGui.lua"]}]}]},{"name":"ReplicatedStorage","className":"ReplicatedStorage","children":[{"name":"AlgebraEasings","className":"ModuleScript","filePaths":["src/shared/AlgebraEasings.lua"]},{"name":"Client","className":"Folder","children":[{"name":"Camera","className":"ModuleScript","filePaths":["src/shared/Client/Camera.lua"]},{"name":"KeyBinds","className":"ModuleScript","filePaths":["src/shared/Client/KeyBinds.lua"]}]},{"name":"Delta","className":"ModuleScript","filePaths":["src/shared/Delta.lua"]},{"name":"Server","className":"Folder","children":[{"name":"holder","className":"ModuleScript","filePaths":["src/shared/Server/holder.lua"]}]},{"name":"String","className":"ModuleScript","filePaths":["src/shared/String.lua"]},{"name":"Tags","className":"ModuleScript","filePaths":["src/shared/Tags.lua"]},{"name":"Tween","className":"ModuleScript","filePaths":["src/shared/Tween.lua"]}]},{"name":"ServerScriptService","className":"ServerScriptService","children":[{"name":"rapid-Server","className":"Actor","children":[{"name":"main","className":"Script","filePaths":["src/server/main/init.server.lua"],"children":[{"name":"EditorEntities","className":"ModuleScript","filePaths":["src/server/main/EditorEntities.lua"]},{"name":"Elevators","className":"Folder","children":[{"name":"Buttons","className":"ModuleScript","filePaths":["src/server/main/Elevators/Buttons.lua"]},{"name":"Enums","className":"ModuleScript","filePaths":["src/server/main/Elevators/Enums.lua"]},{"name":"Floors","className":"ModuleScript","filePaths":["src/server/main/Elevators/Floors.lua"]},{"name":"Mover","className":"ModuleScript","filePaths":["src/server/main/Elevators/Mover.lua"]},{"name":"Otis1960","className":"ModuleScript","filePaths":["src/server/main/Elevators/Otis1960/init.lua"],"children":[{"name":"Doors","className":"ModuleScript","filePaths":["src/server/main/Elevators/Otis1960/Doors.lua"]},{"name":"Leveling","className":"ModuleScript","filePaths":["src/server/main/Elevators/Otis1960/Leveling.lua"]}]}]},{"name":"Lighting","className":"ModuleScript","filePaths":["src/server/main/Lighting/init.lua"]},{"name":"StarterPlayer","className":"ModuleScript","filePaths":["src/server/main/StarterPlayer.lua"]},{"name":"Workspace","className":"ModuleScript","filePaths":["src/server/main/Workspace.lua"]}]}]}]},{"name":"StarterPlayer","className":"StarterPlayer","children":[{"name":"StarterCharacterScripts","className":"StarterCharacterScripts","children":[{"name":"rapid-CharacterRoot","className":"Actor","children":[{"name":"Client","className":"LocalScript","filePaths":["src/client/Character/Client/init.client.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/client/Character/Client/Actions.lua"]},{"name":"Camera","className":"ModuleScript","filePaths":["src/client/Character/Client/Camera/init.lua"],"children":[{"name":"Bobbing","className":"ModuleScript","filePaths":["src/client/Character/Client/Camera/Bobbing.lua"]}]},{"name":"Humanoid","className":"ModuleScript","filePaths":["src/client/Character/Client/Humanoid.lua"]},{"name":"HumanoidRootPart","className":"ModuleScript","filePaths":["src/client/Character/Client/HumanoidRootPart.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/client/Character/Client/SpineKinematics.lua"]}]},{"name":"Server","className":"Script","filePaths":["src/client/Character/Server/init.server.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/client/Character/Server/Actions.lua"]},{"name":"Flashlight","className":"ModuleScript","filePaths":["src/client/Character/Server/Flashlight.lua"]},{"name":"Shadows","className":"ModuleScript","filePaths":["src/client/Character/Server/Shadows.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/client/Character/Server/SpineKinematics.lua"]}]}]}]},{"name":"StarterPlayerScripts","className":"StarterPlayerScripts","children":[{"name":"rapid-PlayerRoot","className":"Actor","children":[{"name":"Player","className":"LocalScript","filePaths":["src/client/Player/init.client.lua"],"children":[{"name":"CoreGuis","className":"ModuleScript","filePaths":["src/client/Player/CoreGuis.lua"]},{"name":"GuiService","className":"ModuleScript","filePaths":["src/client/Player/GuiService.lua"]},{"name":"Mouse","className":"ModuleScript","filePaths":["src/client/Player/Mouse.lua"]},{"name":"UI","className":"Folder","children":[{"name":"Crosshair","className":"ModuleScript","filePaths":["src/client/Player/UI/Crosshair.lua"]},{"name":"Health","className":"ModuleScript","filePaths":["src/client/Player/UI/Health.lua"]},{"name":"Vignette","className":"ModuleScript","filePaths":["src/client/Player/UI/Vignette.lua"]}]}]}]}]}]}]} \ No newline at end of file +{"name":"ElevatorGame","className":"DataModel","filePaths":["default.project.json"],"children":[{"name":"ReplicatedFirst","className":"ReplicatedFirst","children":[{"name":"intro","className":"LocalScript","filePaths":["src/load\\intro\\init.client.lua"],"children":[{"name":"IntroGui","className":"ModuleScript","filePaths":["src/load\\intro\\IntroGui.lua"]}]}]},{"name":"ReplicatedStorage","className":"ReplicatedStorage","children":[{"name":"AlgebraEasings","className":"ModuleScript","filePaths":["src/shared\\AlgebraEasings.lua"]},{"name":"Client","className":"Folder","children":[{"name":"Camera","className":"ModuleScript","filePaths":["src/shared\\Client\\Camera.lua"]},{"name":"KeyBinds","className":"ModuleScript","filePaths":["src/shared\\Client\\KeyBinds.lua"]}]},{"name":"Delta","className":"ModuleScript","filePaths":["src/shared\\Delta.lua"]},{"name":"Server","className":"Folder","children":[{"name":"holder","className":"ModuleScript","filePaths":["src/shared\\Server\\holder.lua"]}]},{"name":"String","className":"ModuleScript","filePaths":["src/shared\\String.lua"]},{"name":"Tags","className":"ModuleScript","filePaths":["src/shared\\Tags.lua"]},{"name":"Tween","className":"ModuleScript","filePaths":["src/shared\\Tween.lua"]}]},{"name":"ServerScriptService","className":"ServerScriptService","children":[{"name":"rapid-Server","className":"Actor","children":[{"name":"main","className":"Script","filePaths":["src/server\\main\\init.server.lua"],"children":[{"name":"EditorEntities","className":"ModuleScript","filePaths":["src/server\\main\\EditorEntities.lua"]},{"name":"Elevators","className":"Folder","children":[{"name":"Buttons","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Buttons.lua"]},{"name":"Enums","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Enums.lua"]},{"name":"Floors","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Floors.lua"]},{"name":"Mover","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Mover.lua"]},{"name":"Otis1960","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\init.lua"],"children":[{"name":"Doors","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\Doors.lua"]},{"name":"Leveling","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\Otis1960\\Leveling.lua"]}]},{"name":"TractionRopes","className":"ModuleScript","filePaths":["src/server\\main\\Elevators\\TractionRopes.lua"]}]},{"name":"Lighting","className":"ModuleScript","filePaths":["src/server\\main\\Lighting\\init.lua"]},{"name":"StarterPlayer","className":"ModuleScript","filePaths":["src/server\\main\\StarterPlayer.lua"]},{"name":"Workspace","className":"ModuleScript","filePaths":["src/server\\main\\Workspace.lua"]}]}]}]},{"name":"StarterPlayer","className":"StarterPlayer","children":[{"name":"StarterCharacterScripts","className":"StarterCharacterScripts","children":[{"name":"rapid-CharacterRoot","className":"Actor","children":[{"name":"Client","className":"LocalScript","filePaths":["src/client/Character\\Client\\init.client.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/client/Character\\Client\\Actions.lua"]},{"name":"Camera","className":"ModuleScript","filePaths":["src/client/Character\\Client\\Camera\\init.lua"],"children":[{"name":"Bobbing","className":"ModuleScript","filePaths":["src/client/Character\\Client\\Camera\\Bobbing.lua"]}]},{"name":"Humanoid","className":"ModuleScript","filePaths":["src/client/Character\\Client\\Humanoid.lua"]},{"name":"HumanoidRootPart","className":"ModuleScript","filePaths":["src/client/Character\\Client\\HumanoidRootPart.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/client/Character\\Client\\SpineKinematics.lua"]}]},{"name":"Server","className":"Script","filePaths":["src/client/Character\\Server\\init.server.lua"],"children":[{"name":"Actions","className":"ModuleScript","filePaths":["src/client/Character\\Server\\Actions.lua"]},{"name":"Flashlight","className":"ModuleScript","filePaths":["src/client/Character\\Server\\Flashlight.lua"]},{"name":"Shadows","className":"ModuleScript","filePaths":["src/client/Character\\Server\\Shadows.lua"]},{"name":"SpineKinematics","className":"ModuleScript","filePaths":["src/client/Character\\Server\\SpineKinematics.lua"]}]}]}]},{"name":"StarterPlayerScripts","className":"StarterPlayerScripts","children":[{"name":"rapid-PlayerRoot","className":"Actor","children":[{"name":"Player","className":"LocalScript","filePaths":["src/client/Player\\init.client.lua"],"children":[{"name":"CoreGuis","className":"ModuleScript","filePaths":["src/client/Player\\CoreGuis.lua"]},{"name":"GuiService","className":"ModuleScript","filePaths":["src/client/Player\\GuiService.lua"]},{"name":"Mouse","className":"ModuleScript","filePaths":["src/client/Player\\Mouse.lua"]},{"name":"UI","className":"Folder","children":[{"name":"Crosshair","className":"ModuleScript","filePaths":["src/client/Player\\UI\\Crosshair.lua"]},{"name":"Health","className":"ModuleScript","filePaths":["src/client/Player\\UI\\Health.lua"]},{"name":"Vignette","className":"ModuleScript","filePaths":["src/client/Player\\UI\\Vignette.lua"]}]}]}]}]}]}]} \ No newline at end of file diff --git a/src/server/main/Elevators/Mover.lua b/src/server/main/Elevators/Mover.lua index 12e6de7..8586f45 100644 --- a/src/server/main/Elevators/Mover.lua +++ b/src/server/main/Elevators/Mover.lua @@ -2,7 +2,7 @@ --!native --!strict -return function(ElevatorBox: BasePart, StartPosition: Vector3): (Attachment, AlignPosition, AlignOrientation) +return function(ElevatorBox: BasePart, StartPosition: Vector3, Responsiveness: number, MaxVelocity: number): (Attachment, AlignPosition, AlignOrientation) local BoxAttachment = Instance.new("Attachment") BoxAttachment.Parent = ElevatorBox @@ -13,10 +13,11 @@ return function(ElevatorBox: BasePart, StartPosition: Vector3): (Attachment, Ali BoxAlignPosition.Position = StartPosition -- BoxAlignPosition.RigidityEnabled = true -- Lines below are disabled with RigidityEnabled true - BoxAlignPosition.Responsiveness = 5 - BoxAlignPosition.MaxVelocity = 10 + BoxAlignPosition.Responsiveness = Responsiveness + BoxAlignPosition.MaxVelocity = MaxVelocity -- BoxAlignPosition.Parent = ElevatorBox + local BoxAlignOrientation = Instance.new("AlignOrientation") BoxAlignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment BoxAlignOrientation.Attachment0 = BoxAttachment diff --git a/src/server/main/Elevators/Otis1960/init.lua b/src/server/main/Elevators/Otis1960/init.lua index 4228102..fe640bc 100644 --- a/src/server/main/Elevators/Otis1960/init.lua +++ b/src/server/main/Elevators/Otis1960/init.lua @@ -15,6 +15,7 @@ local Doors = require(script:WaitForChild("Doors")) local Enums = require(Elevators:WaitForChild("Enums")) local ElevatorMover = require(Elevators:WaitForChild("Mover")) local ButtonTags = require(Elevators:WaitForChild("Buttons")) +local TractionRopes = require(Elevators:WaitForChild("TractionRopes")) type Tags = TagsModule.ExportedTags @@ -28,14 +29,15 @@ type Impl_Constructor = { } & Impl_Static_Props type Impl_Static_Props = { - Moving: boolean + Moving: boolean, + Responsiveness: number, + MaxVelocity: number } type Constructor_Fun = (Tags: Tags) -> ClassConstructor type Constructor_Return_Props = { Tags: Tags, - ElevatorBox_1960: BasePart, - ElevatorBox: BasePart, + ElevatorBox_1960: UnionOperation, ElevatorDoor1: BasePart, ElevatorDoor2: BasePart, ElevatorDoorSensor: Folder, @@ -44,12 +46,18 @@ type Constructor_Return_Props = { BoxAlignPosition: AlignPosition, BoxAlignOrientation: AlignOrientation, ElevatorDoors: Doors.DoorConstructor, + Ropes: {Instance}, + TractionRopes: TractionRopes.TractionRopesConstructor, + PiePlateSelector: UnionOperation, + __RopeConnection: RBXScriptConnection? } local Otis1960 = {} :: Impl_Constructor Otis1960.__index = Otis1960 Otis1960.Moving = false +Otis1960.Responsiveness = 50 +Otis1960.MaxVelocity = 10 local function ButtonPress(Button: BasePart, Activated: boolean) task.spawn(function() @@ -83,7 +91,7 @@ local function HookButtons(self: ClassConstructor, ButtonsConstructor: ButtonTag ButtonsConstructor:HookPromptButtonsGroup(ButtonTree.Prompt, ButtonTree.Inst, function(_Player: Player) if DecodedFloor then - ButtonTree.Prompt.Enabled = false + --ButtonTree.Prompt.Enabled = false ButtonPress(ButtonTree.Inst, false) self:GoToLevel(DecodedFloor) @@ -112,16 +120,21 @@ end function Otis1960.constructor(Tags) local self = {} :: Constructor_Return_Props self.Tags = Tags - self.ElevatorBox_1960 = Tags.ElevatorMover_1960 :: BasePart - self.ElevatorBox = Tags.ElevatorMover_1960 :: BasePart - self.ElevatorDoor1 = Tags.ElevatorDoor_1960_1 :: BasePart - self.ElevatorDoor2 = Tags.ElevatorDoor_1960_2 :: BasePart - self.ElevatorDoorSensor = Tags.ElevatorDoor_Sensor_1960 :: Folder - self.ProximityButtons = Tags.ProximityElevatorButton :: {Instance} + self.ElevatorBox_1960 = Tags.ElevatorMover_1960 :: UnionOperation + self.ElevatorDoor1 = Tags.ElevatorDoor_1960_1 :: BasePart + self.ElevatorDoor2 = Tags.ElevatorDoor_1960_2 :: BasePart + self.ElevatorDoorSensor = Tags.ElevatorDoor_Sensor_1960 :: Folder + self.ProximityButtons = Tags.ProximityElevatorButton :: {Instance} + self.Ropes = Tags["1960_ElevatorPulleyRope"] :: {Instance} + self.PiePlateSelector = Tags.Otis1960_PiePlateSelector :: UnionOperation - self.BoxAttachment, self.BoxAlignPosition, self.BoxAlignOrientation = ElevatorMover(self.ElevatorBox_1960, self.ElevatorBox_1960.Position) - self.ElevatorDoors = Doors.constructor(self.ElevatorBox, self.ElevatorDoor1, self.ElevatorDoor2, self.ElevatorDoorSensor) + self.BoxAttachment, + self.BoxAlignPosition, + self.BoxAlignOrientation = ElevatorMover(self.ElevatorBox_1960, self.ElevatorBox_1960.Position, Otis1960.Responsiveness, Otis1960.MaxVelocity) + self.ElevatorDoors = Doors.constructor(self.ElevatorBox_1960, self.ElevatorDoor1, self.ElevatorDoor2, self.ElevatorDoorSensor) + self.TractionRopes = TractionRopes.constructor(self.Ropes, self.ElevatorBox_1960, Leveling) + --Buttons local ButtonsConstructor = ButtonTags.constructor(Tags, Enums.Elevator.Otis1960) local Otis1960_Buttons = ButtonsConstructor:CreatePromptButtons() @@ -134,20 +147,10 @@ function Otis1960.constructor(Tags) return ClassConstructor end -local BiggestRopeLength = Leveling[#Leveling]-2 - function Otis1960:__MoveFloors(Level) - local ElevatorBoxCurrentPos = self.ElevatorBox.Position - - local RopeConnection = RS.Heartbeat:Connect(function(_dt) - local Ropes = self.Tags["1960_ElevatorPulleyRope"] :: {Instance} - - for i: number = 1, #Ropes do - (Ropes[i] :: RopeConstraint).Length = (BiggestRopeLength-self.ElevatorBox.Position.Y)*10 - print((Ropes[i] :: RopeConstraint).Length) - end - end) - + local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position + self.TractionRopes:Moving(Level, 26) + self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, Level, ElevatorBoxCurrentPos.Z) end diff --git a/src/server/main/Elevators/TractionRopes.lua b/src/server/main/Elevators/TractionRopes.lua new file mode 100644 index 0000000..3f75e45 --- /dev/null +++ b/src/server/main/Elevators/TractionRopes.lua @@ -0,0 +1,66 @@ +--!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 + Moving: (self: ClassConstructor, Level: number, Offset: number) -> (), + Stopped: (self: ClassConstructor) -> (), +} + +type Constructor_Fun = (RopeTags: RopeTags, ElevatorBox: UnionOperation, Leveling: Leveling) -> ClassConstructor +type Constructor_Return_Props = { + Ropes: RopeTags, + ElevatorBox: UnionOperation, + Leveling: Leveling, + BiggestRopeLength: number, + __RopeConnection: RBXScriptConnection? +} + +export type TractionRopesConstructor = ClassConstructor + +local TractionRopes = {} :: Impl_Constructor +TractionRopes.__index = TractionRopes + +local RS: RunService = game:GetService("RunService") + +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, + ElevatorBox = ElevatorBox, + Leveling = Leveling, + BiggestRopeLength = BiggestRopeLength + }, TractionRopes) +end + +function TractionRopes:Moving(Level, Offset) + if self.__RopeConnection then + self.__RopeConnection:Disconnect() + end + self.__RopeConnection = RS.Heartbeat:Connect(function(_dt) + local Elevator = self.ElevatorBox + local ElevatorPosition = Elevator.Position + local l = self.BiggestRopeLength-ElevatorPosition.Y+Offset + + for i: number = 1, #self.Ropes do + (self.Ropes[i] :: RopeConstraint).Length = l + end + --print(Level-ElevatorPosition.Y) + end) +end + +function TractionRopes:Stopped() + +end + +return TractionRopes \ No newline at end of file