working state

This commit is contained in:
2024-04-16 19:48:08 -04:00
parent 9a011c689c
commit 936837eb67
6 changed files with 45 additions and 35 deletions

View File

@@ -5,13 +5,13 @@
local ElevatorsDir = script.Parent
local MainDir = ElevatorsDir.Parent
local TagsModule = require(MainDir:WaitForChild("Tags"))
local Tags = require(MainDir:WaitForChild("Tags"))
local Storage = game:GetService("ReplicatedStorage")
local Enums = require(Storage:WaitForChild("Enums"))
type TagsConstructor = TagsModule.TagsConstructor
type TagProduct = TagsModule.TagProduct
type TagsConstructor = Tags.TagsConstructor
type TagProduct = Tags.TagProduct
type HumanoidRootPart = BasePart
type PromptCallback = (Player: Player) -> ()
@@ -21,19 +21,21 @@ type Impl_Constructor = {
constructor: Constructor_Fun,
--Class functions
DecodeCarTag: (self: ClassConstructor, FloorTag: string) -> number?,
CreatePromptButtons: (self: ClassConstructor) -> TagsModule.ButtonsTree,
AestheticActivateButton: (self: ClassConstructor, Button: BasePart, ActivatedState: boolean, ActivatedColor: Color3) -> ()
CreatePromptButtons: (self: ClassConstructor) -> Tags.ButtonsTree,
AestheticActivateButton: (self: ClassConstructor, Button: BasePart, ActivatedState: boolean, ActivatedColor: Color3) -> thread
} & Impl_Static_Props
type Impl_Static_Props = {
ButtonEnum: any
ButtonEnum: any,
DefaultMaxActivationDistance: number,
DefaultHoldDuration: number
}
type Constructor_Fun = (TagsConstructor: TagsConstructor, Model: Enums.ElevatorValues) -> ClassConstructor
type Constructor_Fun = (TagsConstructor: TagsConstructor, ModelButtons: Tags.ElevatorButtons) -> ClassConstructor
type Constructor_Return_Props = {
Tags: TagsConstructor,
Model: Enums.ElevatorValues,
Buttons: TagsModule.ButtonsTree
ModelButtons: Tags.ElevatorButtons,
Buttons: Tags.ButtonsTree
}
export type ButtonsConstructor = ClassConstructor
@@ -41,10 +43,13 @@ export type ButtonsConstructor = ClassConstructor
local ButtonsModule = {} :: Impl_Constructor
ButtonsModule.__index = ButtonsModule
function ButtonsModule.constructor(TagsConstructor, Model)
ButtonsModule.DefaultMaxActivationDistance = 3
ButtonsModule.DefaultHoldDuration = .30
function ButtonsModule.constructor(TagsConstructor, ModelButtons)
return setmetatable({
Tags = TagsConstructor,
Model = Model,
Tags = TagsConstructor,
ModelButtons = ModelButtons,
Buttons = {
Landing = {},
Car = {},
@@ -61,18 +66,17 @@ SpecialButton = Model_ElevatorButton_Open
RelayButton = Model_RelayButton_F1
]]
function ButtonsModule:CreatePromptButtons()
local ModelButtons = self:Get()
for TagName: string, Inst: Instance in ModelButtons do
for TagName: string, Inst: Instance in self.ModelButtons do
local Attachment = Instance.new("Attachment") :: Attachment
Attachment.Parent = Inst
local Prompt = Instance.new("ProximityPrompt") :: ProximityPrompt
Prompt.MaxActivationDistance = 3
Prompt.HoldDuration = .30
Prompt.MaxActivationDistance = ButtonsModule.DefaultMaxActivationDistance
Prompt.HoldDuration = ButtonsModule.DefaultHoldDuration
Prompt.Parent = Attachment
local Split = TagName:split('_')
local ButtonType = if tonumber(Split[3]) then
local ButtonType: Enums.ButtonValues? = if tonumber(Split[3]) then
Enums.Button.Car
elseif Split[3] == "Floor" and Split[4]:match('%d') then
Enums.Button.Landing
@@ -130,17 +134,17 @@ function ButtonsModule:CreatePromptButtons()
else
Attachment:Destroy()
Prompt:Destroy()
warn(`{self.Model}: Door tag was present but couldnt specify its type for use "{TagName}"`)
warn(`Door tag was present but couldnt specify its type for use "{TagName}"`)
end
print(`[{tostring(ButtonType)}] {self.Model}: created a ProximityPrompt @ "{Inst:GetFullName()}"`)
print(`[{tostring(ButtonType)}] created a ProximityPrompt @ "{Inst:GetFullName()}"`)
end
return self.Buttons
end
function ButtonsModule:AestheticActivateButton(Button, ActivatedState, ActivatedColor)
task.spawn(function()
return task.spawn(function()
local Glass = Button:FindFirstChild("Glass") :: BasePart
local LookVec = Glass.CFrame.LookVector/50
if Glass then

View File

@@ -48,7 +48,7 @@ type Impl_Static_Props = {
__CurrentFloor: number
}
type Constructor_Fun = (TagsConstructor: TagsConstructor, ButtonsTags: Tags.ButtonsTree, LanternsTags: Tags.Lanterns) -> ClassConstructor
type Constructor_Fun = (TagsConstructor: TagsConstructor, ButtonsTags: Tags.ElevatorButtons, LanternsTags: Tags.Lanterns) -> ClassConstructor
type Constructor_Return_Props = {
Tags: Tags,
MOConstructor: MovingObjects.MovingObjectsConstructor,
@@ -102,11 +102,11 @@ local ButtonFunctions: ButtonFunctions = {
end
local Prompt = PromptModule.constructor(ButtonTree.Prompt, ButtonTree.Instance)
local Prompt = PromptModule.constructor(ButtonTree.Prompt, ButtonTree.Inst)
Prompt:AddHookTriggered(function(Player: Player)
if DecodedFloor then
ButtonsConstructor:AestheticActivateButton(ButtonTree.Inst :: BasePart, false, Otis1960.ButtonActivatedColor)
local _ButtonThread = ButtonsConstructor:AestheticActivateButton(ButtonTree.Inst :: BasePart, false, Otis1960.ButtonActivatedColor)
self:GoToLevel(DecodedFloor)
end
end)
@@ -158,9 +158,8 @@ function Otis1960.constructor(TagsConstructor, ButtonsTags, LanternsTags)
--Audio
local LanternDisplay = TagsConstructor:Request("Otis1960_LanternDisplayMain") :: UnionOperation
local LanternTags = TagsConstructor:ElevatorLanterns()[Enums.Elevator.Otis1960]
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, Otis1960.LanternChimeDirection, Otis1960.LanternChimeLanding, LanternTags, {
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, Otis1960.LanternChimeDirection, Otis1960.LanternChimeLanding, LanternsTags, {
Active = Otis1960.LanternDisplayColorOn,
Off = Otis1960.LanternDisplayColorOff
} :: Lanterns.Colors)
@@ -173,13 +172,13 @@ function Otis1960.constructor(TagsConstructor, ButtonsTags, LanternsTags)
self.TractionRopes = TractionRopes.constructor(self.Ropes, self.ElevatorBox_1960, Leveling)
--Buttons
local ButtonsConstructor = ButtonTags.constructor(TagsConstructor, Enums.Elevator.Otis1960)
local ButtonsConstructor = ButtonTags.constructor(TagsConstructor, ButtonsTags)
local Otis1960_Buttons = ButtonsConstructor:CreatePromptButtons()
local ClassConstructor = setmetatable(self, Otis1960)
HookButtons(ClassConstructor, ButtonsConstructor, Enums.ButtonTree.Car)
print("[DEBUG] Otis1960 Lanterns=", LanternTags)
print("[DEBUG] Otis1960 Lanterns=", LanternsTags)
print("[DEBUG] Otis1960 Buttons=", Otis1960_Buttons)
print("🔝 Otis1960 initialized and ready")
return ClassConstructor