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 ElevatorsDir = script.Parent
local MainDir = ElevatorsDir.Parent local MainDir = ElevatorsDir.Parent
local TagsModule = require(MainDir:WaitForChild("Tags")) local Tags = require(MainDir:WaitForChild("Tags"))
local Storage = game:GetService("ReplicatedStorage") local Storage = game:GetService("ReplicatedStorage")
local Enums = require(Storage:WaitForChild("Enums")) local Enums = require(Storage:WaitForChild("Enums"))
type TagsConstructor = TagsModule.TagsConstructor type TagsConstructor = Tags.TagsConstructor
type TagProduct = TagsModule.TagProduct type TagProduct = Tags.TagProduct
type HumanoidRootPart = BasePart type HumanoidRootPart = BasePart
type PromptCallback = (Player: Player) -> () type PromptCallback = (Player: Player) -> ()
@@ -21,19 +21,21 @@ type 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) -> TagsModule.ButtonsTree, CreatePromptButtons: (self: ClassConstructor) -> Tags.ButtonsTree,
AestheticActivateButton: (self: ClassConstructor, Button: BasePart, ActivatedState: boolean, ActivatedColor: Color3) -> () AestheticActivateButton: (self: ClassConstructor, Button: BasePart, ActivatedState: boolean, ActivatedColor: Color3) -> thread
} & Impl_Static_Props } & Impl_Static_Props
type 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 = { type Constructor_Return_Props = {
Tags: TagsConstructor, Tags: TagsConstructor,
Model: Enums.ElevatorValues, ModelButtons: Tags.ElevatorButtons,
Buttons: TagsModule.ButtonsTree Buttons: Tags.ButtonsTree
} }
export type ButtonsConstructor = ClassConstructor export type ButtonsConstructor = ClassConstructor
@@ -41,10 +43,13 @@ export type ButtonsConstructor = ClassConstructor
local ButtonsModule = {} :: Impl_Constructor local ButtonsModule = {} :: Impl_Constructor
ButtonsModule.__index = ButtonsModule ButtonsModule.__index = ButtonsModule
function ButtonsModule.constructor(TagsConstructor, Model) ButtonsModule.DefaultMaxActivationDistance = 3
ButtonsModule.DefaultHoldDuration = .30
function ButtonsModule.constructor(TagsConstructor, ModelButtons)
return setmetatable({ return setmetatable({
Tags = TagsConstructor, Tags = TagsConstructor,
Model = Model, ModelButtons = ModelButtons,
Buttons = { Buttons = {
Landing = {}, Landing = {},
Car = {}, Car = {},
@@ -61,18 +66,17 @@ SpecialButton = Model_ElevatorButton_Open
RelayButton = Model_RelayButton_F1 RelayButton = Model_RelayButton_F1
]] ]]
function ButtonsModule:CreatePromptButtons() function ButtonsModule:CreatePromptButtons()
local ModelButtons = self:Get() for TagName: string, Inst: Instance in self.ModelButtons do
for TagName: string, Inst: Instance in ModelButtons do
local Attachment = Instance.new("Attachment") :: Attachment local Attachment = Instance.new("Attachment") :: Attachment
Attachment.Parent = Inst Attachment.Parent = Inst
local Prompt = Instance.new("ProximityPrompt") :: ProximityPrompt local Prompt = Instance.new("ProximityPrompt") :: ProximityPrompt
Prompt.MaxActivationDistance = 3 Prompt.MaxActivationDistance = ButtonsModule.DefaultMaxActivationDistance
Prompt.HoldDuration = .30 Prompt.HoldDuration = ButtonsModule.DefaultHoldDuration
Prompt.Parent = Attachment Prompt.Parent = Attachment
local Split = TagName:split('_') local Split = TagName:split('_')
local ButtonType = 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
Enums.Button.Landing Enums.Button.Landing
@@ -130,17 +134,17 @@ function ButtonsModule:CreatePromptButtons()
else else
Attachment:Destroy() Attachment:Destroy()
Prompt: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 end
print(`[{tostring(ButtonType)}] {self.Model}: created a ProximityPrompt @ "{Inst:GetFullName()}"`) print(`[{tostring(ButtonType)}] created a ProximityPrompt @ "{Inst:GetFullName()}"`)
end end
return self.Buttons return self.Buttons
end end
function ButtonsModule:AestheticActivateButton(Button, ActivatedState, ActivatedColor) function ButtonsModule:AestheticActivateButton(Button, ActivatedState, ActivatedColor)
task.spawn(function() return task.spawn(function()
local Glass = Button:FindFirstChild("Glass") :: BasePart local Glass = Button:FindFirstChild("Glass") :: BasePart
local LookVec = Glass.CFrame.LookVector/50 local LookVec = Glass.CFrame.LookVector/50
if Glass then if Glass then

View File

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

View File

@@ -5,7 +5,7 @@
local MapDir = script.Parent local MapDir = script.Parent
local MainDir = MapDir.Parent local MainDir = MapDir.Parent
local TagService = require(MainDir:WaitForChild("TagService")) local TagService = require(MainDir:WaitForChild("Tags"))
type LightCallback = (Player: Player) -> () type LightCallback = (Player: Player) -> ()

View File

@@ -70,7 +70,7 @@ local function NewPromptConnection(self: ClassConstructor, PromptSignal: PromptS
if self.Prompt then if self.Prompt then
if self.Instance then if self.Instance then
if self.__PromptConnections[PromptSignalName] and self.__PromptConnections[PromptSignalName].Connected then if self.__PromptConnections[PromptSignalName] and self.__PromptConnections[PromptSignalName].Connected then
warn() warn("asd")
end end
self.__PromptConnections[PromptSignalName] = PromptSignal:Connect(function(Player: Player) self.__PromptConnections[PromptSignalName] = PromptSignal:Connect(function(Player: Player)
@@ -87,6 +87,7 @@ end
function Prompts:AddHookTriggered(Callback) function Prompts:AddHookTriggered(Callback)
self.__TriggeredCallback = Callback self.__TriggeredCallback = Callback
--These dont make sense...
NewPromptConnection(self, self.Prompt.Triggered, "Triggered") NewPromptConnection(self, self.Prompt.Triggered, "Triggered")
end end

View File

@@ -17,7 +17,7 @@ type Impl_Constructor = {
Nuke: (self: ClassConstructor) -> (), Nuke: (self: ClassConstructor) -> (),
Request: (self: ClassConstructor, Name: string) -> TagProduct | Error, Request: (self: ClassConstructor, Name: string) -> TagProduct | Error,
__ElevatorLanterns: (self: ClassConstructor) -> LanternsTree, __ElevatorLanterns: (self: ClassConstructor) -> LanternsTree,
__ElevatorButtons: (self: ClassConstructor) -> ElevatorButtons, __ElevatorButtons: (self: ClassConstructor) -> ElevatorModelButtons,
__Interactables: (self: ClassConstructor) -> InteractablesTree __Interactables: (self: ClassConstructor) -> InteractablesTree
} & Impl_Static_Props } & Impl_Static_Props
@@ -43,9 +43,11 @@ type Lantern = {
} }
export type ElevatorButtons = { export type ElevatorButtons = {
[Enums.ElevatorValues]: {
[string]: Instance [string]: Instance
} }
export type ElevatorModelButtons = {
[Enums.ElevatorValues]: ElevatorButtons
} }
export type Lanterns = { export type Lanterns = {
@@ -137,6 +139,8 @@ 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 = {}
@@ -187,7 +191,7 @@ function Tags:__ElevatorLanterns()
end end
function Tags:__ElevatorButtons() function Tags:__ElevatorButtons()
local Buttons: ElevatorButtons = {} local Buttons: ElevatorModelButtons = {}
for _, EnumValue in Enums.Elevator do for _, EnumValue in Enums.Elevator do
Buttons[EnumValue :: Enums.ElevatorValues] = {} Buttons[EnumValue :: Enums.ElevatorValues] = {}

View File

@@ -37,7 +37,9 @@ print("[DEBUG] Interactables=", Interactables)
--Start the elevators --Start the elevators
local Buttons = TagsConstructor:__ElevatorButtons() local Buttons = TagsConstructor:__ElevatorButtons()
print("[DEBUG] Buttons=", Buttons)
local Lanterns = TagsConstructor:__ElevatorLanterns() local Lanterns = TagsConstructor:__ElevatorLanterns()
print("[DEBUG] Lanterns=", Lanterns)
local Otis1960Lanterns = Lanterns[Enums.Elevator.Otis1960] local Otis1960Lanterns = Lanterns[Enums.Elevator.Otis1960]
local Otis1960Buttons = Buttons[Enums.Elevator.Otis1960] local Otis1960Buttons = Buttons[Enums.Elevator.Otis1960]