mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
Spinning objects
This commit is contained in:
@@ -76,7 +76,7 @@ function StudioEntities.indexAll(enabled: boolean)
|
|||||||
local Case: HideEditor = EditorEntities[Item.Name]
|
local Case: HideEditor = EditorEntities[Item.Name]
|
||||||
if Case then
|
if Case then
|
||||||
table.insert(StudioEntities.IndexedEntities, Item)
|
table.insert(StudioEntities.IndexedEntities, Item)
|
||||||
Case(Item, enabled)
|
Case(Item :: BasePart | Folder, enabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
if Item:IsA("BasePart") then
|
if Item:IsA("BasePart") then
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ local RS: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|||||||
local TagsModule = require(RS:WaitForChild("Tags"))
|
local TagsModule = require(RS:WaitForChild("Tags"))
|
||||||
local Enums = require(Elevators:WaitForChild("Enums"))
|
local Enums = require(Elevators:WaitForChild("Enums"))
|
||||||
|
|
||||||
type Tags = TagsModule.ExportedTags
|
type TagsConstructor = TagsModule.TagsConstructor
|
||||||
|
type TagProduct = TagsModule.TagProduct
|
||||||
type HumanoidRootPart = BasePart
|
type HumanoidRootPart = BasePart
|
||||||
type PromptCallback = (Player: Player) -> ()
|
type PromptCallback = (Player: Player) -> ()
|
||||||
|
|
||||||
@@ -30,9 +31,9 @@ type Impl_Static_Props = {
|
|||||||
ButtonEnum: any
|
ButtonEnum: any
|
||||||
}
|
}
|
||||||
|
|
||||||
type Constructor_Fun = (Tags: Tags, Model: string) -> ClassConstructor
|
type Constructor_Fun = (TagsConstructor: TagsConstructor, Model: string) -> ClassConstructor
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
Tags: Tags,
|
Tags: TagsConstructor,
|
||||||
Model: string,
|
Model: string,
|
||||||
Buttons: ButtonsTree
|
Buttons: ButtonsTree
|
||||||
}
|
}
|
||||||
@@ -53,9 +54,9 @@ export type ButtonsConstructor = ClassConstructor
|
|||||||
local ButtonsModule = {} :: Impl_Constructor
|
local ButtonsModule = {} :: Impl_Constructor
|
||||||
ButtonsModule.__index = ButtonsModule
|
ButtonsModule.__index = ButtonsModule
|
||||||
|
|
||||||
function ButtonsModule.constructor(Tags, Model)
|
function ButtonsModule.constructor(TagsConstructor, Model)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
Tags = Tags,
|
Tags = TagsConstructor,
|
||||||
Model = Model,
|
Model = Model,
|
||||||
Buttons = {
|
Buttons = {
|
||||||
Landing = {},
|
Landing = {},
|
||||||
@@ -76,7 +77,7 @@ end
|
|||||||
function ButtonsModule:Get()
|
function ButtonsModule:Get()
|
||||||
local Buttons: GetButtons = {}
|
local Buttons: GetButtons = {}
|
||||||
|
|
||||||
for TagName: string, Inst: Instance | {Instance} in self.Tags do
|
for TagName: string, Inst: TagProduct in self.Tags.__export do
|
||||||
local Split = TagName:split('_')
|
local Split = TagName:split('_')
|
||||||
if Split[1] == self.Model and (Split[2] == "ElevatorButton" or Split[2] == "RelayButton") then
|
if Split[1] == self.Model and (Split[2] == "ElevatorButton" or Split[2] == "RelayButton") then
|
||||||
if typeof(Inst) == "Instance" then
|
if typeof(Inst) == "Instance" then
|
||||||
|
|||||||
@@ -5,9 +5,10 @@
|
|||||||
|
|
||||||
local Enums = {}
|
local Enums = {}
|
||||||
|
|
||||||
export type EnumValue = typeof(Enums.Button)
|
export type EnumValue = EnumButton | EnumButtonTree | EnumElevator
|
||||||
| typeof(Enums.ButtonTree)
|
export type EnumButton = typeof(Enums.Button)
|
||||||
| typeof(Enums.Elevator)
|
export type EnumButtonTree = typeof(Enums.ButtonTree)
|
||||||
|
export type EnumElevator = typeof(Enums.Elevator)
|
||||||
|
|
||||||
Enums.Button = {
|
Enums.Button = {
|
||||||
Car = "CarButton" :: "CarButton",
|
Car = "CarButton" :: "CarButton",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|||||||
local RS: RunService = game:GetService("RunService")
|
local RS: RunService = game:GetService("RunService")
|
||||||
|
|
||||||
local TagsModule = require(Storage:WaitForChild("Tags"))
|
local TagsModule = require(Storage:WaitForChild("Tags"))
|
||||||
|
local Easings = require(Storage:WaitForChild("AlgebraEasings"))
|
||||||
|
|
||||||
local Leveling = require(script:WaitForChild("Leveling"))
|
local Leveling = require(script:WaitForChild("Leveling"))
|
||||||
local Doors = require(script:WaitForChild("Doors"))
|
local Doors = require(script:WaitForChild("Doors"))
|
||||||
@@ -19,13 +20,14 @@ local ButtonTags = require(Elevators:WaitForChild("Buttons"))
|
|||||||
local TractionRopes = require(Elevators:WaitForChild("TractionRopes"))
|
local TractionRopes = require(Elevators:WaitForChild("TractionRopes"))
|
||||||
|
|
||||||
type Tags = TagsModule.ExportedTags
|
type Tags = TagsModule.ExportedTags
|
||||||
|
type TagsConstructor = TagsModule.TagsConstructor
|
||||||
|
|
||||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
type Impl_Constructor = {
|
type Impl_Constructor = {
|
||||||
__index: Impl_Constructor,
|
__index: Impl_Constructor,
|
||||||
constructor: Constructor_Fun,
|
constructor: Constructor_Fun,
|
||||||
--Class functions
|
--Class functions
|
||||||
__MoveFloors: (self: ClassConstructor, Level: number) -> (),
|
_MoveFloors: (self: ClassConstructor, Level: number) -> (),
|
||||||
GoToLevel: (self: ClassConstructor, RequestedLevel: number) -> ()
|
GoToLevel: (self: ClassConstructor, RequestedLevel: number) -> ()
|
||||||
} & Impl_Static_Props
|
} & Impl_Static_Props
|
||||||
|
|
||||||
@@ -35,14 +37,13 @@ type Impl_Static_Props = {
|
|||||||
MaxVelocity: number
|
MaxVelocity: number
|
||||||
}
|
}
|
||||||
|
|
||||||
type Constructor_Fun = (Tags: Tags) -> ClassConstructor
|
type Constructor_Fun = (TagsConstructor: TagsConstructor) -> ClassConstructor
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
Tags: Tags,
|
Tags: Tags,
|
||||||
ElevatorBox_1960: UnionOperation,
|
ElevatorBox_1960: UnionOperation,
|
||||||
ElevatorDoor1: BasePart,
|
ElevatorDoor1: BasePart,
|
||||||
ElevatorDoor2: BasePart,
|
ElevatorDoor2: BasePart,
|
||||||
ElevatorDoorSensor: Folder,
|
ElevatorDoorSensor: Folder,
|
||||||
ProximityButtons: {Instance},
|
|
||||||
BoxAttachment: Attachment,
|
BoxAttachment: Attachment,
|
||||||
BoxAlignPosition: AlignPosition,
|
BoxAlignPosition: AlignPosition,
|
||||||
BoxAlignOrientation: AlignOrientation,
|
BoxAlignOrientation: AlignOrientation,
|
||||||
@@ -50,9 +51,16 @@ type Constructor_Return_Props = {
|
|||||||
Ropes: {Instance},
|
Ropes: {Instance},
|
||||||
TractionRopes: TractionRopes.TractionRopesConstructor,
|
TractionRopes: TractionRopes.TractionRopesConstructor,
|
||||||
PiePlateSelector: UnionOperation,
|
PiePlateSelector: UnionOperation,
|
||||||
__RopeConnection: RBXScriptConnection?
|
Pulley: UnionOperation,
|
||||||
|
Pulley2: UnionOperation,
|
||||||
|
Governor: UnionOperation,
|
||||||
|
GovernorFlyballs: UnionOperation,
|
||||||
|
PieplatePulley: UnionOperation,
|
||||||
|
__MovingConnection: RBXScriptConnection?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ButtonFunction = () -> ()
|
||||||
|
|
||||||
local Otis1960 = {} :: Impl_Constructor
|
local Otis1960 = {} :: Impl_Constructor
|
||||||
Otis1960.__index = Otis1960
|
Otis1960.__index = Otis1960
|
||||||
|
|
||||||
@@ -82,6 +90,20 @@ local function ButtonPress(Button: BasePart, Activated: boolean)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local ButtonFunctions: {[Enums.EnumButtonTree]: ButtonFunction} = {
|
||||||
|
[Enums.ButtonTree.Landing] = function()
|
||||||
|
|
||||||
|
end,
|
||||||
|
|
||||||
|
[Enums.ButtonTree.Car] = function()
|
||||||
|
|
||||||
|
end,
|
||||||
|
|
||||||
|
[Enums.ButtonTree.Special] = function()
|
||||||
|
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
local function HookButtons(self: ClassConstructor, ButtonsConstructor: ButtonTags.ButtonsConstructor, ButtonType: Enums.EnumValue)
|
local function HookButtons(self: ClassConstructor, ButtonsConstructor: ButtonTags.ButtonsConstructor, ButtonType: Enums.EnumValue)
|
||||||
for ButtonNameType, ButtonList in ButtonsConstructor.Buttons do
|
for ButtonNameType, ButtonList in ButtonsConstructor.Buttons do
|
||||||
for ButtonName, ButtonTree in ButtonList do
|
for ButtonName, ButtonTree in ButtonList do
|
||||||
@@ -118,18 +140,22 @@ local function HookButtons(self: ClassConstructor, ButtonsConstructor: ButtonTag
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Otis1960.constructor(Tags)
|
function Otis1960.constructor(TagsConstructor)
|
||||||
local self = {} :: Constructor_Return_Props
|
local self = {} :: Constructor_Return_Props
|
||||||
self.Tags = Tags
|
self.ElevatorBox_1960 = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
|
||||||
self.ElevatorBox_1960 = Tags.ElevatorMover_1960 :: UnionOperation
|
self.ElevatorDoor1 = TagsConstructor:Request("ElevatorDoor_1960_1") :: BasePart
|
||||||
self.ElevatorDoor1 = Tags.ElevatorDoor_1960_1 :: BasePart
|
self.ElevatorDoor2 = TagsConstructor:Request("ElevatorDoor_1960_2") :: BasePart
|
||||||
self.ElevatorDoor2 = Tags.ElevatorDoor_1960_2 :: BasePart
|
self.ElevatorDoorSensor = TagsConstructor:Request("ElevatorDoor_Sensor_1960") :: Folder
|
||||||
self.ElevatorDoorSensor = Tags.ElevatorDoor_Sensor_1960 :: Folder
|
self.Ropes = TagsConstructor:Request("1960_ElevatorPulleyRope") :: {Instance}
|
||||||
self.ProximityButtons = Tags.ProximityElevatorButton :: {Instance}
|
self.PiePlateSelector = TagsConstructor:Request("Otis1960_PiePlateSelector") :: UnionOperation
|
||||||
self.Ropes = Tags["1960_ElevatorPulleyRope"] :: {Instance}
|
self.PiePlatePlates = TagsConstructor:Request("Otis1960_PiePlatePlates") :: UnionOperation
|
||||||
self.PiePlateSelector = Tags.Otis1960_PiePlateSelector :: UnionOperation
|
|
||||||
self.PiePlatePlates = Tags.Otis1960_PiePlatePlates :: UnionOperation
|
--Rotation objects
|
||||||
self.WheelRotation = Tags.WheelRotation :: {Instance}
|
self.Pulley = TagsConstructor:Request("Otis1960_Pulley") :: UnionOperation
|
||||||
|
self.Pulley2 = TagsConstructor:Request("Otis1960_Pulley2") :: UnionOperation
|
||||||
|
self.Governor = TagsConstructor:Request("Otis1960_Governor") :: UnionOperation
|
||||||
|
self.GovernorFlyballs = TagsConstructor:Request("Otis1960_GovernorFlyballs") :: UnionOperation
|
||||||
|
self.PieplatePulley = TagsConstructor:Request("Otis1960_PieplatePulley") :: UnionOperation
|
||||||
|
|
||||||
self.BoxAttachment,
|
self.BoxAttachment,
|
||||||
self.BoxAlignPosition,
|
self.BoxAlignPosition,
|
||||||
@@ -140,7 +166,7 @@ function Otis1960.constructor(Tags)
|
|||||||
self.PiePlate = PieplateModule.constructor(self.PiePlateSelector, self.PiePlatePlates, self.ElevatorBox_1960)
|
self.PiePlate = PieplateModule.constructor(self.PiePlateSelector, self.PiePlatePlates, self.ElevatorBox_1960)
|
||||||
|
|
||||||
--Buttons
|
--Buttons
|
||||||
local ButtonsConstructor = ButtonTags.constructor(Tags, Enums.Elevator.Otis1960)
|
local ButtonsConstructor = ButtonTags.constructor(TagsConstructor, Enums.Elevator.Otis1960)
|
||||||
local Otis1960_Buttons = ButtonsConstructor:CreatePromptButtons()
|
local Otis1960_Buttons = ButtonsConstructor:CreatePromptButtons()
|
||||||
|
|
||||||
local ClassConstructor = setmetatable(self, Otis1960)
|
local ClassConstructor = setmetatable(self, Otis1960)
|
||||||
@@ -151,10 +177,46 @@ function Otis1960.constructor(Tags)
|
|||||||
return ClassConstructor
|
return ClassConstructor
|
||||||
end
|
end
|
||||||
|
|
||||||
function Otis1960:__MoveFloors(Level)
|
function Otis1960:_MoveFloors(Level)
|
||||||
local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position
|
local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position
|
||||||
self.TractionRopes:Moving(Level, 26)
|
local RotationDelta = 0
|
||||||
--self.PiePlate:test()
|
local PulleyPosition = self.Pulley.CFrame
|
||||||
|
local GovernorPosition = self.Governor.CFrame
|
||||||
|
local FlyballPosition = self.GovernorFlyballs.CFrame
|
||||||
|
local Pulley2Position = self.Pulley2.CFrame
|
||||||
|
local PieplatePulleyPosition = self.PieplatePulley.CFrame
|
||||||
|
|
||||||
|
local LastVelocityDelta = 0
|
||||||
|
|
||||||
|
if self.__MovingConnection then
|
||||||
|
self.__MovingConnection:Disconnect()
|
||||||
|
end
|
||||||
|
--Otis1960_ShaftGovernor
|
||||||
|
|
||||||
|
self.__MovingConnection = RS.Heartbeat:Connect(function(_dt) --Not safe for parallel
|
||||||
|
RotationDelta+=1
|
||||||
|
|
||||||
|
local ElevatorPosition = self.ElevatorBox_1960.Position
|
||||||
|
local ElevatorVelocity = self.ElevatorBox_1960:GetVelocityAtPosition(ElevatorPosition).Y
|
||||||
|
local VelocitySmoothing = Easings.Linear(LastVelocityDelta, ElevatorVelocity, .5)
|
||||||
|
LastVelocityDelta = ElevatorVelocity
|
||||||
|
|
||||||
|
local PullAngle_2 = math.rad(RotationDelta*VelocitySmoothing/2)
|
||||||
|
local PullAngle = math.rad(RotationDelta*VelocitySmoothing)
|
||||||
|
|
||||||
|
self.Pulley.CFrame = PulleyPosition *CFrame.Angles(-PullAngle_2, 0, 0)
|
||||||
|
self.Pulley2.CFrame = Pulley2Position *CFrame.Angles(PullAngle_2, 0, 0)
|
||||||
|
self.Governor.CFrame = GovernorPosition *CFrame.Angles(0, PullAngle_2, 0)
|
||||||
|
self.GovernorFlyballs.CFrame = FlyballPosition *CFrame.Angles(PullAngle, 0, 0)
|
||||||
|
self.PieplatePulley.CFrame = PieplatePulleyPosition*CFrame.Angles(PullAngle_2, 0, 0)
|
||||||
|
|
||||||
|
self.TractionRopes:Move(26.3, ElevatorPosition)
|
||||||
|
|
||||||
|
if ElevatorPosition.Y>=self.BoxAlignPosition.Position.Y then
|
||||||
|
(self.__MovingConnection :: RBXScriptConnection):Disconnect()
|
||||||
|
print("Dead")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, Level, ElevatorBoxCurrentPos.Z)
|
self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, Level, ElevatorBoxCurrentPos.Z)
|
||||||
end
|
end
|
||||||
@@ -162,7 +224,7 @@ end
|
|||||||
function Otis1960:GoToLevel(RequestedLevel)
|
function Otis1960:GoToLevel(RequestedLevel)
|
||||||
local level: number = Leveling[RequestedLevel]
|
local level: number = Leveling[RequestedLevel]
|
||||||
if level and level ~= 0 then
|
if level and level ~= 0 then
|
||||||
self:__MoveFloors(level)
|
self:_MoveFloors(level)
|
||||||
else
|
else
|
||||||
warn(`[{Enums.Elevator.Otis1960}]: landing out of range! requested landing: {tostring(RequestedLevel)}`)
|
warn(`[{Enums.Elevator.Otis1960}]: landing out of range! requested landing: {tostring(RequestedLevel)}`)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,17 +10,15 @@ type Impl_Constructor = {
|
|||||||
__index: Impl_Constructor,
|
__index: Impl_Constructor,
|
||||||
constructor: Constructor_Fun,
|
constructor: Constructor_Fun,
|
||||||
--Class functions
|
--Class functions
|
||||||
Moving: (self: ClassConstructor, Level: number, Offset: number) -> (),
|
Move: (self: ClassConstructor, Offset: number, ElevatorPosition: Vector3) -> (),
|
||||||
Stopped: (self: ClassConstructor) -> (),
|
Stopped: (self: ClassConstructor) -> (),
|
||||||
}
|
}
|
||||||
|
|
||||||
type Constructor_Fun = (RopeTags: RopeTags, ElevatorBox: UnionOperation, Leveling: Leveling) -> ClassConstructor
|
type Constructor_Fun = (RopeTags: RopeTags, ElevatorBox: UnionOperation, Leveling: Leveling) -> ClassConstructor
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
Ropes: RopeTags,
|
Ropes: RopeTags,
|
||||||
ElevatorBox: UnionOperation,
|
|
||||||
Leveling: Leveling,
|
Leveling: Leveling,
|
||||||
BiggestRopeLength: number,
|
BiggestRopeLength: number,
|
||||||
__RopeConnection: RBXScriptConnection?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TractionRopesConstructor = ClassConstructor
|
export type TractionRopesConstructor = ClassConstructor
|
||||||
@@ -28,8 +26,6 @@ export type TractionRopesConstructor = ClassConstructor
|
|||||||
local TractionRopes = {} :: Impl_Constructor
|
local TractionRopes = {} :: Impl_Constructor
|
||||||
TractionRopes.__index = TractionRopes
|
TractionRopes.__index = TractionRopes
|
||||||
|
|
||||||
local RS: RunService = game:GetService("RunService")
|
|
||||||
|
|
||||||
function TractionRopes.constructor(RopeTags, ElevatorBox, Leveling)
|
function TractionRopes.constructor(RopeTags, ElevatorBox, Leveling)
|
||||||
local ArbitraryRopeContact = RopeTags[1].Parent :: BasePart
|
local ArbitraryRopeContact = RopeTags[1].Parent :: BasePart
|
||||||
local HighestLevel = Leveling[#Leveling]
|
local HighestLevel = Leveling[#Leveling]
|
||||||
@@ -37,26 +33,17 @@ function TractionRopes.constructor(RopeTags, ElevatorBox, Leveling)
|
|||||||
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
Ropes = RopeTags,
|
Ropes = RopeTags,
|
||||||
ElevatorBox = ElevatorBox,
|
|
||||||
Leveling = Leveling,
|
Leveling = Leveling,
|
||||||
BiggestRopeLength = BiggestRopeLength
|
BiggestRopeLength = BiggestRopeLength
|
||||||
}, TractionRopes)
|
}, TractionRopes)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TractionRopes:Moving(Level, Offset)
|
function TractionRopes:Move(Offset, ElevatorPosition)
|
||||||
if self.__RopeConnection then
|
|
||||||
self.__RopeConnection:Disconnect()
|
|
||||||
end
|
|
||||||
self.__RopeConnection = RS.Heartbeat:Connect(function(_dt) --Not safe for parallel
|
|
||||||
local Elevator = self.ElevatorBox
|
|
||||||
local ElevatorPosition = Elevator.Position
|
|
||||||
local l = self.BiggestRopeLength-ElevatorPosition.Y+Offset
|
local l = self.BiggestRopeLength-ElevatorPosition.Y+Offset
|
||||||
|
|
||||||
for i: number = 1, #self.Ropes do
|
for i: number = 1, #self.Ropes do
|
||||||
(self.Ropes[i] :: RopeConstraint).Length = l
|
(self.Ropes[i] :: RopeConstraint).Length = l
|
||||||
end
|
end
|
||||||
--print(Level-ElevatorPosition.Y)
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function TractionRopes:Stopped()
|
function TractionRopes:Stopped()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export type Effects = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local Lighting = game:GetService("Lighting")
|
local Lighting = game:GetService("Lighting")
|
||||||
local mat_fullbright = false
|
local mat_fullbright = game:GetService("RunService"):IsStudio()
|
||||||
|
|
||||||
local Lighting_PropsTree: LightingProps = {
|
local Lighting_PropsTree: LightingProps = {
|
||||||
["Ambient"] = mat_fullbright and Color3.new(1,1,1) or Color3.fromRGB(40,40,40),
|
["Ambient"] = mat_fullbright and Color3.new(1,1,1) or Color3.fromRGB(40,40,40),
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ local StarterPlayer_Stuff = require(script:WaitForChild("StarterPlayer"))
|
|||||||
local Otis1960_Module = require(Elevators:WaitForChild("Otis1960"))
|
local Otis1960_Module = require(Elevators:WaitForChild("Otis1960"))
|
||||||
|
|
||||||
local TagsConstructor = TagsModule.constructor()
|
local TagsConstructor = TagsModule.constructor()
|
||||||
local Tags = TagsConstructor.Exports
|
print("[DEBUG] Tags=", TagsConstructor.__export)
|
||||||
print("[DEBUG] Tags=", Tags)
|
|
||||||
|
|
||||||
HideEditorEntities.indexAll(not false)
|
HideEditorEntities.indexAll(not false)
|
||||||
TagsConstructor:Nuke()
|
TagsConstructor:Nuke()
|
||||||
@@ -27,4 +26,4 @@ Lighting_Stuff()
|
|||||||
Workspace_Stuff()
|
Workspace_Stuff()
|
||||||
|
|
||||||
--Start the elevators
|
--Start the elevators
|
||||||
local Otis1960 = Otis1960_Module.constructor(Tags)
|
local Otis1960 = Otis1960_Module.constructor(TagsConstructor)
|
||||||
|
|||||||
@@ -2,28 +2,30 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
|
type Error = never
|
||||||
|
|
||||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
type Impl_Constructor = {
|
type Impl_Constructor = {
|
||||||
__index: Impl_Constructor,
|
__index: Impl_Constructor,
|
||||||
constructor: Constructor_Fun,
|
constructor: Constructor_Fun,
|
||||||
--Class functions
|
--Class functions
|
||||||
Nuke: (self: ClassConstructor) -> (),
|
Nuke: (self: ClassConstructor) -> (),
|
||||||
|
Request: (self: ClassConstructor, Name: string) -> TagProduct | Error
|
||||||
}
|
}
|
||||||
|
|
||||||
type Constructor_Fun = () -> ClassConstructor
|
type Constructor_Fun = () -> ClassConstructor
|
||||||
type Constructor_Return_Props = {
|
type Constructor_Return_Props = {
|
||||||
Exports: ExportedTags
|
__export: ExportedTags
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ExportedTags = {
|
export type TagProduct = Instance | {Instance}
|
||||||
[string]: Instance | {Instance}
|
export type ExportedTags = {[string]: TagProduct}
|
||||||
}
|
|
||||||
export type TagsConstructor = ClassConstructor
|
export type TagsConstructor = ClassConstructor
|
||||||
|
|
||||||
local Tags = {} :: Impl_Constructor
|
local Tags = {} :: Impl_Constructor
|
||||||
Tags.__index = Tags
|
Tags.__index = Tags
|
||||||
|
|
||||||
local CS = game:GetService("CollectionService")
|
local CS: CollectionService = game:GetService("CollectionService")
|
||||||
|
|
||||||
function Tags.constructor()
|
function Tags.constructor()
|
||||||
local Exports: ExportedTags = {}
|
local Exports: ExportedTags = {}
|
||||||
@@ -34,15 +36,20 @@ function Tags.constructor()
|
|||||||
local Tagged = CS:GetTagged(TagName)
|
local Tagged = CS:GetTagged(TagName)
|
||||||
Exports[TagName] = #Tagged>1 and Tagged or Tagged[1]
|
Exports[TagName] = #Tagged>1 and Tagged or Tagged[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
Exports = Exports
|
__export = Exports
|
||||||
}, Tags)
|
}, Tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Tags:Nuke()
|
function Tags:Request(Name)
|
||||||
local Exports = self.Exports
|
return self.__export[Name] or error(`Error requesting tag name, tag name "{Name}" does not exist`, 2)
|
||||||
|
end
|
||||||
|
|
||||||
for i: string, v: Instance | {Instance} in Exports do
|
function Tags:Nuke()
|
||||||
|
local Exports = self.__export
|
||||||
|
|
||||||
|
for i: string, v: TagProduct in Exports do
|
||||||
if type(v) == "table" then
|
if type(v) == "table" then
|
||||||
for n: number = 1, #v do
|
for n: number = 1, #v do
|
||||||
CS:RemoveTag(v[n], i)
|
CS:RemoveTag(v[n], i)
|
||||||
|
|||||||
Reference in New Issue
Block a user