mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
working state
This commit is contained in:
@@ -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,
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
local MapDir = script.Parent
|
||||
local MainDir = MapDir.Parent
|
||||
|
||||
local TagService = require(MainDir:WaitForChild("TagService"))
|
||||
local TagService = require(MainDir:WaitForChild("Tags"))
|
||||
|
||||
type LightCallback = (Player: Player) -> ()
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ local function NewPromptConnection(self: ClassConstructor, PromptSignal: PromptS
|
||||
if self.Prompt then
|
||||
if self.Instance then
|
||||
if self.__PromptConnections[PromptSignalName] and self.__PromptConnections[PromptSignalName].Connected then
|
||||
warn()
|
||||
warn("asd")
|
||||
end
|
||||
|
||||
self.__PromptConnections[PromptSignalName] = PromptSignal:Connect(function(Player: Player)
|
||||
@@ -87,6 +87,7 @@ end
|
||||
function Prompts:AddHookTriggered(Callback)
|
||||
self.__TriggeredCallback = Callback
|
||||
|
||||
--These dont make sense...
|
||||
NewPromptConnection(self, self.Prompt.Triggered, "Triggered")
|
||||
end
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ type Impl_Constructor = {
|
||||
Nuke: (self: ClassConstructor) -> (),
|
||||
Request: (self: ClassConstructor, Name: string) -> TagProduct | Error,
|
||||
__ElevatorLanterns: (self: ClassConstructor) -> LanternsTree,
|
||||
__ElevatorButtons: (self: ClassConstructor) -> ElevatorButtons,
|
||||
__ElevatorButtons: (self: ClassConstructor) -> ElevatorModelButtons,
|
||||
__Interactables: (self: ClassConstructor) -> InteractablesTree
|
||||
} & Impl_Static_Props
|
||||
|
||||
@@ -43,9 +43,11 @@ type Lantern = {
|
||||
}
|
||||
|
||||
export type ElevatorButtons = {
|
||||
[Enums.ElevatorValues]: {
|
||||
[string]: Instance
|
||||
}
|
||||
}
|
||||
|
||||
export type ElevatorModelButtons = {
|
||||
[Enums.ElevatorValues]: ElevatorButtons
|
||||
}
|
||||
|
||||
export type Lanterns = {
|
||||
@@ -137,6 +139,8 @@ function Tags:Nuke()
|
||||
warn("☢️ nuked all in-game tags. Left-over tags="..table.concat(CS:GetAllTags(), ", "))
|
||||
end
|
||||
|
||||
--Parsers:
|
||||
|
||||
function Tags:__ElevatorLanterns()
|
||||
local Lanterns: LanternsTree = {}
|
||||
|
||||
@@ -187,7 +191,7 @@ function Tags:__ElevatorLanterns()
|
||||
end
|
||||
|
||||
function Tags:__ElevatorButtons()
|
||||
local Buttons: ElevatorButtons = {}
|
||||
local Buttons: ElevatorModelButtons = {}
|
||||
|
||||
for _, EnumValue in Enums.Elevator do
|
||||
Buttons[EnumValue :: Enums.ElevatorValues] = {}
|
||||
|
||||
@@ -37,7 +37,9 @@ print("[DEBUG] Interactables=", Interactables)
|
||||
|
||||
--Start the elevators
|
||||
local Buttons = TagsConstructor:__ElevatorButtons()
|
||||
print("[DEBUG] Buttons=", Buttons)
|
||||
local Lanterns = TagsConstructor:__ElevatorLanterns()
|
||||
print("[DEBUG] Lanterns=", Lanterns)
|
||||
|
||||
local Otis1960Lanterns = Lanterns[Enums.Elevator.Otis1960]
|
||||
local Otis1960Buttons = Buttons[Enums.Elevator.Otis1960]
|
||||
|
||||
Reference in New Issue
Block a user